-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpythonanywhere_deploy.py
More file actions
59 lines (46 loc) · 1.53 KB
/
Copy pathpythonanywhere_deploy.py
File metadata and controls
59 lines (46 loc) · 1.53 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sh, shutil, glob
def main():
root = '/home/saarsayfan/'
sh.nvm.alias('default', 'v9.6.1')
print(nvm.stdout)
gp = sh.git('pull')
if gp.stdout.startswith('Already up-to-date.'):
continue = raw_input('UP TO DATE. CONTINUE (Y/N)?')
if continue.lower() != 'y':
return
nrb = sh.npm('run', 'build')
if 'STDERR' in nrb.stdout:
print(nrb.stdout)
return
print('BUILD SUCCESSFUL')
cdbs = sh.cd(root + 'rumble-react/build/static')
shutil.copytree('js', '../js')
shutil.copytree('css', '../css')
shutil.copytree('media', '../media')
cdb = sh.cd(root + 'rumble-react/build')
shutil.rmtree('static')
with open('index.html', 'r+') as f:
t = f.read()
t = t.replace('favicon.ico', 'static/rumble-react/favicon.ico')
f.seek(0)
f.write(t)
f.truncate()
filename = glob.glob('js/*.js')[0]
with open(filename, 'r+') as f:
t = f.read()
t = t.replace('/images/logo.png', 'rumble-react/images/logo.png')
f.seek(0)
f.write(t)
f.truncate()
with open('index.html', 'r+') as f:
t = f.read()
t = t.replace('static', 'static/rumble-react')
f.seek(0)
f.write(t)
f.truncate()
cdrr = sh.cd(root + 'rumble-react')
shutil.rmtree(root + 'Rumble-React-Builds/build')
shutil.copytree(root + 'rumble-react/build', root + 'Rumble-React-Builds/build')
print('DEPLOYMENT SUCCESSFUL!!! (HOPEFULLY)')
if __name__ == '__main__':
main()