From 47a9132d309dd58cab826501c10a9e1e28436234 Mon Sep 17 00:00:00 2001 From: bernd2k <36308246+bernd2k@users.noreply.github.com> Date: Wed, 14 Feb 2018 18:59:47 +0000 Subject: [PATCH] fixes: datetime brackets are correct now. logging missed a STR(), loggint itself got dir_path fixes: datetime brackets are correct now. logging missed a STR(), loggint itself got dir_path --- main.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 15c388e..6fdfc11 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,7 @@ def textselect(min, max): return random.randint(min, max) def log(out): - f = open("log.csv", "a") + f = open(dir_path + os.sep + "log.csv", "a") f.write(out) f.close() @@ -88,12 +88,15 @@ while True: number = len(data_status["closing_text"]) number = textselect(0, number - 1) - text = data_status["closing_text"][number]["text"] + text = data_status["closing_text"][number]["text"] + " " + datetime.datetime.fromtimestamp( + int( time_now + 3600 )).strftime('%Y-%m-%d %H:%M:%S') + + print("Text:", text) print("Text:", text) api.update_status(text) # same text as before cannot be posted! - log(str(time_now) + ";" + data_space["state"]["lastchange"] + ";" + str(data_space["state"]["open"]) + log(str(time_now) + ";" + str(data_space["state"]["lastchange"]) + ";" + str(data_space["state"]["open"]) + ";" + str(number) + "\n") else: @@ -103,11 +106,13 @@ while True: number = len(data_status["opening_text"]) number = textselect(0, number - 1) - text = data_status["opening_text"][number]["text"] + text = data_status["opening_text"][number]["text"] + " " + datetime.datetime.fromtimestamp( + int( time_now + 3600 )).strftime('%Y-%m-%d %H:%M:%S') + print("Text:", text) api.update_status(text) - log(str(time_now) + ";" + data_space["state"]["lastchange"] + ";" + str(data_space["state"]["open"]) + log(str(time_now) + ";" + str(data_space["state"]["lastchange"]) + ";" + str(data_space["state"]["open"]) + ";" + str(number) + "\n") @@ -127,4 +132,4 @@ while True: print(time.time(), "internet is off") # how often shall we check for status? - time.sleep(data_config["status_api"]["checking_period"]) \ No newline at end of file + time.sleep(data_config["status_api"]["checking_period"])