From 9b1a45d3cc3ebd2b6a09fed4a4cf8f2446a0af7f Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 31 Oct 2019 19:38:30 +0100 Subject: [PATCH] Dont require mastodon library when --debug is set --- templates/main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/templates/main.py b/templates/main.py index 2519a0d..c12c8b4 100644 --- a/templates/main.py +++ b/templates/main.py @@ -1,22 +1,23 @@ #!/usr/bin/python3 import os -from mastodon import Mastodon import csv import itertools import random import os import argparse -instance = os.environ['MASTODON_INSTANCE'] -username = os.environ['MASTODON_USERNAME'] - parser = argparse.ArgumentParser(description='Parse quotes from .csv files, and post a random quote to Mastodon API') parser.add_argument('--debug', action='store_true', help='Dont actually login or post to the remote API') args = parser.parse_args() mastodon_api = None if not args.debug: + from mastodon import Mastodon + + instance = os.environ['MASTODON_INSTANCE'] + username = os.environ['MASTODON_USERNAME'] + # Create application if it does not exist # TODO: store this file in volume if not os.path.isfile(instance+'.secret'):