-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy_webapp.py
More file actions
33 lines (25 loc) · 845 Bytes
/
deploy_webapp.py
File metadata and controls
33 lines (25 loc) · 845 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
#! /usr/bin/python
import json
import os, fnmatch
import sys, getopt
import yaml
def get_config(key):
with open("ddr_config.props", 'r') as propsfile:
props = yaml.load(propsfile)
return props.get(key)
def listFiles(inputDir, file_ext):
return fnmatch.filter(os.listdir(inputDir), '*.' + file_ext)
s3bucket = get_config('s3_bucket')
s3_webapp_bucket = get_config('s3_webapp_bucket')
api_url = get_config('api_url')
app_dir = 'scoreboard-web-app'
html_files = listFiles(app_dir, 'html')
js_files = listFiles(app_dir, 'js')
all_files = html_files + js_files
for src_file in all_files:
print(src_file)
with open(app_dir + '/' + src_file, 'r+') as f:
content = f.read()
f.seek(0)
f.truncate()
f.write(content.replace('S3_BUCKET_TOKEN', s3bucket).replace('API_URL_TOKEN', api_url))