Skip to content

Commit

Permalink
fix: update to python3 (matryer#1433)
Browse files Browse the repository at this point in the history
* fix: update urllib2 to urllib for python3
why?
https://stackoverflow.com/a/2792652/3281978
https://stackoverflow.com/a/28906913/3281978

* Fix shebang

Co-authored-by: Brian Hartvigsen <[email protected]>
  • Loading branch information
tgrrr and tresni authored May 16, 2020
1 parent cc223e0 commit 068cf96
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Dev/RescueTime/rescuetime.1h.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env PYTHONIOENCODING=UTF-8 python3
# <bitbar.title>RescueTime</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Paul Traylor</bitbar.author>
Expand All @@ -13,7 +13,7 @@
import json
import os
import urllib
import urllib2
from urllib.request import urlopen

API_KEY = os.path.expanduser('~/Library/RescueTime.com/api.key')

Expand All @@ -28,8 +28,8 @@

def get(url, params):
'''Simple function to mimic the signature of requests.get'''
params = urllib.urlencode(params)
result = urllib2.urlopen(url + '?' + params).read()
params = urllib.parse.urlencode(params)
result = urlopen(url + '?' + params).read()
return json.loads(result)

if not os.path.exists(API_KEY):
Expand Down

0 comments on commit 068cf96

Please sign in to comment.