[enh] Display nice operation name

This commit is contained in:
ljf 2018-04-13 10:11:44 +02:00
parent 79ee0396d0
commit a9d937db21
2 changed files with 23 additions and 5 deletions

View file

@ -207,6 +207,24 @@
"iptables_unavailable": "You cannot play with iptables here. You are either in a container or your kernel does not support it", "iptables_unavailable": "You cannot play with iptables here. You are either in a container or your kernel does not support it",
"log_does_exists": "There is not operation log with the name '{log}', use 'yunohost log list to see all available operation logs'", "log_does_exists": "There is not operation log with the name '{log}', use 'yunohost log list to see all available operation logs'",
"log_operation_unit_unclosed_properly": "Operation unit has not been closed properly", "log_operation_unit_unclosed_properly": "Operation unit has not been closed properly",
"log_app_removelist": "Remove an application list",
"log_app_change_url": "Change the url of '{}' application",
"log_app_install": "Install '{}' application",
"log_app_remove": "Remove '{}' application",
"log_app_upgrade": "Upgrade '{}' application",
"log_app_makedefault": "Make '{}' as default application",
"log_domain_add": "Add '{}' domain into system configuration",
"log_domain_remove": "Remove '{}' domain from system configuration",
"log_dyndns_subscribe": "Subscribe to a YunoHost subdomain '{}'",
"log_dyndns_update": "Update the ip associated with your YunoHost subdomain '{}'",
"log_user_create": "Add '{}' user",
"log_user_delete": "Delete '{}' user",
"log_user_update": "Update information of '{}' user",
"log_tools_maindomain": "Make '{}' as main domain",
"log_tools_postinstall": "Postinstall your YunoHost server",
"log_tools_upgrade": "Upgrade debian packages",
"log_tools_shutdown": "Shutdown your server",
"log_tools_reboot": "Reboot your server",
"ldap_init_failed_to_create_admin": "LDAP initialization failed to create admin user", "ldap_init_failed_to_create_admin": "LDAP initialization failed to create admin user",
"ldap_initialized": "LDAP has been initialized", "ldap_initialized": "LDAP has been initialized",
"license_undefined": "undefined", "license_undefined": "undefined",

View file

@ -63,13 +63,13 @@ def log_list(limit=None):
file_name = operation file_name = operation
operation = operation[:-len(METADATA_FILE_EXT)] operation = operation[:-len(METADATA_FILE_EXT)]
operation = operation.split("_") operation = operation.split("-")
operation_datetime = datetime.strptime(" ".join(operation[:2]), "%Y-%m-%d %H-%M-%S") operation_datetime = datetime.strptime(" ".join(operation[:2]), "%Y%m%d %H%M%S")
result["categories"][-1]["operations"].append({ result["categories"][-1]["operations"].append({
"started_at": operation_datetime, "started_at": operation_datetime,
"name": " ".join(operation[-2:]), "name": m18n.n("log_" + operation[2], *operation[3:]),
"file_name": file_name, "file_name": file_name,
"path": os.path.join(OPERATIONS_PATH, category, file_name), "path": os.path.join(OPERATIONS_PATH, category, file_name),
}) })
@ -213,11 +213,11 @@ class UnitOperation(object):
@property @property
def name(self): def name(self):
name = [self.started_at.strftime("%F_%X").replace(":", "-")] name = [self.started_at.strftime("%Y%m%d-%H%M%S")]
name += [self.operation] name += [self.operation]
if self.on is not None: if self.on is not None:
name += self.on name += self.on
return '_'.join(name) return '-'.join(name)
@property @property
def metadata(self): def metadata(self):