Refactored the way modules are dynamically imported

This commit is contained in:
Anon 2022-10-09 22:15:09 -07:00
parent 2dd89995e1
commit 8ce1c4bbaa

View File

@ -135,8 +135,8 @@ class YandereBot:
def download_media(self, picked_profile):
try:
backend_s = picked_profile["backend"]
backend = importlib.import_module(backend_s)
backend_credentials = self.settings_backend[backend_s]
backend = importlib.import_module(backend_credentials["module"])
img = None
downloader = backend.downloader(backend_credentials)
@ -292,7 +292,7 @@ class YandereBot:
# 2. The server is down. Check to verify in a web browser (this is the default assumption since the
# mastodon.py API will not specify why the connection timed out).
# The default assumption is #2
except (FileNotFoundError, MastodonAPIError, Exception) as e:
except (FileNotFoundError, MastodonAPIError) as e:
print("Exception:", e)
# An exception occurred