Skip to content

Commit c402028

Browse files
committed
Adjusting to Wanda
Python path fixed Added secret : wrcc14 password booFirstRun adjusted to compensate for hipk and whpt not accepting password. stuck at 30days.
1 parent 33f6a10 commit c402028

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

sensor_ucnrs_dri_puller.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python3
1+
#!/home/collin/pyv/bin/python
22
################################################################################
33
# name: sensor_ucnrs_dri_puller.py
44
# author: collin bode, email: [email protected]
@@ -74,15 +74,23 @@
7474

7575
# stations that only can download 30 days or newer without password
7676
#stations = ['hipk','whpt','sagh','croo','wmtn','barc']
77-
77+
7878
# Loop through all the stations, webscrape, and parse
7979
for station in stations:
8080
print(station)
81+
8182
# Define path and station filename
82-
#path = '/data/sensor/UCNRS/'
83-
path = '/Users/cbode/Documents/GoogleDrive/UCNRS_WeatherStations/DatFiles_DRI/'
83+
path = '/data/sensor/UCNRS/'
84+
#path = '/Users/cbode/Documents/GoogleDrive/UCNRS_WeatherStations/DatFiles_DRI/'
85+
ftdirpath = path+'/dri_time/'
86+
87+
# Check for existance of the time files directory, if not create
88+
if(os.path.exists(ftdirpath) == False):
89+
os.makedirs(ftdirpath)
90+
91+
# Define file paths
8492
fpath = path+station+'_dri.dat'
85-
ftpath = fpath+'.time' # The .time file holds the last timestmap recorded
93+
ftpath = ftdirpath+station+'_dri.dat.time' # The .time file holds the last timestmap recorded
8694

8795
# Build a header if the file doesn't exist yet and FirstRun wasn't called.
8896
if(os.path.exists(fpath) == False):
@@ -91,8 +99,10 @@
9199
# TIME - get start datetime to pull data. booFirstRun
92100
time_end = dt.datetime.now()
93101
if(booFirstRun == True):
94-
#time_start = dt.datetime.now() - dt.timedelta(days=29) # For 30 day locked stations
95-
time_start = dt.datetime.strptime('1990-01-01 01:00:00',"%Y-%m-%d %H:%M:%S")
102+
if(station =='hipk' or station == 'whpt'):
103+
time_start = dt.datetime.now() - dt.timedelta(days=29) # For 30 day locked stations
104+
else:
105+
time_start = dt.datetime.strptime('1990-01-01 01:00:00',"%Y-%m-%d %H:%M:%S")
96106
time_start_o = time_start
97107
write_mode = 'w' # new file
98108
booWriteHeader = True
@@ -104,6 +114,7 @@
104114
time_start_o = dt.datetime.strptime(dtstring,"%Y-%m-%d %H:%M:%S")
105115
time_start = time_start_o - dt.timedelta(days=1) # add a day for safety
106116
ft.close()
117+
write_mode = 'a' # append to existing file
107118
except:
108119
print(ftpath+" not found or doesn't have valid dates. Skipping...")
109120
continue
@@ -156,7 +167,7 @@
156167
############################################################################
157168
# HEADER: Build a new header. Ginger wants as similar to .dat as possible.
158169
if(booWriteHeader == True):
159-
row1 = '"TOA5","'+station+'","DRI WRCC webscrape"\n'
170+
row1 = '"TOA5","'+station+'","DRI WRCC webscrape"'
160171
row2 = '"TIMESTAMP","RECORD"'
161172
row3 = '"TS","RN"'
162173
row4 = '"",""'

0 commit comments

Comments
 (0)