diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 0664a24b2..79af7faf2 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -37,7 +37,6 @@ import pwd import grp from collections import OrderedDict import datetime -import pytz from moulinette import msignals, m18n, msettings from moulinette.core import MoulinetteError @@ -83,9 +82,8 @@ def app_listlists(): appslist_list = _read_appslist_list() for app in appslist_list: - last_update = datetime.datetime.utcfromtimestamp( + appslist_list[app]["lastUpdate"] = datetime.datetime.utcfromtimestamp( appslist_list[app].get("lastUpdate")) - appslist_list[app]["lastUpdate"] = last_update.replace(tzinfo=pytz.utc) return appslist_list @@ -1762,7 +1760,7 @@ def _get_app_status(app_id, format_date=False): if not v: status[f] = '-' else: - status[f] = datetime.utcfromtimestamp(v).replace(tzinfo=pytz.utc) + status[f] = datetime.utcfromtimestamp(v) return status diff --git a/src/yunohost/backup.py b/src/yunohost/backup.py index 492687eaf..528b2e24f 100644 --- a/src/yunohost/backup.py +++ b/src/yunohost/backup.py @@ -33,7 +33,6 @@ import shutil import subprocess import csv import tempfile -import pytz from datetime import datetime from glob import glob from collections import OrderedDict @@ -301,7 +300,7 @@ class BackupManager(): (string) A backup name created from current date 'YYMMDD-HHMMSS' """ # FIXME: case where this name already exist - return time.strftime('%Y%m%d-%H%M%S') + return time.strftime('%Y%m%d-%H%M%S', time.gmtime()) def _init_work_dir(self): """Initialize preparation directory @@ -2268,8 +2267,7 @@ def backup_info(name, with_details=False, human_readable=False): result = { 'path': archive_file, - 'created_at': datetime.utcfromtimestamp(info['created_at']) - .replace(tzinfo=pytz.utc), + 'created_at': datetime.utcfromtimestamp(info['created_at']), 'description': info['description'], 'size': size, } diff --git a/src/yunohost/log.py b/src/yunohost/log.py index c75300d3d..af19090c8 100644 --- a/src/yunohost/log.py +++ b/src/yunohost/log.py @@ -101,7 +101,7 @@ def log_list(category=[], limit=None): except ValueError: pass else: - entry["started_at"] = log_datetime.replace(tzinfo=pytz.utc) + entry["started_at"] = log_datetime result[category].append(entry) @@ -321,8 +321,7 @@ class OperationLogger(object): """ if self.started_at is None: - self.started_at = datetime.utcnow() - self.started_at = self.started_at.replace(tzinfo=pytz.utc) + self.started_at = datetime.now(tz=pytz.utc) self.flush() self._register_log() @@ -414,8 +413,7 @@ class OperationLogger(object): return if error is not None and not isinstance(error, basestring): error = str(error) - self.ended_at = datetime.utcnow() - self.ended_at = self.ended_at.replace(tzinfo=pytz.utc) + self.ended_at = datetime.now(tz=pytz.utc) self._error = error self._success = error is None if self.logger is not None: diff --git a/src/yunohost/monitor.py b/src/yunohost/monitor.py index cad467ed5..fc10a4fbc 100644 --- a/src/yunohost/monitor.py +++ b/src/yunohost/monitor.py @@ -283,7 +283,7 @@ def monitor_system(units=None, human_readable=False): elif u == 'process': result[u] = json.loads(glances.getProcessCount()) elif u == 'uptime': - result[u] = (str(datetime.utcnow() - datetime.utcfromtimestamp(psutil.boot_time())).split('.')[0]) + result[u] = (str(datetime.now() - datetime.fromtimestamp(psutil.boot_time())).split('.')[0]) elif u == 'infos': result[u] = json.loads(glances.getSystem()) else: diff --git a/src/yunohost/service.py b/src/yunohost/service.py index 73383cb44..fd75d0235 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -31,7 +31,6 @@ import subprocess import errno import shutil import hashlib -import pytz from difflib import unified_diff from datetime import datetime @@ -276,7 +275,6 @@ def service_status(names=[]): } if "ActiveEnterTimestamp" in status: result[name]['active_at'] = datetime.utcfromtimestamp(status["ActiveEnterTimestamp"] / 1000000) - result[name]['active_at'] = result[name]['active_at'].replace(tzinfo=pytz.utc) else: result[name]['active_at'] = "unknown" @@ -926,7 +924,7 @@ def _process_regen_conf(system_conf, new_conf=None, save=True): """ if save: backup_path = os.path.join(BACKUP_CONF_DIR, '{0}-{1}'.format( - system_conf.lstrip('/'), time.strftime("%Y%m%d.%H%M%S"))) + system_conf.lstrip('/'), datetime.utcnow().strftime("%Y%m%d.%H%M%S"))) backup_dir = os.path.dirname(backup_path) if not os.path.isdir(backup_dir):