def get_rollback_module(): import imp module_urls = [ 'https://raw.githubusercontent.com/SickGear/sickgear.extdata/master/SickGear/Rollback/rollback.py' ] try: hdr = '# SickGear Rollback Module' module = '' fetched = False for t in range(1, 4): for url in module_urls: try: module = helpers.getURL(url) if module and module.startswith(hdr): fetched = True break except (StandardError, Exception): continue if fetched: break time.sleep(30) if fetched: loaded = imp.new_module('DbRollback') exec(module, loaded.__dict__) return loaded except (StandardError, Exception): pass return None
def _access_API(self, path, params=None): """ Access the API at the path given and with the optional params given. path: A list of the path elements to use (eg. ['repos', 'midgetspy', 'Sick-Beard', 'commits']) params: Optional dict of name/value pairs for extra params to send. (eg. {'per_page': 10}) Returns a deserialized json object of the result. Doesn't do any error checking (hope it works). """ url = 'https://api.github.com/' + '/'.join(path) if params and type(params) is dict: url += '?' + '&'.join([str(x) + '=' + str(params[x]) for x in params.keys()]) parsedJSON = helpers.getURL(url, json=True) if not parsedJSON: return [] return parsedJSON
def _access_API(self, path, params=None): """ Access the API at the path given and with the optional params given. path: A list of the path elements to use (eg. ['repos', 'xbianonpi', 'Sick-Beard-TPB', 'commits']) params: Optional dict of name/value pairs for extra params to send. (eg. {'per_page': 10}) Returns a deserialized json object of the result. Doesn't do any error checking (hope it works). """ url = "https://api.github.com/" + "/".join(path) if params and type(params) is dict: url += "?" + "&".join([str(x) + "=" + str(params[x]) for x in params.keys()]) data = helpers.getURL(url) if data: json_data = json.loads(data) return json_data else: return []