Skip to content

Commit

Permalink
#41 check if it is too early to process
Browse files Browse the repository at this point in the history
  • Loading branch information
webgisdeveloper committed Nov 10, 2022
1 parent 565ccd6 commit d2d9391
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions HWRF_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ def check_status(adate):

return processed

def check_hours(adate):
""" check if it is too early to process"""
# adate in YYYYMMDDHH
TIME_DELDAY = 8 #hours
from datetime import datetime
ct = datetime.now()
da = datetime.strptime(adate,"%Y%m%d%H")
delta = ct - da
dhours = int(delta.total_seconds() / 3600)
if dhours > TIME_DELDAY:
return False
else:
return True

def generate_procesing_list():
""" generate the processing list"""

Expand Down Expand Up @@ -71,6 +85,9 @@ def generate_procesing_list():
a_entry = key + hhstr
if check_status(a_entry):
continue
# check if it is too early to process the data
if check_hours(a_entry):
continue
dataurllist[a_entry] = os.path.join(hosturl,fstr)

return dataurllist
Expand Down Expand Up @@ -260,8 +277,8 @@ def HWRF_cron():
# get date list
datelist = generate_procesing_list()
# for debug
#print(datelist)
#sys.exit()
print(datelist)
sys.exit()

if len(datelist) == 0:
logging.info("no new data to process!")
Expand Down

0 comments on commit d2d9391

Please sign in to comment.