Debug daily file rotation
This commit is contained in:
parent
2efc31ab4d
commit
b4036b8092
@ -256,17 +256,17 @@ def rotate_files():
|
||||
#If the hour changed : copy current data.csv to hourly directory
|
||||
if current_time[3] != last_time[3] and backup_data:
|
||||
print("Time to move hourly data !")
|
||||
os.rename("data/data.csv", "data/hourly/{}.csv".format(last_time[3]))
|
||||
os.rename("data/data.csv", "data/hourly/{:02}.csv".format(last_time[3]))
|
||||
|
||||
#If the day changed : copy content of hourly to daily directories
|
||||
if current_time[2] != last_time[2] and backup_data:
|
||||
print("Time to move daily data !")
|
||||
#Create new dir for the date of yesterday
|
||||
newdir = "data/daily/{}{}{}.csv".format(last_time[0:2])
|
||||
newdir = "data/daily/{}{:02}{:02}".format(*last_time[0:3])
|
||||
os.mkdir(newdir)
|
||||
#Move each "hourly file" to the new directory
|
||||
for file in os.listdir('data/hourly'):
|
||||
print("Move {} to {}".format(newdir, file))
|
||||
print("Move {} to {}".format(file, newdir))
|
||||
os.rename("data/hourly/{}".format(file), "{}/{}".format(newdir, file))
|
||||
|
||||
#Finally update last_time, each time
|
||||
|
Loading…
Reference in New Issue
Block a user