aboutsummaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/utils.py b/utils.py
index 1e23a89c4..adcaf09ef 100644
--- a/utils.py
+++ b/utils.py
@@ -347,7 +347,7 @@ def copydir(src, dst, filter=None, ignore=None, force=True, recursive=True, vars
return results
-def rmtree(dirname):
+def rmtree(dirname, ignore=False):
def handleRemoveReadonly(func, path, exc):
excvalue = exc[1]
if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES:
@@ -355,7 +355,7 @@ def rmtree(dirname):
func(path)
else:
raise
- shutil.rmtree(dirname, ignore_errors=False, onerror=handleRemoveReadonly)
+ shutil.rmtree(dirname, ignore_errors=ignore, onerror=handleRemoveReadonly)
def run_process_output(args, initial_env=None):
if initial_env is None:
@@ -901,3 +901,31 @@ def get_python_dict(python_script_path):
except IOError as e:
print("get_python_dict: Couldn't get dict from python file: {}.".format(python_script_path))
raise
+
+def install_pip_dependencies(env_pip, packages):
+ for p in packages:
+ run_instruction([env_pip, "install", p], "Failed to install " + p)
+
+def get_qtci_virtualEnv(python_ver, host):
+ _pExe = "python"
+ _env = "env" + str(python_ver)
+ env_python = _env + "/bin/python"
+ env_pip = _env + "/bin/pip"
+
+ if host == "Windows":
+ _pExe = "python.exe"
+ if python_ver == "3":
+ _pExe = os.path.join(os.getenv("PYTHON3_PATH"), "python.exe")
+ env_python = _env + "\\Scripts\\python.exe"
+ env_pip = _env + "\\Scripts\\pip.exe"
+ else:
+ if python_ver == "3":
+ _pExe = "python3"
+ return(_pExe, _env, env_pip, env_python)
+
+def run_instruction(instruction, error):
+ print("Running Coin instruction: " + ' '.join(str(e) for e in instruction))
+ result = subprocess.call(instruction)
+ if result != 0:
+ print("ERROR : " + error)
+ exit(result)