-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRun_Parsivel_all.py
More file actions
executable file
·59 lines (47 loc) · 1.63 KB
/
Run_Parsivel_all.py
File metadata and controls
executable file
·59 lines (47 loc) · 1.63 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
#!/home/cpabla/anaconda3/envs/pysimba/bin/python
# coding: utf-8
import sys, glob, os
import subprocess
from datetime import date
from datetime import timedelta
import warnings
warnings.filterwarnings("ignore")
def get_ymd_from_command_line(argv):
nargs = len(argv)
if(nargs == 2):
theDate = date.today()
if(argv[1] == 'TODAY'):
year = theDate.year
month = theDate.month
day = theDate.day
if(argv[1] == 'YESTERDAY'):
theDate = date.today() - timedelta(days=1)
year = theDate.year
month = theDate.month
day = theDate.day
if(nargs == 4):
year = int(argv[1])
month = int(argv[2])
day = int(argv[3])
if( (nargs != 2) & (nargs !=4)):
sys.exit('Must provide TODAY, YESTERDAY or year, month, day')
return year, month, day
# ****************************************************************************************
if __name__ == "__main__":
site = 'WFF'
prog = 'Proc_Parsivel.py'
# Parse command line to get date for execution
year, month, day = get_ymd_from_command_line(sys.argv)
syear = str(year).zfill(4)
smonth = str(month).zfill(2)
sday = str(day).zfill(2)
sdate = smonth + '/' + sday + '/' + syear
#insts = ['apu01', 'apu04', 'apu11', 'apu15',
# 'apu17', 'apu18']
#insts = ['apu02']
insts = ['apu02', 'apu07', 'apu16', 'apu21']
for i,inst in enumerate(insts):
c = prog + ' ' + site + ' ' + inst + ' ' + syear + ' ' + smonth + ' ' + sday
clist = c.split()
print(c)
subprocess.run(clist)