How do I in python to end the code, does it go to the start again and repeat once every 3600 seconds?
My code: *
fb = Facebook ( "meu-token" )
fb.testing = False
try:
start_time = time.time()
markov.collecttext("./markov")
#markov.collectjsons ("./markov")
#markov.loadjson("data.json")
#markov.savejson()
train_time = time.time() - start_time
start_time = time.time()
generated = markov.generate (1)
generation_time = time.time() - start_time
if getpyversion() == 2:
generated = generated.encode('utf8')
image = randomimg("./images", generated)
log("Chosen image: " + str(image))
if not image:
image = randomimg("./images")
log("No tags found, randomly chosen image: " + str(image))
message_start = "Este post foi gerado pelo Marcos Bot\n----------\n"
else:
log("tags: " + ", ".join(gettags(generated, image)))
message_start = "The image was chosen because of the following tag(s): " + ", ".join(gettags(generated, image)) + "\n----------\n"
response = fb.publish_image ( censor(generated), image )
log(response)
except Exception as e:
log("Failed to generate sentence. Posting a random image instead.")
log(traceback.format_exc(e))
message = "Failed to generate sent(i)ence. Posting a random image instead:"
image = randomimg("./images")
log("Chosen image: " + str(image))
if not image:
response = fb.publish_text ( message )
else:
response = fb.publish_image ( message, image )
log(response)
main () *