From 95452857251e5ec7c6e2d32301a6d54d533cf6ab Mon Sep 17 00:00:00 2001 From: root Date: Sun, 16 Apr 2023 16:55:10 +0200 Subject: [PATCH] Add commandline option to run with different settingsfiles --- main.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index e4d783c..e8c9fbc 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -import argparse, time +import argparse, time, importlib import feedparser import f_run_once, f_sigint from settings import * @@ -91,11 +91,33 @@ def main(): f.close() def startup(): parser = argparse.ArgumentParser(description = "Mastodon robot posting RSS-Feeds") + parser.add_argument('--settingsfile', dest='settingsfile', action='store', help='load another feedslist') parser.add_argument('--daemon', dest='daemon', action='store_true', help='run in daemon mode and repeat after a delay') parser.add_argument('--delay', dest='daemon_delay', action='store', type=int, help='number of seconds to wait for next run default=3600') args = parser.parse_args() f_run_once.run_once() run_as_daemon = False + if args.settingsfile: + global feeds + global log_path + global data_path + global app_path + global user_path + global bot_name + global account_name + global account_password + feedslist = importlib.import_module(args.settingsfile) + feeds = feedslist.feeds + log_path = feedslist.log_path + data_path = feedslist.data_path + app_path = feedslist.app_path + user_path = feedslist.user_path + api_url = feedslist.api_url + bot_name = feedslist.bot_name + account_name = feedslist.account_name + account_password = feedslist.account_password + # for j, url in enumerate(feeds): + # print(url) if args.daemon or args.daemon_delay: run_as_daemon = True if run_as_daemon: