qvm-template: Fix date formats to "%Y-%m-%d %H:%M:%S"
This commit is contained in:
parent
f8032b0f5a
commit
89895038b5
@ -252,9 +252,8 @@ Options
|
|||||||
Where ``STATUS`` can be one of ``"installed"``, ``"available"``,
|
Where ``STATUS`` can be one of ``"installed"``, ``"available"``,
|
||||||
``"extra"``, or ``"upgradable"``.
|
``"extra"``, or ``"upgradable"``.
|
||||||
|
|
||||||
The fields ``buildtime`` and ``installtime`` are in ISO 8601 format.
|
The fields ``buildtime`` and ``installtime`` are in ``%Y-%m-%d
|
||||||
For example, one can parse them in Python with
|
%H:%M:%S`` format in UTC.
|
||||||
``datetime.fromisoformat()``.
|
|
||||||
|
|
||||||
The field ``{evr}`` contains version information in the form of
|
The field ``{evr}`` contains version information in the form of
|
||||||
``{epoch}:{version}-{release}``.
|
``{epoch}:{version}-{release}``.
|
||||||
@ -313,9 +312,8 @@ Options
|
|||||||
Where ``{status}`` can be one of ``installed``, ``available``,
|
Where ``{status}`` can be one of ``installed``, ``available``,
|
||||||
``extra``, or ``upgradable``.
|
``extra``, or ``upgradable``.
|
||||||
|
|
||||||
The fields ``{buildtime}`` and ``{installtime}`` are in ISO 8601 format.
|
The fields ``buildtime`` and ``installtime`` are in ``%Y-%m-%d
|
||||||
For example, one can parse them in Python with
|
%H:%M:%S`` format in UTC.
|
||||||
``datetime.fromisoformat()``.
|
|
||||||
|
|
||||||
Newlines in the ``{description}`` field are replaced with pipe
|
Newlines in the ``{description}`` field are replaced with pipe
|
||||||
characters (``|``) for easier processing.
|
characters (``|``) for easier processing.
|
||||||
@ -353,9 +351,8 @@ Options
|
|||||||
Where ``STATUS`` can be one of ``"installed"``, ``"available"``,
|
Where ``STATUS`` can be one of ``"installed"``, ``"available"``,
|
||||||
``"extra"``, or ``"upgradable"``.
|
``"extra"``, or ``"upgradable"``.
|
||||||
|
|
||||||
The fields ``buildtime`` and ``installtime`` are in ISO 8601 format.
|
The fields ``buildtime`` and ``installtime`` are in ``%Y-%m-%d
|
||||||
For example, one can parse them in Python using
|
%H:%M:%S`` format in UTC.
|
||||||
`datetime.fromisoformat()`.
|
|
||||||
|
|
||||||
search
|
search
|
||||||
------
|
------
|
||||||
|
@ -149,8 +149,8 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase):
|
|||||||
mock_rename,
|
mock_rename,
|
||||||
mock_remove):
|
mock_remove):
|
||||||
self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = b'0\0'
|
self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = b'0\0'
|
||||||
build_time = '2020-09-01 14:30:00+00:00' # 1598970600
|
build_time = '2020-09-01 14:30:00' # 1598970600
|
||||||
install_time = '2020-09-01 15:30:00.508230+00:00'
|
install_time = '2020-09-01 15:30:00'
|
||||||
for key, val in [
|
for key, val in [
|
||||||
('name', 'test-vm'),
|
('name', 'test-vm'),
|
||||||
('epoch', '2'),
|
('epoch', '2'),
|
||||||
@ -280,8 +280,8 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase):
|
|||||||
mock_rename,
|
mock_rename,
|
||||||
mock_remove):
|
mock_remove):
|
||||||
self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = b'0\0'
|
self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = b'0\0'
|
||||||
build_time = '2020-09-01 14:30:00+00:00' # 1598970600
|
build_time = '2020-09-01 14:30:00' # 1598970600
|
||||||
install_time = '2020-09-01 15:30:00.508230+00:00'
|
install_time = '2020-09-01 15:30:00'
|
||||||
for key, val in [
|
for key, val in [
|
||||||
('name', 'test-vm'),
|
('name', 'test-vm'),
|
||||||
('epoch', '2'),
|
('epoch', '2'),
|
||||||
|
@ -35,6 +35,7 @@ PACKAGE_NAME_PREFIX = 'qubes-template-'
|
|||||||
CACHE_DIR = os.path.join(xdg.BaseDirectory.xdg_cache_home, 'qvm-template')
|
CACHE_DIR = os.path.join(xdg.BaseDirectory.xdg_cache_home, 'qvm-template')
|
||||||
UNVERIFIED_SUFFIX = '.unverified'
|
UNVERIFIED_SUFFIX = '.unverified'
|
||||||
LOCK_FILE = '/var/tmp/qvm-template.lck'
|
LOCK_FILE = '/var/tmp/qvm-template.lck'
|
||||||
|
DATE_FMT = '%Y-%m-%d %H:%M:%S'
|
||||||
|
|
||||||
def qubes_release() -> str:
|
def qubes_release() -> str:
|
||||||
"""Return the Qubes release."""
|
"""Return the Qubes release."""
|
||||||
@ -287,7 +288,7 @@ def query_local(vm: qubesadmin.vm.QubesVM) -> Template:
|
|||||||
vm.features['template-release'],
|
vm.features['template-release'],
|
||||||
vm.features['template-reponame'],
|
vm.features['template-reponame'],
|
||||||
vm.get_disk_utilization(),
|
vm.get_disk_utilization(),
|
||||||
datetime.datetime.fromisoformat(vm.features['template-buildtime']),
|
datetime.datetime.strptime(vm.features['template-buildtime'], DATE_FMT),
|
||||||
vm.features['template-license'],
|
vm.features['template-license'],
|
||||||
vm.features['template-url'],
|
vm.features['template-url'],
|
||||||
vm.features['template-summary'],
|
vm.features['template-summary'],
|
||||||
@ -922,11 +923,13 @@ def install(
|
|||||||
package_hdr[rpm.RPMTAG_RELEASE]
|
package_hdr[rpm.RPMTAG_RELEASE]
|
||||||
tpl.features['template-reponame'] = reponame
|
tpl.features['template-reponame'] = reponame
|
||||||
tpl.features['template-buildtime'] = \
|
tpl.features['template-buildtime'] = \
|
||||||
str(datetime.datetime.fromtimestamp(
|
datetime.datetime.fromtimestamp(
|
||||||
int(package_hdr[rpm.RPMTAG_BUILDTIME]),
|
int(package_hdr[rpm.RPMTAG_BUILDTIME]),
|
||||||
tz=datetime.timezone.utc))
|
tz=datetime.timezone.utc) \
|
||||||
|
.strftime(DATE_FMT)
|
||||||
tpl.features['template-installtime'] = \
|
tpl.features['template-installtime'] = \
|
||||||
str(datetime.datetime.today(tz=datetime.timezone.utc))
|
datetime.datetime.today(
|
||||||
|
tz=datetime.timezone.utc).strftime(DATE_FMT)
|
||||||
tpl.features['template-license'] = \
|
tpl.features['template-license'] = \
|
||||||
package_hdr[rpm.RPMTAG_LICENSE]
|
package_hdr[rpm.RPMTAG_LICENSE]
|
||||||
tpl.features['template-url'] = \
|
tpl.features['template-url'] = \
|
||||||
@ -1011,8 +1014,8 @@ def list_templates(args: argparse.Namespace,
|
|||||||
name, epoch, version, release, reponame, dlsize, \
|
name, epoch, version, release, reponame, dlsize, \
|
||||||
buildtime, licence, url, summary, description = data
|
buildtime, licence, url, summary, description = data
|
||||||
dlsize = str(dlsize)
|
dlsize = str(dlsize)
|
||||||
buildtime = str(buildtime)
|
buildtime = buildtime.strftime(DATE_FMT)
|
||||||
install_time = str(install_time) if install_time else ''
|
install_time = install_time.strftime(DATE_FMT) if install_time else ''
|
||||||
if replace_newline:
|
if replace_newline:
|
||||||
description = description.replace('\n', '|')
|
description = description.replace('\n', '|')
|
||||||
output.append({
|
output.append({
|
||||||
|
Loading…
Reference in New Issue
Block a user