From b4036b80921ea2dd0e20e410af7b9930049e7498 Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Fri, 24 Aug 2018 21:19:49 +0200 Subject: [PATCH] Debug daily file rotation --- circuitpython/code/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/circuitpython/code/main.py b/circuitpython/code/main.py index 71181b7..6a3932f 100644 --- a/circuitpython/code/main.py +++ b/circuitpython/code/main.py @@ -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