def _get_data(self, filepath, cachefilepath, url, url_params): json_data = '' if self._update_cache(filepath, cachefilepath): success, uloglines, json_data = self.JSONURL.Get(url, params=url_params) self.LOGLINES.extend(uloglines) if success: success, wloglines = writeFile( py2_encode(_json.dumps(json_data)), filepath) self.LOGLINES.extend(wloglines) exists, cloglines = checkPath(filepath, False) self.LOGLINES.extend(cloglines) if exists: self._get_audiodbid( ) # this is to generate the id file if it doesn't exist rloglines, rawdata = readFile(filepath) self.LOGLINES.extend(rloglines) try: json_data = _json.loads(rawdata) except ValueError: success, dloglines = deleteFile(filepath) self.LOGLINES.extend(dloglines) self.LOGLINES.append( 'Deleted old cache file. New file will be download on next run.' ) json_data = '' return json_data
def _deletePID(): success, loglines = deleteFile(pidfile)