-
Notifications
You must be signed in to change notification settings - Fork 0
/
populate_sheets_package.py
48 lines (40 loc) · 1.48 KB
/
populate_sheets_package.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
import subprocess
import yaml
from datetime import datetime, timedelta
with open("config_create_sheets.yaml", "r") as cr:
config_vals = yaml.full_load(cr)
MAIN = config_vals['MAIN']
CORE = config_vals['CORE']
with open(""+str(MAIN)+"config_create_sheets.yaml", "r") as cr:
config_vals = yaml.full_load(cr)
n = config_vals['n']
t = datetime.today() - timedelta(days=n)
a = t.strftime('%Y-%m-%d')
format = "%Y-%m-%d"
t = datetime.strptime(a, format).date()
print(t)
config_vals['datetime'] = t
with open("" + str(MAIN) + "config_create_sheets.yaml", "w") as cw:
yaml.dump(config_vals, cw, default_flow_style=True)
while n > 0:
with open(""+str(MAIN)+"config_create_sheets.yaml", "r") as cr:
config_vals = yaml.full_load(cr)
n = config_vals['n']
script_path = "" + str(MAIN) + "startupscript1.sh"
result = subprocess.call(['bash', script_path])
config_vals['n'] = n - 1
with open(""+str(MAIN)+"config_create_sheets.yaml", "w") as cw:
yaml.dump(config_vals, cw, default_flow_style=True)
with open(""+str(MAIN)+"config_create_sheets.yaml", "r") as cr:
config_vals = yaml.full_load(cr)
n = config_vals['n']
t = datetime.today() - timedelta(days=n)
a = t.strftime('%Y-%m-%d')
format = "%Y-%m-%d"
t = datetime.strptime(a, format).date()
print(t)
config_vals['datetime'] = t
with open(""+str(MAIN)+"config_create_sheets.yaml", "w") as cw:
yaml.dump(config_vals, cw, default_flow_style=True)
continue
break