Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 3 incompatibility: passing custom format #73

Open
spapanik opened this issue Apr 24, 2018 · 2 comments
Open

python 3 incompatibility: passing custom format #73

spapanik opened this issue Apr 24, 2018 · 2 comments

Comments

@spapanik
Copy link

passing custom format leads to an error in python3:

@ $ jira-cli view -6029 --format="%key"
Traceback (most recent call last):
File "
/venv/bin/jira-cli", line 11, in
sys.exit(cli())
File "/venv/lib/python3.6/site-packages/jiracli/interface.py", line 272, in cli
return post_args.cmd(jira, post_args).execute()
File "
/venv/lib/python3.6/site-packages/jiracli/processor.py", line 30, in execute
return self.eval()
File "/venv/lib/python3.6/site-packages/jiracli/processor.py", line 75, in eval
comments_only=self.args.comments_only
File "
/venv/lib/python3.6/site-packages/jiracli/bridge/init.py", line 68, in format_issue
ret_str = ret_str.replace(k, issue.setdefault(v.lower(),"")).encode('utf-8')
TypeError: a bytes-like object is required, not 'str'

@radoeka
Copy link

radoeka commented Oct 6, 2018

I encounter the same issue unfortunately.

When I make this change:

--- /var/tmp/__init__.py        2018-10-06 11:00:50.483476807 +0200
+++ ./__init__.py       2018-10-06 12:10:25.107991192 +0200
@@ -60,12 +60,12 @@
                 if v.lower() in special_fields.keys():
                     key=issue[v.lower()]
                     data = "" or JiraBridge.object_from_key(key, special_fields[v.lower()])["name"]
-                    ret_str = ret_str.replace(k, data)
+                    ret_str = ret_str.decode('unicode-escape').replace(k, data).encode('utf-8')
                 elif v.lower() in list_fields:
                     fix_versions = ", ".join(v.name for v in issue.get('fixVersions', []))
                     ret_str = ret_str.replace(k, fix_versions.encode('utf-8'))
                 else:
-                    ret_str = ret_str.replace(k, issue.setdefault(v.lower(),"")).encode('utf-8')
+                    ret_str = ret_str.decode('unicode-escape').replace(k, issue.setdefault(v.lower(),"")).encode('utf-8')
             return ret_str
         if mode >= 0:
             # minimal

Things start to move a bit. At least there is some output.

This works:
jira-cli view --search-jql='resolution = Unresolved ORDER BY key' --format='%key,%summary,%status,%priority,%assignee,%reporter,%created,%updated'

Although the output starts with: b'

Any python guru that can solve this???

When %labels is added to the format string, the output states;

  File "/usr/lib/python3.6/site-packages/jiracli/bridge/__init__.py", line 68, in format_issue
    ret_str = ret_str.decode('unicode-escape').replace(k, issue.setdefault(v.lower(),"")).encode('utf-8')
TypeError: replace() argument 2 must be str, not list

How to add, '%issue type' and '%prio-customer' to the format string?

With %prio-customer, the output will be:
..................,-customer

And with '%issue type', the output is similar:
.................., type

It would be very useful to have the --format argument working for python > 3.4!
And to be able to specify %labels, %prio-customer, %issue type and the like.
Or is it already possible to specify %prio-customer, %issue type, in a special way.

@kshtsk
Copy link

kshtsk commented Apr 24, 2020

Having similar issue:

> jira-cli view --search='bug' --format "issue id: %k [%priority]"
Traceback (most recent call last):
  File "/home/kyr/jira/v/bin/jira-cli", line 8, in <module>
    sys.exit(cli())
  File "/home/kyr/jira/v/lib/python3.6/site-packages/jiracli/interface.py", line 272, in cli
    return post_args.cmd(jira, post_args).execute()
  File "/home/kyr/jira/v/lib/python3.6/site-packages/jiracli/processor.py", line 30, in execute
    return self.eval()
  File "/home/kyr/jira/v/lib/python3.6/site-packages/jiracli/processor.py", line 75, in eval
    comments_only=self.args.comments_only
  File "/home/kyr/jira/v/lib/python3.6/site-packages/jiracli/bridge/__init__.py", line 68, in format_issue
    ret_str = ret_str.replace(k, issue.setdefault(v.lower(),"")).encode('utf-8')
TypeError: a bytes-like object is required, not 'str'
> jira-cli --version
2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants