Commit be2ce0ef authored by Benjamin Schwenker's avatar Benjamin Schwenker
Browse files

fixed time ranges for downloading PVs

parent fb85306a
......@@ -69,14 +69,18 @@ def get_start_end(year, month):
last_day = calendar.monthrange(year, month)[1]
start = "{:d}-{:02d}-{:02d} 00:00:00".format(year, month, 1)
start = pytz.timezone(
'Asia/Tokyo').localize(datetime.datetime.strptime(start, "%Y-%m-%d %H:%M:%S"))
if now_jst.year == year and now_jst.month == month:
# Download current month
end = "{:d}-{:02d}-{:02d} {:02d}:{:02d}:00".format(year, month, now_jst.day, now_jst.hour, now_jst.minute)
end = pytz.timezone('Asia/Tokyo').localize(datetime.datetime.strptime(end, "%Y-%m-%d %H:%M:%S"))
else:
# Download historic month
end = "{:d}-{:02d}-{:02d} 23:59:59".format(year, month, last_day)
end = pytz.timezone('Asia/Tokyo').localize(datetime.datetime.strptime(end, "%Y-%m-%d %H:%M:%S"))
end = end + datetime.timedelta(seconds=1)
return start, end
......@@ -94,9 +98,6 @@ def download_archive(year, month, data_folder, connectVPN=None):
"""
logging.info('Starting download_archive ...')
# Get start and end time in JST, as strings
start, end = get_start_end(year, month)
data_folder = os.path.expandvars(data_folder)
superkekb_archiver = EpicsArchiver(
......@@ -105,11 +106,8 @@ def download_archive(year, month, data_folder, connectVPN=None):
server_prefix='/archappl_skekb'
)
# Specify a time interval (say a month). You will create daily summary data frames for this time interval
start = pytz.timezone(
'Asia/Tokyo').localize(datetime.datetime.strptime(start, "%Y-%m-%d %H:%M:%S"))
end = pytz.timezone(
'Asia/Tokyo').localize(datetime.datetime.strptime(end, "%Y-%m-%d %H:%M:%S"))
# Get start and end time in JST
start, end = get_start_end(year, month)
# Check that end is not on future
if end > indexer_utils.get_now_jst():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment