exp is now exc
This commit is contained in:
parent
5e8506cc12
commit
1d88076285
@ -104,8 +104,8 @@ class PyroClient(PyroClient):
|
|||||||
logger.warning(
|
logger.warning(
|
||||||
"Could not send startup message to bot owner. Perhaps user has not started the bot yet."
|
"Could not send startup message to bot owner. Perhaps user has not started the bot yet."
|
||||||
)
|
)
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
logger.exception("Update check failed due to %s: %s", exp, format_exc())
|
logger.exception("Update check failed due to %s: %s", exc, format_exc())
|
||||||
|
|
||||||
if self.config["mode"]["post"]:
|
if self.config["mode"]["post"]:
|
||||||
if self.config["posting"]["use_interval"]:
|
if self.config["posting"]["use_interval"]:
|
||||||
@ -155,8 +155,8 @@ class PyroClient(PyroClient):
|
|||||||
filepath = await self.download_media(
|
filepath = await self.download_media(
|
||||||
submission, file_name=self.config["locations"]["tmp"] + sep
|
submission, file_name=self.config["locations"]["tmp"] + sep
|
||||||
)
|
)
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
raise SubmissionUnavailableError() from exp
|
raise SubmissionUnavailableError() from exc
|
||||||
|
|
||||||
elif not Path(
|
elif not Path(
|
||||||
f"{self.config['locations']['data']}/submissions/{db_entry['temp']['uuid']}/{db_entry['temp']['file']}",
|
f"{self.config['locations']['data']}/submissions/{db_entry['temp']['uuid']}/{db_entry['temp']['file']}",
|
||||||
@ -204,8 +204,8 @@ class PyroClient(PyroClient):
|
|||||||
# ),
|
# ),
|
||||||
# caption="queue",
|
# caption="queue",
|
||||||
# )
|
# )
|
||||||
except UnexpectedStatus as exp:
|
except UnexpectedStatus as exc:
|
||||||
raise SubmissionUnsupportedError(str(filepath)) from exp
|
raise SubmissionUnsupportedError(str(filepath)) from exc
|
||||||
|
|
||||||
response_dict = (
|
response_dict = (
|
||||||
{}
|
{}
|
||||||
|
@ -58,8 +58,8 @@ async def cli_create_user() -> None:
|
|||||||
none = input(
|
none = input(
|
||||||
"Alright. If you have email confirmation enabled - please confirm registration by using the link in your email. After that press Enter. Otherwise just press Enter."
|
"Alright. If you have email confirmation enabled - please confirm registration by using the link in your email. After that press Enter. Otherwise just press Enter."
|
||||||
)
|
)
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
print(f"Could not create a user due to {exp}", flush=True)
|
print(f"Could not create a user due to {exc}", flush=True)
|
||||||
print_exc()
|
print_exc()
|
||||||
exit()
|
exit()
|
||||||
if not args.create_album:
|
if not args.create_album:
|
||||||
@ -97,8 +97,8 @@ async def cli_create_album() -> None:
|
|||||||
result_2 = await album_create(client=client, name=name, title=title)
|
result_2 = await album_create(client=client, name=name, title=title)
|
||||||
# asyncio.run(create_album(name, title))
|
# asyncio.run(create_album(name, title))
|
||||||
await config_set("album", name, "posting", "api")
|
await config_set("album", name, "posting", "api")
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
print(f"Could not create an album due to {exp}", flush=True)
|
print(f"Could not create an album due to {exc}", flush=True)
|
||||||
print_exc()
|
print_exc()
|
||||||
exit()
|
exit()
|
||||||
print("You're done!", flush=True)
|
print("You're done!", flush=True)
|
||||||
|
@ -77,12 +77,12 @@ async def send_content(app: PyroClient, http_session: ClientSession) -> None:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
response: File = await func_iter[1](id=media.id, client=client)
|
response: File = await func_iter[1](id=media.id, client=client)
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
print_exc()
|
print_exc()
|
||||||
logger.error("Media is invalid: %s", exp)
|
logger.error("Media is invalid: %s", exc)
|
||||||
if app.config["reports"]["error"]:
|
if app.config["reports"]["error"]:
|
||||||
await app.send_message(
|
await app.send_message(
|
||||||
app.owner, f"Media is invalid: {exp}"
|
app.owner, f"Media is invalid: {exc}"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -103,11 +103,11 @@ async def send_content(app: PyroClient, http_session: ClientSession) -> None:
|
|||||||
).results[0]
|
).results[0]
|
||||||
try:
|
try:
|
||||||
response: File = await func[1](id=media.id, client=client)
|
response: File = await func[1](id=media.id, client=client)
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
print_exc()
|
print_exc()
|
||||||
logger.error("Media is invalid: %s", exp)
|
logger.error("Media is invalid: %s", exc)
|
||||||
if app.config["reports"]["error"]:
|
if app.config["reports"]["error"]:
|
||||||
await app.send_message(app.owner, f"Media is invalid: {exp}")
|
await app.send_message(app.owner, f"Media is invalid: {exc}")
|
||||||
return
|
return
|
||||||
|
|
||||||
except (KeyError, AttributeError, TypeError, IndexError):
|
except (KeyError, AttributeError, TypeError, IndexError):
|
||||||
@ -217,14 +217,14 @@ async def send_content(app: PyroClient, http_session: ClientSession) -> None:
|
|||||||
caption=caption,
|
caption=caption,
|
||||||
disable_notification=app.config["posting"]["silent"],
|
disable_notification=app.config["posting"]["silent"],
|
||||||
)
|
)
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
logger.error(
|
logger.error(
|
||||||
"Could not send media %s (%s) due to %s", media.filename, media.id, exp
|
"Could not send media %s (%s) due to %s", media.filename, media.id, exc
|
||||||
)
|
)
|
||||||
if app.config["reports"]["error"]:
|
if app.config["reports"]["error"]:
|
||||||
await app.send_message(
|
await app.send_message(
|
||||||
app.owner,
|
app.owner,
|
||||||
app._("post_exception", "message").format(exp, format_exc()),
|
app._("post_exception", "message").format(exc, format_exc()),
|
||||||
)
|
)
|
||||||
# rmtree(path.join(app.config['locations']['tmp'], tmp_dir), ignore_errors=True)
|
# rmtree(path.join(app.config['locations']['tmp'], tmp_dir), ignore_errors=True)
|
||||||
return
|
return
|
||||||
@ -253,14 +253,14 @@ async def send_content(app: PyroClient, http_session: ClientSession) -> None:
|
|||||||
str(app.config["posting"]["silent"]),
|
str(app.config["posting"]["silent"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
logger.error(
|
logger.error(
|
||||||
"Could not send content due to %s. Traceback: %s", exp, format_exc()
|
"Could not send content due to %s. Traceback: %s", exc, format_exc()
|
||||||
)
|
)
|
||||||
if app.config["reports"]["error"]:
|
if app.config["reports"]["error"]:
|
||||||
await app.send_message(
|
await app.send_message(
|
||||||
app.owner,
|
app.owner,
|
||||||
app._("post_exception", "message").format(exp, format_exc()),
|
app._("post_exception", "message").format(exc, format_exc()),
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
rmtree(
|
rmtree(
|
||||||
|
@ -43,21 +43,21 @@ async def callback_query_yes(app: PyroClient, clb: CallbackQuery):
|
|||||||
show_alert=True,
|
show_alert=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except SubmissionDuplicatesError as exp:
|
except SubmissionDuplicatesError as exc:
|
||||||
await clb.answer(
|
await clb.answer(
|
||||||
text=app._("sub_duplicates_found", "callback", locale=user.locale),
|
text=app._("sub_duplicates_found", "callback", locale=user.locale),
|
||||||
show_alert=True,
|
show_alert=True,
|
||||||
)
|
)
|
||||||
await clb.message.reply_text(
|
await clb.message.reply_text(
|
||||||
app._("sub_media_duplicates_list", "message", locale=user.locale).format(
|
app._("sub_media_duplicates_list", "message", locale=user.locale).format(
|
||||||
"\n • ".join(exp.duplicates)
|
"\n • ".join(exc.duplicates)
|
||||||
),
|
),
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
"Submission with ID '%s' could not be accepted because of the duplicates: %s",
|
"Submission with ID '%s' could not be accepted because of the duplicates: %s",
|
||||||
fullclb[2],
|
fullclb[2],
|
||||||
str(exp.duplicates),
|
str(exc.duplicates),
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ async def callback_query_no(app: PyroClient, clb: CallbackQuery):
|
|||||||
submission = await app.get_messages(
|
submission = await app.get_messages(
|
||||||
db_entry["user"], db_entry["telegram"]["msg_id"]
|
db_entry["user"], db_entry["telegram"]["msg_id"]
|
||||||
)
|
)
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
await clb.answer(
|
await clb.answer(
|
||||||
text=app._("sub_msg_unavail", "message", locale=user.locale),
|
text=app._("sub_msg_unavail", "message", locale=user.locale),
|
||||||
show_alert=True,
|
show_alert=True,
|
||||||
|
@ -123,16 +123,16 @@ async def cmd_import(app: PyroClient, msg: Message):
|
|||||||
for name in handle.namelist()
|
for name in handle.namelist()
|
||||||
]
|
]
|
||||||
_ = await asyncio.gather(*tasks)
|
_ = await asyncio.gather(*tasks)
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
logger.error(
|
logger.error(
|
||||||
"Could not import '%s' due to %s: %s",
|
"Could not import '%s' due to %s: %s",
|
||||||
answer.document.file_name,
|
answer.document.file_name,
|
||||||
exp,
|
exc,
|
||||||
format_exc(),
|
format_exc(),
|
||||||
)
|
)
|
||||||
await answer.reply_text(
|
await answer.reply_text(
|
||||||
app._("import_unpack_error", "message", locale=user.locale).format(
|
app._("import_unpack_error", "message", locale=user.locale).format(
|
||||||
exp, format_exc()
|
exc, format_exc()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -165,12 +165,12 @@ async def cmd_import(app: PyroClient, msg: Message):
|
|||||||
compress=False,
|
compress=False,
|
||||||
caption="queue",
|
caption="queue",
|
||||||
)
|
)
|
||||||
except UnexpectedStatus as exp:
|
except UnexpectedStatus as exc:
|
||||||
logger.error(
|
logger.error(
|
||||||
"Could not upload '%s' from '%s': %s",
|
"Could not upload '%s' from '%s': %s",
|
||||||
filename,
|
filename,
|
||||||
Path(f"{app.config['locations']['tmp']}/{tmp_dir}"),
|
Path(f"{app.config['locations']['tmp']}/{tmp_dir}"),
|
||||||
exp,
|
exc,
|
||||||
)
|
)
|
||||||
await msg.reply_text(
|
await msg.reply_text(
|
||||||
app._(
|
app._(
|
||||||
|
@ -237,16 +237,16 @@ async def get_submission(app: PyroClient, msg: Message):
|
|||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except SubmissionDuplicatesError as exp:
|
except SubmissionDuplicatesError as exc:
|
||||||
await msg.reply_text(
|
await msg.reply_text(
|
||||||
app._(
|
app._(
|
||||||
"sub_media_duplicates_list", "message", locale=user.locale
|
"sub_media_duplicates_list", "message", locale=user.locale
|
||||||
).format("\n • ".join(exp.duplicates)),
|
).format("\n • ".join(exc.duplicates)),
|
||||||
quote=True,
|
quote=True,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
await msg.reply_text(format_exc(), quote=True)
|
await msg.reply_text(exc, quote=True)
|
||||||
return
|
return
|
||||||
elif (
|
elif (
|
||||||
msg.from_user.id not in app.admins
|
msg.from_user.id not in app.admins
|
||||||
@ -270,12 +270,12 @@ async def get_submission(app: PyroClient, msg: Message):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except SubmissionDuplicatesError as exp:
|
except SubmissionDuplicatesError as exc:
|
||||||
await msg.reply_text(
|
await msg.reply_text(
|
||||||
app._("sub_dup", "message", locale=user.locale), quote=True
|
app._("sub_dup", "message", locale=user.locale), quote=True
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
except Exception as exp:
|
except Exception as exc:
|
||||||
await app.send_message(
|
await app.send_message(
|
||||||
app.owner,
|
app.owner,
|
||||||
app._(
|
app._(
|
||||||
|
Reference in New Issue
Block a user