feat(backup): added debug logging to backup import
All checks were successful
Actions / Lint Code (Pylint) (push) Successful in 18s
Actions / Build Documentation (MkDocs) (push) Successful in 14s

This commit is contained in:
Seaswimmer 2024-02-01 15:01:32 -05:00
parent 960ec4c83a
commit 3398100a0f
Signed by: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -114,10 +114,12 @@ class Backup(commands.Cog):
try:
repository = await downloader._repo_manager.add_repo(url, name, branch) # pylint: disable=protected-access
repo_s.append(f"Added repository {name} from {url} on branch {branch}.")
self.logger.debug("Added repository %s from %s on branch %s", name, url, branch)
except errors.ExistingGitRepo:
repo_e.append(f"Repository {name} already exists.")
repository = downloader._repo_manager.get_repo(name) # pylint: disable=protected-access
self.logger.debug("Repository %s already exists", name)
# This is commented out because errors.AuthenticationError is not yet implemented in Red 3.5.5's Downloader cog.
# Rather, it is only in the development version and will be added in version 3.5.6 (or whatever the next version is).
@ -170,8 +172,10 @@ class Backup(commands.Cog):
await ctx.bot.remove_loaded_package(cog)
await downloader._delete_cog(poss_installed_path) # pylint: disable=protected-access
uninstall_s.append(f"Uninstalled {cog}")
self.logger.debug("Uninstalled %s", cog)
else:
uninstall_e.append(f"Failed to uninstall {cog}")
self.logger.warning("Failed to uninstall %s", cog)
await downloader._remove_from_installed(cog_modules) # pylint: disable=protected-access
for cog in cogs:
@ -190,10 +194,12 @@ class Backup(commands.Cog):
cogs_c, message = await downloader._filter_incorrect_cogs_by_names(repository, [cog_name]) # pylint: disable=protected-access
if not cogs_c:
install_e.append(message)
self.logger.error(message)
continue
failed_reqs = await downloader._install_requirements(cogs_c) # pylint: disable=protected-access
if failed_reqs:
install_e.append(f"Failed to install {cog_name} due to missing requirements: {failed_reqs}")
self.logger.error("Failed to install %s due to missing requirements: %s", cog_name, failed_reqs)
continue
installed_cogs, failed_cogs = await downloader._install_cogs(cogs_c) # pylint: disable=protected-access
@ -212,13 +218,17 @@ class Backup(commands.Cog):
if installed_cogs:
installed_cog_name = installed_cogs[0].name
install_s.append(f"Installed {installed_cog_name}")
self.logger.debug("Installed %s", installed_cog_name)
if installed_libs:
for lib in installed_libs:
install_s.append(f"Installed {lib.name} required for {cog_name}")
self.logger.debug("Installed %s required for %s", lib.name, cog_name)
if failed_cogs:
failed_cog_name = failed_cogs[0].name
install_e.append(f"Failed to install {failed_cog_name}")
self.logger.error("Failed to install %s", failed_cog_name)
if failed_libs:
for lib in failed_libs:
install_e.append(f"Failed to install {lib.name} required for {cog_name}")
self.logger.error("Failed to install %s required for %s", lib.name, cog_name)
await ctx.send("Import complete!", file=text_to_file(f"Repositories:\n{repo_s}\n\nRepository Errors:\n{repo_e}\n\nUninstalled Cogs:\n{uninstall_s}\n\nUninstalled Cogs Errors:\n{uninstall_e}\n\nInstalled Cogs:\n{install_s}\n\nInstalled Cogs Errors:\n{install_e}", 'backup.log'))