-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
80 lines (64 loc) · 2.35 KB
/
main.py
File metadata and controls
80 lines (64 loc) · 2.35 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#-*- coding: utf-8 -*-
from __future__ import print_function
import os, sys
import sys
import datetime
import json
import google_upload
#Input Argument
#python main.py timestamp(0 or YYYY.MM.DD_HH:MM) locationNo 0.3um 0.5um 5um
#or
#python main.py --help
#or
#python main.py -h
#sys.argv[0] #TimeStamp or Realtime Parameter
#sys.argv[1] #first Value
#sys.argv[2] #second Value
#sys.argv[3] #third Value
if sys.version_info.major<3:
print("Python version is too low, use over python 3")
exit()
from builtins import input
with open('cfg.json', 'r') as cfgfile:
cfgdata = json.load(cfgfile)
if len(sys.argv) == 1:
print('')
print('if you help to use program, do \"python main.py --help\" or \"python main.py -help\"\n RUN IN INTERACTIVE MODE\n')
os.system('python3 main_interactive.py')
exit()
if sys.argv[1] == '-h' or sys.argv[1] == '--help':
print("Help for Dust Monitoring Input Python Script")
print("1. to use interactive input: \"python main.py\" or \"python main_interactive.py\"")
print("2. to use command line input: ", end='\n')
print("python main.py timestamp(0 or YYYY-MM-DD HH:MM) ", end='')
if len(cfgdata["Locations"])!=1:
print('LocationNumber ', end='')
for i in range(0,len(cfgdata['Type1'])):
for j in range(0,len(cfgdata['Type2'])):
print(cfgdata['Type2'][j]+'of'+cfgdata['Type1'][i], end=' ')
print('')
if len(cfgdata["Locations"])!=1:
print('\nlocation numbers')
locationind = 1
for location in list(cfgdata["Locations"]):
print("%d: %s" %(locationind, location))
locationind = locationind + 1
exit()
########################################################################
if sys.argv[1] == '0':
TimeStamp = datetime.datetime.now()#.strftime('%Y/%m/%d-%H:%M')
else:
TimeStamp = datetime.datetime.strptime(sys.argv[1],'%Y-%m-%d %H:%M')
dustdata = dict()
if len(cfgdata["Locations"])==1:
k = 2
location = cfgdata["Locations"][0]
else:
k = 3
location = cfgdata["Locations"][int(sys.argv[2])]
for i in range(0,len(cfgdata['Type1'])):
dustdata[cfgdata['Type1'][i]] = dict()
for j in range(0,len(cfgdata['Type2'])):
dustdata[cfgdata['Type1'][i]][cfgdata['Type2'][j]] = int(sys.argv[k])
k = k+1
google_upload.Upload_dict('TimeStamp', TimeStamp.strftime('%Y-%m-%d %H:%M'), location, dustdata)