method call json default option set up to str
Fixed: https://pagure.io/koji/issue/3065
This commit is contained in:
parent
cd7f3eb551
commit
74112e804f
2 changed files with 11 additions and 1 deletions
|
|
@ -24,6 +24,7 @@ import koji
|
|||
from koji.util import base64encode, md5_constructor, to_list
|
||||
from koji_cli.lib import (
|
||||
TimeOption,
|
||||
DatetimeJSONEncoder,
|
||||
_,
|
||||
_list_tasks,
|
||||
_progress_callback,
|
||||
|
|
@ -1045,7 +1046,7 @@ def handle_call(goptions, session, args):
|
|||
non_kw.append(arg_filter(arg))
|
||||
response = getattr(session, name).__call__(*non_kw, **kw)
|
||||
if options.json_output:
|
||||
print(json.dumps(response, indent=2, separators=(',', ': ')))
|
||||
print(json.dumps(response, indent=2, separators=(',', ': '), cls=DatetimeJSONEncoder))
|
||||
else:
|
||||
pprint.pprint(response)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import socket
|
|||
import string
|
||||
import sys
|
||||
import time
|
||||
import json
|
||||
from contextlib import closing
|
||||
from copy import copy
|
||||
|
||||
|
|
@ -21,6 +22,7 @@ import koji
|
|||
# import parse_arches to current namespace for backward compatibility
|
||||
from koji import parse_arches
|
||||
from koji.util import md5_constructor, to_list
|
||||
from koji.xmlrpcplus import xmlrpc_client
|
||||
|
||||
|
||||
# for compatibility with plugins based on older version of lib
|
||||
|
|
@ -848,3 +850,10 @@ def truncate_string(s, length=47):
|
|||
return s
|
||||
else:
|
||||
return ''
|
||||
|
||||
|
||||
class DatetimeJSONEncoder(json.JSONEncoder):
|
||||
def default(self, o):
|
||||
if isinstance(o, xmlrpc_client.DateTime):
|
||||
return str(o)
|
||||
return json.JSONEncoder.default(self, o)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue