Add commandline option to run with different settingsfiles

This commit is contained in:
root 2023-04-16 16:55:10 +02:00
parent 0bf1d379e8
commit 9545285725
1 changed files with 23 additions and 1 deletions

24
main.py
View File

@ -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: