-
Notifications
You must be signed in to change notification settings - Fork 21
/
gen_resources.py
47 lines (40 loc) · 1.79 KB
/
gen_resources.py
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
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, os, multiprocessing, subprocess
root_path = os.path.abspath(os.path.join(os.path.dirname(__file__)))
resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'res'))
gen_resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src/sakia'))
def convert_ui(args, **kwargs):
subprocess.call(args, **kwargs)
def build_resources():
try:
to_process = []
for root, dirs, files in os.walk(root_path):
for f in files:
if f.endswith('.ui'):
source = os.path.join(root, f)
dest = os.path.join(root, os.path.splitext(os.path.basename(source))[0]+'_uic.py')
exe = 'pyuic5'
elif f.endswith('.qrc'):
source = os.path.join(root, f)
filename = os.path.splitext(os.path.basename(source))[0]
# we remove "sakia." from the rc filename
# its only named like this so that imports are corrects in uic files
dest = os.path.join(gen_resources, filename.replace('sakia.', '')+'_rc.py')
exe = 'pyrcc5'
else:
continue
print(source + " >> " + dest)
to_process.append([exe, '-o', dest, source])
if sys.platform.startswith('win'):
# doing this in parallel on windows will crash your computer
[convert_ui(args, shell=True) for args in to_process]
else:
pool = multiprocessing.Pool()
pool.map(convert_ui, to_process)
except EnvironmentError:
print("""\
Warning: PyQt5 development utilities (pyuic5 and pyrcc5) not found
Unable to install praxes' graphical user interface
""")
build_resources()