From 1ec058027c4732dbdd6477c344d16ed8b8353ec3 Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 1 Nov 2018 15:27:03 +1000 Subject: [PATCH] only skip failing users, added windows compatibility --- gen.py | 37 +++++++++++++++++++------------------ main.py | 7 ++++--- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/gen.py b/gen.py index 4622b20..af6e8e3 100755 --- a/gen.py +++ b/gen.py @@ -23,21 +23,22 @@ client = Mastodon( access_token=cfg['secret'], api_base_url=cfg['site']) -toot = create.make_toot() -if not args.simulate: - try: - if toot['media'] != None: - mediaID = client.media_post(toot['media'], description = toot['toot']) - client.status_post(toot['toot'].replace("\n", " "), - media_ids = [mediaID], visibility = "unlisted") - else: - client.status_post(toot['toot'], visibility = 'unlisted') - except Exception as err: - toot = { - "toot": - "Mistress @lynnesbian@fedi.lynnesbian.space, something has gone terribly" \ - + " 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']) +if __name__ == '__main__': + toot = create.make_toot() + if not args.simulate: + try: + if toot['media'] != None: + mediaID = client.media_post(toot['media'], description = toot['toot']) + client.status_post(toot['toot'].replace("\n", " "), + media_ids = [mediaID], visibility = "unlisted") + else: + client.status_post(toot['toot'], visibility = 'unlisted') + except Exception as err: + toot = { + "toot": + "Mistress @lynnesbian@fedi.lynnesbian.space, something has gone terribly" \ + + " 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']) diff --git a/main.py b/main.py index 8bbfc48..4b53e37 100755 --- a/main.py +++ b/main.py @@ -214,10 +214,11 @@ for f in following: print(" Done!") db.commit() except: - print("Encountered an error! Saving toots to database and exiting.") + print("Encountered an error! Saving toots to database and continuing.") db.commit() - db.close() - sys.exit(1) + # db.close() + +print("Done!") db.commit() db.execute("VACUUM") #compact db