-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutilities.py
More file actions
38 lines (27 loc) · 1.14 KB
/
Copy pathutilities.py
File metadata and controls
38 lines (27 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os, sys, subprocess, re
# colored print functions:
def printinfo(message):
print("\033[1;36m" + message + "\033[1;m")
def printerror(message):
print("\033[1;31m" + message + "\033[1;m")
# build helpers:
def shellcall(command, error="", terminate=False):
if subprocess.call(command, shell=True) != 0:
if error:
printerror(error)
if terminate:
sys.exit(1)
return False
return True
def run_qmake_make(qmakecommand, silent=True, threads=5):
shellcall(qmakecommand+" > /dev/null", error="qmake failed", terminate=True)
shellcall("make {} -j{}".format("-s" if silent else "", threads), error="make failed", terminate=True)
def list_qmakes():
paths = os.environ["PATH"].split(os.path.pathsep)
result = []
qmakeregex = re.compile(r"^qmake\d+$")
for path in filter(os.path.isdir, paths):
for f in filter(qmakeregex.match, os.listdir(path)):
if os.access(os.path.join(path, f), os.X_OK):
result.append(f)
return sorted(result, key=lambda s: s if len(s)>8 else s[:-2]+'0'+s[-2:]) # lambda makes sure qmake5101 comes after qmake591