# Buggy code
def check_update():
    try:
        logger.info("Checking for Update.")
        github_url = "https://raw.githubusercontent.com/MobSF/Mobile-Security-Framework-MobSF/master/MobSF/settings.py"
        try:
            proxies, verify = upstream_proxy("https")
        except Exception:
            PrintException("[ERROR] Setting upstream proxy")
        response = requests.get(github_url, timeout=5, proxies=proxies, verify=verify)
        html = str(response.text).split("\n")
        for line in html:
            if line.startswith("MOBSF_VER"):
                line = line.replace("MOBSF_VER", "").replace('"', "")
                line = line.replace("=", "").strip()
                if line != settings.MOBSF_VER:
                    logger.warning(
                        "A new version of MobSF is available, Please update from master branch or check "
                        "for new releases."
                    )
                else:
                    logger.info("No updates available.")
    except requests.exceptions.HTTPError as err:
        logger.warning(
            "\n[WARN] Cannot check for updates.. No Internet Connection Found."
        )
        return
    except:
        PrintException("[ERROR] Cannot Check for updates.")


# Traceback (KeyError)
[INFO] 08/Feb/2019 16:17:54 - VM Starting
[INFO] 08/Feb/2019 16:17:55 - "POST /DynamicAnalyzer/ HTTP/1.1" 200 32400
[INFO] 08/Feb/2019 16:17:55 - "GET /static/css/devices.min.css HTTP/1.1" 200 44241
[INFO] 08/Feb/2019 16:17:55 - "GET /download/screen/screen.png HTTP/1.1" 302 0
[DEBUG] 08/Feb/2019 16:17:55 - Exception while resolving variable 'exp' in template 'general/error.html'.
Traceback (most recent call last):
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/base.py", line 829, in _resolve_lookup
current = current[bit]
File "/home/userhome/Mobile-Security-Framework-MobSF/venv/lib/python3.6/site-packages/django/template/context.py", line 83, in __getitem__
raise KeyError(key)
KeyError: 'exp'

During handling of the above exception, another exception occurred:

# Fixed code
def check_update():
    try:
        logger.info("Checking for Update.")
        github_url = "https://raw.githubusercontent.com/MobSF/Mobile-Security-Framework-MobSF/master/MobSF/settings.py"
        try:
            proxies, verify = upstream_proxy("https")
        except Exception:
            PrintException("Setting upstream proxy")
        response = requests.get(github_url, timeout=5, proxies=proxies, verify=verify)
        html = str(response.text).split("\n")
        for line in html:
            if line.startswith("MOBSF_VER"):
                line = line.replace("MOBSF_VER", "").replace('"', "")
                line = line.replace("=", "").strip()
                if line != settings.MOBSF_VER:
                    logger.warning(
                        "A new version of MobSF is available, Please update from master branch or check "
                        "for new releases."
                    )
                else:
                    logger.info("No updates available.")
    except requests.exceptions.HTTPError as err:
        logger.warning("\nCannot check for updates.. No Internet Connection Found.")
        return
    except:
        PrintException("Cannot Check for updates.")