Bläddra i källkod

to be compatible with windows & styling code (#1951)

Tingquan Gao 1 år sedan
förälder
incheckning
f2e8652ff3
1 ändrade filer med 9 tillägg och 1 borttagningar
  1. 9 1
      paddlex/repo_manager/utils.py

+ 9 - 1
paddlex/repo_manager/utils.py

@@ -15,12 +15,16 @@
 import os
 import sys
 import json
+import platform
 import subprocess
 import contextlib
 
 from parsley import makeGrammar
 
 
+PLATFORM = platform.system()
+
+
 def _check_call(*args, **kwargs):
     return subprocess.check_call(*args, **kwargs)
 
@@ -98,7 +102,11 @@ def reset_repo_using_git(pointer, hard=True):
 
 def remove_repo_using_rm(name):
     """remove_repo_using_rm"""
-    return _check_call(["rm", "-rf", name])
+    if os.path.exists(name):
+        if PLATFORM == "Windows":
+            return _check_call(["rmdir", "/S", "/Q", name], shell=True)
+        else:
+            return _check_call(["rm", "-rf", name])
 
 
 def build_wheel_using_pip(pkg, dst_dir="./", with_deps=False, pip_flags=None):