# Buggy code
def get_result(self, file_path, file_hash):
    """
    Uoloading a file and getting the approval msg from VT or fetching existing report
    :param file_path: file's path
    :param file_hash: file's hash - md5/sha1/sha256
    :return: VirusTotal result json / None upon error
    """
    try:
        logger.info("[INFO] VirusTotal: Check for existing report")
        report = self.get_report(file_hash)
        # Check for existing report
        if report:
            if report["response_code"] == 1:
                logger.info("[INFO] VirusTotal: " + report["verbose_msg"])
                return report
        if settings.VT_UPLOAD:
            logger.info("[INFO] VirusTotal: file upload")
            upload_response = self.upload_file(file_path)
            if upload_response:
                logger.info(
                    "[INFO] VirusTotal: {}".format(upload_response["verbose_msg"])
                )
            return upload_response
        else:
            logger.info(
                "MobSF: VirusTotal Scan not performed as file upload is disabled in settings.py. "
                "To enable file upload, set VT_UPLOAD to True."
            )
            report = {
                "verbose_msg": "Scan Not performed, VirusTotal file upload disabled in settings.py",
                "positives": 0,
                "total": 0,
            }
            return report
    except:
        PrintException("[ERROR] in VirusTotal get_result")


# 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 get_result(self, file_path, file_hash):
    """
    Uoloading a file and getting the approval msg from VT or fetching existing report
    :param file_path: file's path
    :param file_hash: file's hash - md5/sha1/sha256
    :return: VirusTotal result json / None upon error
    """
    try:
        logger.info("VirusTotal: Check for existing report")
        report = self.get_report(file_hash)
        # Check for existing report
        if report:
            if report["response_code"] == 1:
                logger.info("VirusTotal: " + report["verbose_msg"])
                return report
        if settings.VT_UPLOAD:
            logger.info("VirusTotal: file upload")
            upload_response = self.upload_file(file_path)
            if upload_response:
                logger.info("VirusTotal: {}".format(upload_response["verbose_msg"]))
            return upload_response
        else:
            logger.info(
                "MobSF: VirusTotal Scan not performed as file upload is disabled in settings.py. "
                "To enable file upload, set VT_UPLOAD to True."
            )
            report = {
                "verbose_msg": "Scan Not performed, VirusTotal file upload disabled in settings.py",
                "positives": 0,
                "total": 0,
            }
            return report
    except:
        PrintException("VirusTotal get_result")