Esempio n. 1
0
def save_last_error_report(error):
    """Save a copy of our last error report"""
    try:
        rfile = os.path.join(utils.get_file_dir(), 'last_report_error.txt')
        with open(rfile, 'w') as f:
            f.write(error)
    except Exception:
        utils.log("Error writing error report file")
Esempio n. 2
0
def not_already_reported(error):
    """Is the user allowed to send this error?

    Check to see if our new error message is different from the last
    successful error report. If it is, or the file doesn't exist, then
    we'll return True
    """
    try:
        rfile = os.path.join(utils.get_file_dir(), 'last_report_error.txt')

        if not os.path.isfile(rfile):
            return True
        else:
            f = open(rfile, 'r')
            report = f.read()
            if report != error:
                return True
    except Exception as e:
        utils.log("Error checking error report file: %s" % str(e))
        return False

    utils.log("Not allowing error report. Last report matches this one")
    return False
Esempio n. 3
0
 def test_get_file_dir(self, mock_translate_path, make_dir):
     mock_translate_path.return_value = '/home/kodi/.kodi/temp'
     observed = utils.get_file_dir().replace('\\', '/')
     self.assertEqual('/home/kodi/.kodi/temp/test.addon', observed)