mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] kill all bare exceptions
This commit is contained in:
parent
5ac2355882
commit
97f26015c6
8 changed files with 23 additions and 23 deletions
|
@ -735,7 +735,7 @@ class BackupManager:
|
||||||
}
|
}
|
||||||
write_to_yaml("%s/permissions.yml" % settings_dir, this_app_permissions)
|
write_to_yaml("%s/permissions.yml" % settings_dir, this_app_permissions)
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
abs_tmp_app_dir = os.path.join(self.work_dir, "apps/", app)
|
abs_tmp_app_dir = os.path.join(self.work_dir, "apps/", app)
|
||||||
shutil.rmtree(abs_tmp_app_dir, ignore_errors=True)
|
shutil.rmtree(abs_tmp_app_dir, ignore_errors=True)
|
||||||
logger.error(m18n.n("backup_app_failed", app=app))
|
logger.error(m18n.n("backup_app_failed", app=app))
|
||||||
|
@ -1507,7 +1507,7 @@ class RestoreManager:
|
||||||
raise_on_error=True,
|
raise_on_error=True,
|
||||||
env=env_dict,
|
env=env_dict,
|
||||||
)[0]
|
)[0]
|
||||||
except:
|
except Exception:
|
||||||
msg = m18n.n("restore_app_failed", app=app_instance_name)
|
msg = m18n.n("restore_app_failed", app=app_instance_name)
|
||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
operation_logger.error(msg)
|
operation_logger.error(msg)
|
||||||
|
@ -1944,7 +1944,7 @@ class TarBackupMethod(BackupMethod):
|
||||||
self._archive_file,
|
self._archive_file,
|
||||||
"w:gz" if self._archive_file.endswith(".gz") else "w",
|
"w:gz" if self._archive_file.endswith(".gz") else "w",
|
||||||
)
|
)
|
||||||
except:
|
except Exception:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"unable to open '%s' for writing", self._archive_file, exc_info=1
|
"unable to open '%s' for writing", self._archive_file, exc_info=1
|
||||||
)
|
)
|
||||||
|
@ -1995,7 +1995,7 @@ class TarBackupMethod(BackupMethod):
|
||||||
self._archive_file,
|
self._archive_file,
|
||||||
"r:gz" if self._archive_file.endswith(".gz") else "r",
|
"r:gz" if self._archive_file.endswith(".gz") else "r",
|
||||||
)
|
)
|
||||||
except:
|
except Exception:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"cannot open backup archive '%s'", self._archive_file, exc_info=1
|
"cannot open backup archive '%s'", self._archive_file, exc_info=1
|
||||||
)
|
)
|
||||||
|
@ -2466,7 +2466,7 @@ def backup_info(name, with_details=False, human_readable=False):
|
||||||
with open(info_file) as f:
|
with open(info_file) as f:
|
||||||
# Retrieve backup info
|
# Retrieve backup info
|
||||||
info = json.load(f)
|
info = json.load(f)
|
||||||
except:
|
except Exception:
|
||||||
logger.debug("unable to load '%s'", info_file, exc_info=1)
|
logger.debug("unable to load '%s'", info_file, exc_info=1)
|
||||||
raise YunohostError(
|
raise YunohostError(
|
||||||
"backup_archive_cant_retrieve_info_json", archive=archive_file
|
"backup_archive_cant_retrieve_info_json", archive=archive_file
|
||||||
|
@ -2552,7 +2552,7 @@ def backup_delete(name):
|
||||||
for backup_file in files_to_delete:
|
for backup_file in files_to_delete:
|
||||||
try:
|
try:
|
||||||
os.remove(backup_file)
|
os.remove(backup_file)
|
||||||
except:
|
except Exception:
|
||||||
logger.debug("unable to delete '%s'", backup_file, exc_info=1)
|
logger.debug("unable to delete '%s'", backup_file, exc_info=1)
|
||||||
logger.warning(m18n.n("backup_delete_error", path=backup_file))
|
logger.warning(m18n.n("backup_delete_error", path=backup_file))
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ def certificate_status(domain_list, full=False):
|
||||||
try:
|
try:
|
||||||
_check_domain_is_ready_for_ACME(domain)
|
_check_domain_is_ready_for_ACME(domain)
|
||||||
status["ACME_eligible"] = True
|
status["ACME_eligible"] = True
|
||||||
except:
|
except Exception:
|
||||||
status["ACME_eligible"] = False
|
status["ACME_eligible"] = False
|
||||||
|
|
||||||
del status["domain"]
|
del status["domain"]
|
||||||
|
|
|
@ -182,7 +182,7 @@ def dyndns_subscribe(
|
||||||
os.system("rm -f %s" % key_file)
|
os.system("rm -f %s" % key_file)
|
||||||
try:
|
try:
|
||||||
error = json.loads(r.text)["error"]
|
error = json.loads(r.text)["error"]
|
||||||
except:
|
except Exception:
|
||||||
error = 'Server error, code: %s. (Message: "%s")' % (r.status_code, r.text)
|
error = 'Server error, code: %s. (Message: "%s")' % (r.status_code, r.text)
|
||||||
raise YunohostError("dyndns_registration_failed", error=error)
|
raise YunohostError("dyndns_registration_failed", error=error)
|
||||||
|
|
||||||
|
|
|
@ -335,7 +335,7 @@ def firewall_upnp(action="status", no_refresh=False):
|
||||||
try:
|
try:
|
||||||
# Remove old cron job
|
# Remove old cron job
|
||||||
os.remove("/etc/cron.d/yunohost-firewall")
|
os.remove("/etc/cron.d/yunohost-firewall")
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
action = "status"
|
action = "status"
|
||||||
no_refresh = False
|
no_refresh = False
|
||||||
|
@ -360,7 +360,7 @@ def firewall_upnp(action="status", no_refresh=False):
|
||||||
try:
|
try:
|
||||||
# Remove cron job
|
# Remove cron job
|
||||||
os.remove(UPNP_CRON_JOB)
|
os.remove(UPNP_CRON_JOB)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
enabled = False
|
enabled = False
|
||||||
if action == "status":
|
if action == "status":
|
||||||
|
@ -384,7 +384,7 @@ def firewall_upnp(action="status", no_refresh=False):
|
||||||
try:
|
try:
|
||||||
# Select UPnP device
|
# Select UPnP device
|
||||||
upnpc.selectigd()
|
upnpc.selectigd()
|
||||||
except:
|
except Exception:
|
||||||
logger.debug("unable to select UPnP device", exc_info=1)
|
logger.debug("unable to select UPnP device", exc_info=1)
|
||||||
enabled = False
|
enabled = False
|
||||||
else:
|
else:
|
||||||
|
@ -396,7 +396,7 @@ def firewall_upnp(action="status", no_refresh=False):
|
||||||
if upnpc.getspecificportmapping(port, protocol):
|
if upnpc.getspecificportmapping(port, protocol):
|
||||||
try:
|
try:
|
||||||
upnpc.deleteportmapping(port, protocol)
|
upnpc.deleteportmapping(port, protocol)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
firewall["uPnP"][protocol + "_TO_CLOSE"] = []
|
firewall["uPnP"][protocol + "_TO_CLOSE"] = []
|
||||||
|
|
||||||
|
@ -405,7 +405,7 @@ def firewall_upnp(action="status", no_refresh=False):
|
||||||
if upnpc.getspecificportmapping(port, protocol):
|
if upnpc.getspecificportmapping(port, protocol):
|
||||||
try:
|
try:
|
||||||
upnpc.deleteportmapping(port, protocol)
|
upnpc.deleteportmapping(port, protocol)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if not enabled:
|
if not enabled:
|
||||||
continue
|
continue
|
||||||
|
@ -419,7 +419,7 @@ def firewall_upnp(action="status", no_refresh=False):
|
||||||
"yunohost firewall: port %d" % port,
|
"yunohost firewall: port %d" % port,
|
||||||
"",
|
"",
|
||||||
)
|
)
|
||||||
except:
|
except Exception:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"unable to add port %d using UPnP", port, exc_info=1
|
"unable to add port %d using UPnP", port, exc_info=1
|
||||||
)
|
)
|
||||||
|
@ -488,7 +488,7 @@ def _get_ssh_port(default=22):
|
||||||
m = searchf(r"^Port[ \t]+([0-9]+)$", "/etc/ssh/sshd_config", count=-1)
|
m = searchf(r"^Port[ \t]+([0-9]+)$", "/etc/ssh/sshd_config", count=-1)
|
||||||
if m:
|
if m:
|
||||||
return int(m)
|
return int(m)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
|
@ -445,7 +445,7 @@ def _get_regenconf_infos():
|
||||||
try:
|
try:
|
||||||
with open(REGEN_CONF_FILE, "r") as f:
|
with open(REGEN_CONF_FILE, "r") as f:
|
||||||
return yaml.load(f)
|
return yaml.load(f)
|
||||||
except:
|
except Exception:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -498,7 +498,7 @@ def _get_files_diff(orig_file, new_file, as_string=False, skip_header=True):
|
||||||
try:
|
try:
|
||||||
next(diff)
|
next(diff)
|
||||||
next(diff)
|
next(diff)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if as_string:
|
if as_string:
|
||||||
|
@ -683,7 +683,7 @@ def _process_regen_conf(system_conf, new_conf=None, save=True):
|
||||||
# Raise an exception if an os.stat() call on either pathname fails.
|
# Raise an exception if an os.stat() call on either pathname fails.
|
||||||
# (os.stats returns a series of information from a file like type, size...)
|
# (os.stats returns a series of information from a file like type, size...)
|
||||||
copy_succeed = os.path.samefile(system_conf, new_conf)
|
copy_succeed = os.path.samefile(system_conf, new_conf)
|
||||||
except:
|
except Exception:
|
||||||
copy_succeed = False
|
copy_succeed = False
|
||||||
finally:
|
finally:
|
||||||
if not copy_succeed:
|
if not copy_succeed:
|
||||||
|
|
|
@ -673,7 +673,7 @@ def _get_services():
|
||||||
try:
|
try:
|
||||||
with open("/etc/yunohost/services.yml", "r") as f:
|
with open("/etc/yunohost/services.yml", "r") as f:
|
||||||
services = yaml.load(f) or {}
|
services = yaml.load(f) or {}
|
||||||
except:
|
except Exception:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
# some services are marked as None to remove them from YunoHost
|
# some services are marked as None to remove them from YunoHost
|
||||||
|
@ -807,7 +807,7 @@ def _get_journalctl_logs(service, number="all"):
|
||||||
systemd_service, number
|
systemd_service, number
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except:
|
except Exception:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -157,7 +157,7 @@ def settings_set(key, value):
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
try:
|
try:
|
||||||
value = int(value)
|
value = int(value)
|
||||||
except:
|
except Exception:
|
||||||
raise YunohostError(
|
raise YunohostError(
|
||||||
"global_settings_bad_type_for_setting",
|
"global_settings_bad_type_for_setting",
|
||||||
setting=key,
|
setting=key,
|
||||||
|
|
|
@ -171,7 +171,7 @@ def tools_adminpw(new_password, check_strength=True):
|
||||||
"userPassword": [new_hash],
|
"userPassword": [new_hash],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
except:
|
except Exception:
|
||||||
logger.error("unable to change admin password")
|
logger.error("unable to change admin password")
|
||||||
raise YunohostError("admin_password_change_failed")
|
raise YunohostError("admin_password_change_failed")
|
||||||
else:
|
else:
|
||||||
|
@ -315,7 +315,7 @@ def tools_postinstall(
|
||||||
# If an exception is thrown, most likely we don't have internet
|
# If an exception is thrown, most likely we don't have internet
|
||||||
# connectivity or something. Assume that this domain isn't manageable
|
# connectivity or something. Assume that this domain isn't manageable
|
||||||
# and inform the user that we could not contact the dyndns host server.
|
# and inform the user that we could not contact the dyndns host server.
|
||||||
except:
|
except Exception:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
m18n.n("dyndns_provider_unreachable", provider=dyndns_provider)
|
m18n.n("dyndns_provider_unreachable", provider=dyndns_provider)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue