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
This commit is contained in:
bernd2k 2018-02-14 18:59:47 +00:00 committed by GitHub
parent af904b12e1
commit 47a9132d30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

17
main.py
View file

@ -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"])
time.sleep(data_config["status_api"]["checking_period"])