mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Use UTC naive format and manage it in moulinette
This commit is contained in:
parent
e43bcf253c
commit
db1b00e706
5 changed files with 9 additions and 17 deletions
|
@ -37,7 +37,6 @@ import pwd
|
||||||
import grp
|
import grp
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import datetime
|
import datetime
|
||||||
import pytz
|
|
||||||
|
|
||||||
from moulinette import msignals, m18n, msettings
|
from moulinette import msignals, m18n, msettings
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
|
@ -83,9 +82,8 @@ def app_listlists():
|
||||||
appslist_list = _read_appslist_list()
|
appslist_list = _read_appslist_list()
|
||||||
|
|
||||||
for app in 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].get("lastUpdate"))
|
||||||
appslist_list[app]["lastUpdate"] = last_update.replace(tzinfo=pytz.utc)
|
|
||||||
|
|
||||||
return appslist_list
|
return appslist_list
|
||||||
|
|
||||||
|
@ -1762,7 +1760,7 @@ def _get_app_status(app_id, format_date=False):
|
||||||
if not v:
|
if not v:
|
||||||
status[f] = '-'
|
status[f] = '-'
|
||||||
else:
|
else:
|
||||||
status[f] = datetime.utcfromtimestamp(v).replace(tzinfo=pytz.utc)
|
status[f] = datetime.utcfromtimestamp(v)
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import csv
|
import csv
|
||||||
import tempfile
|
import tempfile
|
||||||
import pytz
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
@ -301,7 +300,7 @@ class BackupManager():
|
||||||
(string) A backup name created from current date 'YYMMDD-HHMMSS'
|
(string) A backup name created from current date 'YYMMDD-HHMMSS'
|
||||||
"""
|
"""
|
||||||
# FIXME: case where this name already exist
|
# 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):
|
def _init_work_dir(self):
|
||||||
"""Initialize preparation directory
|
"""Initialize preparation directory
|
||||||
|
@ -2268,8 +2267,7 @@ def backup_info(name, with_details=False, human_readable=False):
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
'path': archive_file,
|
'path': archive_file,
|
||||||
'created_at': datetime.utcfromtimestamp(info['created_at'])
|
'created_at': datetime.utcfromtimestamp(info['created_at']),
|
||||||
.replace(tzinfo=pytz.utc),
|
|
||||||
'description': info['description'],
|
'description': info['description'],
|
||||||
'size': size,
|
'size': size,
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ def log_list(category=[], limit=None):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
entry["started_at"] = log_datetime.replace(tzinfo=pytz.utc)
|
entry["started_at"] = log_datetime
|
||||||
|
|
||||||
result[category].append(entry)
|
result[category].append(entry)
|
||||||
|
|
||||||
|
@ -321,8 +321,7 @@ class OperationLogger(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.started_at is None:
|
if self.started_at is None:
|
||||||
self.started_at = datetime.utcnow()
|
self.started_at = datetime.now(tz=pytz.utc)
|
||||||
self.started_at = self.started_at.replace(tzinfo=pytz.utc)
|
|
||||||
self.flush()
|
self.flush()
|
||||||
self._register_log()
|
self._register_log()
|
||||||
|
|
||||||
|
@ -414,8 +413,7 @@ class OperationLogger(object):
|
||||||
return
|
return
|
||||||
if error is not None and not isinstance(error, basestring):
|
if error is not None and not isinstance(error, basestring):
|
||||||
error = str(error)
|
error = str(error)
|
||||||
self.ended_at = datetime.utcnow()
|
self.ended_at = datetime.now(tz=pytz.utc)
|
||||||
self.ended_at = self.ended_at.replace(tzinfo=pytz.utc)
|
|
||||||
self._error = error
|
self._error = error
|
||||||
self._success = error is None
|
self._success = error is None
|
||||||
if self.logger is not None:
|
if self.logger is not None:
|
||||||
|
|
|
@ -283,7 +283,7 @@ def monitor_system(units=None, human_readable=False):
|
||||||
elif u == 'process':
|
elif u == 'process':
|
||||||
result[u] = json.loads(glances.getProcessCount())
|
result[u] = json.loads(glances.getProcessCount())
|
||||||
elif u == 'uptime':
|
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':
|
elif u == 'infos':
|
||||||
result[u] = json.loads(glances.getSystem())
|
result[u] = json.loads(glances.getSystem())
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -31,7 +31,6 @@ import subprocess
|
||||||
import errno
|
import errno
|
||||||
import shutil
|
import shutil
|
||||||
import hashlib
|
import hashlib
|
||||||
import pytz
|
|
||||||
|
|
||||||
from difflib import unified_diff
|
from difflib import unified_diff
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -276,7 +275,6 @@ def service_status(names=[]):
|
||||||
}
|
}
|
||||||
if "ActiveEnterTimestamp" in status:
|
if "ActiveEnterTimestamp" in status:
|
||||||
result[name]['active_at'] = datetime.utcfromtimestamp(status["ActiveEnterTimestamp"] / 1000000)
|
result[name]['active_at'] = datetime.utcfromtimestamp(status["ActiveEnterTimestamp"] / 1000000)
|
||||||
result[name]['active_at'] = result[name]['active_at'].replace(tzinfo=pytz.utc)
|
|
||||||
else:
|
else:
|
||||||
result[name]['active_at'] = "unknown"
|
result[name]['active_at'] = "unknown"
|
||||||
|
|
||||||
|
@ -926,7 +924,7 @@ def _process_regen_conf(system_conf, new_conf=None, save=True):
|
||||||
"""
|
"""
|
||||||
if save:
|
if save:
|
||||||
backup_path = os.path.join(BACKUP_CONF_DIR, '{0}-{1}'.format(
|
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)
|
backup_dir = os.path.dirname(backup_path)
|
||||||
|
|
||||||
if not os.path.isdir(backup_dir):
|
if not os.path.isdir(backup_dir):
|
||||||
|
|
Loading…
Add table
Reference in a new issue