xbar-plugins icon indicating copy to clipboard operation
xbar-plugins copied to clipboard

001-notifications.30s.py: fix small bugs and add discussion

Open elalemanyo opened this issue 2 years ago • 10 comments

  • 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 but CheckSuite don't have href so link is not working 😞

elalemanyo avatar Mar 07 '22 16:03 elalemanyo

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 avatar Mar 07 '22 17:03 elalemanyo

@elalemanyo what's happening with the option click?

matryer avatar Mar 23 '22 14:03 matryer

@elalemanyo what's happening with the option click?

@matryer mark as read is not working, notification still there 🤷 not sure what is going on

elalemanyo avatar Mar 23 '22 14:03 elalemanyo

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.

gingerbeardman avatar Apr 01 '22 14:04 gingerbeardman

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

elalemanyo avatar Apr 08 '22 09:04 elalemanyo

The only thing the last Python 2 version does not cope with are Discussion notifications.

gingerbeardman avatar Apr 08 '22 10:04 gingerbeardman

Yes Discussion and CheckSuite 😞 Not sure what is the problem with "mark as read" function with the python3 version...

elalemanyo avatar Apr 08 '22 10:04 elalemanyo

Sadly i do not have time to look into that, I will try to help when i can.

gingerbeardman avatar Apr 08 '22 10:04 gingerbeardman

"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.

gingerbeardman avatar Jun 13 '22 23:06 gingerbeardman

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.

gingerbeardman avatar Jun 13 '22 23:06 gingerbeardman

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.

funkymonkeymonk avatar Aug 22 '22 20:08 funkymonkeymonk