#182 use dateutil to parse timestamp args in list-history
Merged 7 years ago by mikem. Opened 7 years ago by mikem.
https://github.com/mikem23/koji-playground.git query-hist-timestamp  into  master

use dateutil to parse timestamp args in list-history
Mike McLean • 7 years ago  
cli/koji
file modified
+17
@@ -42,6 +42,7 @@

          json = None

  import ConfigParser

  import base64

+ import dateutil.parser

  import errno

  import koji

  import koji.util
@@ -4213,6 +4214,22 @@

          assert False

      kwargs = {}

      limited = False

+     for opt in ('before', 'after'):

+         val = getattr(options, opt)

+         if not val:

+             continue

+         try:

+             ts = float(val)

+             setattr(options, opt, ts)

+             continue

+         except ValueError:

+             pass

+         try:

+             dt = dateutil.parser.parse(val)

+             ts = time.mktime(dt.timetuple())

+             setattr(options, opt, ts)

+         except:

+             parser.error(_("Invalid time specification: %s") % val)

      for opt in ('package', 'tag', 'build', 'editor', 'user', 'permission',

                  'cg', 'external_repo', 'build_target', 'group', 'before',

                  'after'):

koji.spec
file modified
+1
@@ -29,6 +29,7 @@

  Requires: rpm-python

  Requires: pyOpenSSL

  Requires: python-urlgrabber

+ Requires: python-dateutil

  BuildRequires: python

  %if %{use_systemd}

  BuildRequires: systemd

no initial comment

This is a fix for issue #181. Parsing the timestamp on the client side means we interpret it in the client's local time, which is surely what the user intended.

Adds a new requirement on python-dateutil, which appears to be broadly available.

Still, could use some more testing on older RHEL versions

Works for me on centos5/6/7.

rebased

7 years ago

Pull-Request has been merged by mikem

7 years ago
Metadata