xbar-plugins
xbar-plugins copied to clipboard
001-notifications.30s.py: fix small bugs and add discussion
- Fix /issues/1780
- Fix
TypeError: a bytes-like object is required, not 'str'
- Add
Discussion
, not sure how to add the image 🙈 I wanted to use this one: https://primer.style/octicons/comment-discussion-16 - Add also
CheckSuite
, same problem here with the image. https://primer.style/octicons/play-16, not sure why butCheckSuite
don't havehref
so link is not working 😞
BTW I still have some issues, but not sure how to fix them. I think that for debugging would be better to show errors:
--- a/notifications.30s.py
+++ b/notifications.30s.py
@@ -61,8 +61,7 @@ def make_github_request(url, method="GET", data=None, enterprise=False):
return (
json.load(response) if int(response.headers.get("content-length", 0)) > 0 else {}
)
- except Exception:
- return None
+ except Exception as e: print("Error: %s" % e)
Running the script showing the errors I get this error: Error: unknown url type: 'None'
Also Opt+Click
functions is not working for me 😞
@elalemanyo what's happening with the option click?
@elalemanyo what's happening with the option click?
@matryer mark as read
is not working, notification still there 🤷 not sure what is going on
Can confirm this version fixes issues with the python3 "fixed" version that is the current download. But "mark as read" function is not working on option click.
Personally, I just reinstalled Python2 and continue to use my old version.
Can confirm this version fixes issues with the python3 "fixed" version that is the current download. But "mark as read" function is not working on option click.
Personally, I just reinstalled Python2 and continue to use my old version.
you are right, using the last python2 version works like a charm
The only thing the last Python 2 version does not cope with are Discussion notifications.
Yes Discussion
and CheckSuite
😞 Not sure what is the problem with "mark as read" function with the python3 version...
Sadly i do not have time to look into that, I will try to help when i can.
"mark as read" problem is because data
variable is not correct type for urlopen
, I added debugging and get this error message:
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.
This is a typical problem when porting from Python 2 to 3.
So I will investigate the solution.
OK! Solved.
Around line 55 or so, depending on your script.
data = json.dumps(data)
becomes
data = json.dumps(data).encode('utf-8')
and "mark as read" now works.
Hey. I found this open PR looking for the process to upgrade the script to python3. I was wondering what work is remaining before this is good to merge? I have some time and would be happy to help carry this over the finish line instead of starting from scratch.