Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Listing user tokens causes traceback when running under Python 2. #6319

@niallmcandrew-work

Description

@niallmcandrew-work

CKAN version
2.9

Describe the bug
When running on Python 2, if one of the API tokens has been used then calling ckan user token list [USERNAME] results in a traceback (seen below). This is caused by differences in the isoformat option of datetime objects between Python 2 and Python 3.

Steps to reproduce
Steps to reproduce the behavior:

  1. Add an API token to a user.
  2. Use the token so that the lastAccess time is not None.
  3. Query the users tokens with ckan user token list [USERNAME]

Expected behavior
Should list the tokens and their last access time as follows:

Tokens([id] name - lastAccess):
        [Wf2-C4zSru-BDP5JGf7sUyYEkYgf_MPPmg_0xJW_GNs] test_api_token - 2021-08-10 21:00:26
        [ppjoo1wlS283tolPkwDzRCbPA72vuKs3MZc1xGoe7rQ] test_api_token - Never

Additional details

Traceback (most recent call last):
  File "/usr/local/bin/ckan", line 11, in <module>
    load_entry_point('ckan', 'console_scripts', 'ckan')()
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/ckan_repo_code/src/ckan-core/ckan/cli/user.py", line 233, in list_tokens
    ).isoformat(u" ", u"seconds")
TypeError: isoformat() takes at most 1 argument (2 given)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions