Skip to content

Commit

Permalink
Fixes #4
Browse files Browse the repository at this point in the history
* explicitly call decode on the webresponse and don't rely on the decode magic of python 3.6 to keep backwards compatibility to older version of keypirinha
* version bump
  • Loading branch information
ueffel committed Aug 29, 2018
1 parent 7dd753f commit 964a12e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ All commands are prefixed with `PackageControl:`.
* Open the `Keypirinha: Console`
* Enter the following:
```python
import keypirinha as kp,keypirinha_net as kpn,os;p="PackageControl.keypirinha-package";d=kpn.build_urllib_opener().open("https://github.com/ueffel/Keypirinha-PackageControl/releases/download/0.2.1/"+p);pb=d.read();d.close();f=open(os.path.join(kp.installed_package_dir(),p),"wb");f.write(pb);f.close()
import keypirinha as kp,keypirinha_net as kpn,os;p="PackageControl.keypirinha-package";d=kpn.build_urllib_opener().open("https://github.com/ueffel/Keypirinha-PackageControl/releases/download/0.2.2/"+p);pb=d.read();d.close();f=open(os.path.join(kp.installed_package_dir(),p),"wb");f.write(pb);f.close()
```

### Manually
Expand Down
4 changes: 2 additions & 2 deletions packagecontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def _get_available_packages(self, force=False):

if not force and last_run and os.path.isfile(os.path.join(cache_path, "packages.json")):
with open(os.path.join(cache_path, "packages.json"), "r") as cache:
repo = json.loads(cache.read())
repo = json.load(cache)
write_cache = False
self.info("Package list loaded from file cache '{}' ({} packages)".format(repo["name"],
len(repo["packages"])))
Expand All @@ -381,7 +381,7 @@ def _get_available_packages(self, force=False):
self.dbg("No available packages cached or its time to update, getting list from", self._repo_url)
req = urllib.request.Request(self._repo_url)
with self._urlopener.open(req) as response:
repo = json.loads(response.read())
repo = json.loads(response.read().decode())
if hasattr(req, "redirect"):
self.info("Request permanently redirected. Changing repository url to:", req.redirect)
self._repo_url = req.redirect
Expand Down

0 comments on commit 964a12e

Please sign in to comment.