minigalaxy
minigalaxy copied to clipboard
api.get_version needs better exception handling
I ran into this happening:
blackwell_deception_1_3_53244.sh integrity is preserved. MD5 is: 61c144995e396515948fbb15c3467494
warning [/home/wouter/.cache/minigalaxy/download/Blackwell Deception/blackwell_deception_1_3_53244.sh]: 829369 extra bytes at beginning or within zipfile
(attempting to process anyway)
Exception in thread Thread-793:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/home/wouter/Sources/minigalaxy/minigalaxy/download.py", line 28, in finish
self.__finish_func(self.save_location)
File "/home/wouter/Sources/minigalaxy/minigalaxy/ui/gametile.py", line 289, in __install_game
install_success = self.__install(save_location)
File "/home/wouter/Sources/minigalaxy/minigalaxy/ui/gametile.py", line 309, in __install
self.game.set_info("version", self.api.get_version(self.game))
File "/home/wouter/Sources/minigalaxy/minigalaxy/api.py", line 229, in get_version
gameinfo = self.get_info(game)
File "/home/wouter/Sources/minigalaxy/minigalaxy/api.py", line 134, in get_info
response = self.__request(request_url)
File "/home/wouter/Sources/minigalaxy/minigalaxy/api.py", line 276, in __request
return response.json()
File "/usr/lib/python3/dist-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
It turns out the json file Blackwell Deception does not exist yet. I don't know how this happened. I was installing this game and had cancelled the download which would happen after it.
This function does not check the response code: https://github.com/sharkwouter/minigalaxy/blob/729d3439a585ab50378bc5f35bedda5f3d1886ba/minigalaxy/api.py#L130