-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunall.py
More file actions
38 lines (29 loc) · 988 Bytes
/
runall.py
File metadata and controls
38 lines (29 loc) · 988 Bytes
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
import os
from multiprocessing import Pool
def run_flask_process(process):
print(f'RUN {process}')
os.system('python "{}"'.format(process))
def run_django_process(process):
print(f'MIGRATE {process}')
os.system(f'python "{process}" migrate')
print(f'RUN {process}')
os.system(f'python "{process}" runserver 0.0.0.0:8000')
def run_process(process):
name, ptype = process
if ptype == 'flask':
run_flask_process(name)
if ptype == 'django':
run_django_process(name)
FLASK_RUN = 'main.py'
DJANGO_RUN = 'manage.py'
run_files = []
for path, folders, files in os.walk(os.getcwd()):
if FLASK_RUN in files:
run_path = os.path.join(path, FLASK_RUN)
run_files.append((run_path, 'flask'))
if DJANGO_RUN in files:
run_path = os.path.join(path, DJANGO_RUN)
run_files.append((run_path, 'django'))
if __name__ == '__main__':
pool = Pool(processes=len(run_files))
pool.map(run_process, run_files)