-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-dev.py
44 lines (37 loc) · 1.54 KB
/
build-dev.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
import os
import subprocess
import time
CURRENT_DIRECTORY = os.getcwd()
directories = os.listdir(CURRENT_DIRECTORY)
NON_ANGULAR_DIRS = ['static', 'templates', 'venv', '__pycache__']
for directory in directories:
if "." not in directory and directory not in NON_ANGULAR_DIRS:
ANGULAR_PROJECT_PATH = os.path.join(CURRENT_DIRECTORY, directory)
DIST_PATH = os.path.join(ANGULAR_PROJECT_PATH, 'dist', directory)
FLASK_STATIC_PATH = os.path.join(CURRENT_DIRECTORY, 'static')
FLASK_TEMPLATES_PATH = os.path.join(CURRENT_DIRECTORY, 'templates')
print(ANGULAR_PROJECT_PATH, FLASK_STATIC_PATH,
FLASK_TEMPLATES_PATH, NON_ANGULAR_DIRS)
subprocess.call(('cd ' + ANGULAR_PROJECT_PATH +
' && ng build --watch --prod --base-href /static/ &'), shell=True)
dir_exists = True
while dir_exists:
try:
files = os.listdir(DIST_PATH)
static_files = ""
html_files = ""
for file in files:
if '.js' in file or '.js.map' in file or '.ico' in file:
static_files += (file + ' ')
if '.html' in file:
html_files += (file + ' ')
if len(static_files) > 0:
subprocess.call(('cd ' + DIST_PATH + ' &&' + ' mv ' +
static_files + FLASK_STATIC_PATH), shell=True)
if len(html_files) > 0:
subprocess.call(('cd ' + DIST_PATH + ' &&' + ' mv ' +
html_files + FLASK_TEMPLATES_PATH), shell=True)
except Exception as e:
dir_exists = False
print(e)
time.sleep(10.0)