only skip failing users, added windows compatibility

This commit is contained in:
Lynne 2018-11-01 15:27:03 +10:00
parent 11e7a1ff88
commit 1ec058027c
2 changed files with 23 additions and 21 deletions

37
gen.py
View file

@ -23,21 +23,22 @@ client = Mastodon(
access_token=cfg['secret'], access_token=cfg['secret'],
api_base_url=cfg['site']) api_base_url=cfg['site'])
toot = create.make_toot() if __name__ == '__main__':
if not args.simulate: toot = create.make_toot()
try: if not args.simulate:
if toot['media'] != None: try:
mediaID = client.media_post(toot['media'], description = toot['toot']) if toot['media'] != None:
client.status_post(toot['toot'].replace("\n", " "), mediaID = client.media_post(toot['media'], description = toot['toot'])
media_ids = [mediaID], visibility = "unlisted") client.status_post(toot['toot'].replace("\n", " "),
else: media_ids = [mediaID], visibility = "unlisted")
client.status_post(toot['toot'], visibility = 'unlisted') else:
except Exception as err: client.status_post(toot['toot'], visibility = 'unlisted')
toot = { except Exception as err:
"toot": toot = {
"Mistress @lynnesbian@fedi.lynnesbian.space, something has gone terribly" \ "toot":
+ " wrong! While attempting to post a toot, I received the following" \ "Mistress @lynnesbian@fedi.lynnesbian.space, something has gone terribly" \
+ " error:\n" + "\n".join(traceback.format_tb(sys.exc_info()[2])) + " wrong! While attempting to post a toot, I received the following" \
} + " error:\n" + "\n".join(traceback.format_tb(sys.exc_info()[2]))
client.status_post(toot['toot'], visibility = 'unlisted', spoiler_text = "Error!") }
print(toot['toot']) client.status_post(toot['toot'], visibility = 'unlisted', spoiler_text = "Error!")
print(toot['toot'])

View file

@ -214,10 +214,11 @@ for f in following:
print(" Done!") print(" Done!")
db.commit() db.commit()
except: except:
print("Encountered an error! Saving toots to database and exiting.") print("Encountered an error! Saving toots to database and continuing.")
db.commit() db.commit()
db.close() # db.close()
sys.exit(1)
print("Done!")
db.commit() db.commit()
db.execute("VACUUM") #compact db db.execute("VACUUM") #compact db