Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: github.GithubException.GithubException: 502 {"message": "Server Error"}

### INFO
**Python Version**: `3.7.6 (default, Dec 21 2019, 02:28:04) [GCC 8.3.0]`
**Operating System**: `Linux-3.10.105-x86_64-with`
**Locale**: `UTF-8`
**Branch**: [master](../tree/master)
**Database**: `44.15`
**Commit**: pymedusa/Medusa@baad1e5af59d7f29606c1fed1c110af1424bb117
**Link to Log**: https://gist.github.com/4f42865477a3ddc3df6e6891c3a4c895
### ERROR
<pre>
2020-04-21 15:57:47 ERROR    CHECKVERSION :: [baad1e5] Exception generated: 502 {"message": "Server Error"}
Traceback (most recent call last):
  File "/app/medusa/<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/scheduler.py#L78">medusa/scheduler.py</a>", line 78, in run
    self.action.run(self.force)
  File "/app/medusa/<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/updater/version_checker.py#L45">medusa/updater/version_checker.py</a>", line 45, in run
    if self.check_for_new_version(force):
  File "/app/medusa/<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/updater/version_checker.py#L253">medusa/updater/version_checker.py</a>", line 253, in check_for_new_version
    if not self.updater.need_update():
  File "/app/medusa/<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/updater/docker_updater.py#L28">medusa/updater/docker_updater.py</a>", line 28, in need_update
    if self.branch == 'master' and not self.is_latest_version():
  File "/app/medusa/<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/updater/update_manager.py#L42">medusa/updater/update_manager.py</a>", line 42, in is_latest_version
    if LooseVersion(self.newest_version) > LooseVersion(self.current_version):
  File "/app/medusa/<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/updater/source_updater.py#L67">medusa/updater/source_updater.py</a>", line 67, in newest_version
    latest_release = get_latest_release(self.github_org, self.github_repo)
  File "/app/medusa/<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/medusa/github_client.py#L119">medusa/github_client.py</a>", line 119, in get_latest_release
    return gh.get_organization(organization).get_repo(repo).get_latest_release()
  File "/app/medusa/<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/ext/github/MainClass.py#L293">ext/github/MainClass.py</a>", line 293, in get_organization
    headers, data = self.__requester.requestJsonAndCheck("GET", "/orgs/" + login)
  File "/app/medusa/<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/ext/github/Requester.py#L322">ext/github/Requester.py</a>", line 322, in requestJsonAndCheck
    verb, url, parameters, headers, input, self.__customConnection(url)
  File "/app/medusa/<a href="../blob/baad1e5af59d7f29606c1fed1c110af1424bb117/ext/github/Requester.py#L345">ext/github/Requester.py</a>", line 345, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException: 502 {"message": "Server Error"}
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:

Resolving patch:
diff --git a/medusa/updater/update_manager.py b/medusa/updater/update_manager.py
--- a/medusa/updater/update_manager.py
+++ b/medusa/updater/update_manager.py
@@ -5,11 +5,14 @@
 import logging
 from distutils.version import LooseVersion
 
+from github import GithubException
+
 from medusa import app
 from medusa.logger.adapters.style import BraceAdapter
 
-from six import text_type
+from requests.exceptions import RequestException
 
+from six import text_type
 
 log = BraceAdapter(logging.getLogger(__name__))
 log.logger.addHandler(logging.NullHandler())
@@ -39,6 +42,10 @@ def newest_version(self):
 
     def is_latest_version(self):
         """Compare the current installed version with the remote version."""
-        if LooseVersion(self.newest_version) > LooseVersion(self.current_version):
-            return False
+        try:
+            if LooseVersion(self.newest_version) > LooseVersion(self.current_version):
+                return False
+        except (GithubException, RequestException) as error:
+            log.warning("Unable to contact GitHub, can't get latest version: {0!r}", error)
+
         return True


Test patch: