-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_data.py
73 lines (66 loc) · 2.06 KB
/
build_data.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import subprocess
import shutil
import errno
import glob
import sys
import os
def mkdirp(path, mode = 0o777):
head, tail = os.path.split(path)
if not tail:
head, tail = os.path.split(head)
if head and tail and not os.path.exists(head):
try:
mkdirp(head, mode)
except OSError as e:
# be happy if someone already created the path
if e.errno != errno.EEXIST:
raise
if tail == os.curdir: # xxx/newdir/. exists if xxx/newdir exists
return
try:
os.mkdir(path, mode)
except OSError as e:
# be happy if someone already created the path
if e.errno != errno.EEXIST:
raise
# Create data dir
mkdirp('data/www')
# Copy config
if os.path.isfile('data_src/config') == False :
if (os.path.isfile('data_src/config.in') == False) :
print('Warning: copy "config" from "config.in".')
shutil.copy('data_src/config.in', 'data_src/config')
else :
sys.exit("Error: 'data_src/config.in' isn't exist.")
shutil.copy('data_src/config', 'data/config')
subprocess.Popen([
"html-minifier",
"--collapse-whitespace",
"--remove-comments",
"--remove-redundant-attributes",
"--remove-tag-whitespace",
"--use-short-doctype",
"--minify-css=true",
"--minify-js=true",
"--output=data/www/index.html",
"data_src/www/index.html"],
shell=True
)
subprocess.Popen([
"html-minifier",
"--collapse-whitespace",
"--remove-comments",
"--remove-redundant-attributes",
"--remove-tag-whitespace",
"--use-short-doctype",
"--minify-css=true",
"--minify-js=true",
"--output=data/www/style.css",
"data_src/www/style.css"],
shell=True
)
shutil.copy('data_src/www/script.js', 'data/www/script.js')
shutil.copy('data_src/www/mfglabsiconset-webfont.svg', 'data/www/mfglabsiconset-webfont.svg')
shutil.copy('data_src/www/mfglabsiconset-webfont.eot', 'data/www/mfglabsiconset-webfont.eot')
shutil.copy('data_src/www/mfglabsiconset-webfont.ttf', 'data/www/mfglabsiconset-webfont.ttf')
shutil.copy('data_src/www/mfglabsiconset-webfont.woff', 'data/www/mfglabsiconset-webfont.woff')