def _do_call(self, endpoint, method, callback=None, **k): k = prepare_args(k) if self.access_token: k['access_token'] = self.access_token.encode('utf8') url = UrlQuery(self.graph_http + endpoint + '/' + method, **k) log.info("calling method: %s", method) log.info_s("calling: %s with %r", url, k) if self.mode == 'async': return self.call_asynchttp(url, None, callback=callback) elif self.mode == 'console': return call_urllib2(url, None) elif self.mode == 'threaded': from util.threads import threaded return threaded(call_urllib2)(url, None, callback=callback) else: return callback_adapter(call_urllib2)(url, None, callback=callback)
def batch(self, *a, **k): callback = k.pop('callback') k['batch'] = list(a) k = prepare_args(k) if self.access_token: k['access_token'] = self.access_token.encode('utf-8') url = UrlQuery(self.graph_http + self.graph_endpoint) data = self.prepare_values(k) if self.mode == 'async': return self.call_asynchttp(url, data, callback=callback) elif self.mode == 'console': return call_urllib2(url, data) elif self.mode == 'threaded': from util.threads import threaded return threaded(call_urllib2)(url, data, callback=callback) else: return callback_adapter(call_urllib2)(url, data, callback=callback)
def get(self, callback=None, **k): version = self.stringversion from gui.native.helpers import GetUserIdleTime from AccountManager import SECONDS_FOR_IDLE idle = GetUserIdleTime() > (1000 * SECONDS_FOR_IDLE) local_load_exc = getattr(self.profile, 'local_load_exc', None) log.debug('loaded: %s initial: %s', local_load_exc, self.initial) have_acct_data = not bool(local_load_exc) button_clicked = bool(self.initial) log.debug('have_data: %s button_clicked: %s', have_acct_data, button_clicked) if button_clicked and not have_acct_data: state = 'initial_nocache' elif button_clicked: state = 'initial' elif idle: state = 'reconnect_idle' else: state = 'reconnect' url = net.UrlQueryObject('http://%s:%s/load/all/json' % (self.host, self.port), revision=getattr(sys, 'REVISION', 'unknown'), tag=getattr(sys, 'TAG', 'unknown'), username=self.username, version=version, state=state, v=version, **k) log.debug('calling loadbalance URL: %s', url) if self.mode == 'async': return self.call_async(url, callback=callback) elif self.mode == 'console': return self.get_urllib(url) elif self.mode == 'threaded': return threads.threaded(self.get_urllib)(url, callback=callback) else: return callbacks.callback_adapter(self.get_urllib)( url, callback=callback)
def __missing__(self, song): """ returns None and retrieves the snipr url for the given song, inserting the return value from that API. """ self[song] = None try: return self[song] finally: url = UrlQuery('http://www.amazon.com/gp/search', LazySortedDict(dict(ie = 'UTF8', keywords = song.encode('utf-8'), tag = 'dmp3-20', index = 'digital-music', linkCode = 'ur2', camp = '1789', creative = '9325'))) f = threaded(get_short_url) f.verbose = True f(url, success = lambda val: self.__setitem__(song, change_hostname(val, 'music.digsby.com')), error = lambda _e: self.pop(song))
def get(self, callback=None, **k): version = self.stringversion from gui.native.helpers import GetUserIdleTime from AccountManager import SECONDS_FOR_IDLE idle = GetUserIdleTime() > (1000 * SECONDS_FOR_IDLE) local_load_exc = getattr(self.profile, 'local_load_exc', None) log.debug('loaded: %s initial: %s', local_load_exc, self.initial) have_acct_data = not bool(local_load_exc) button_clicked = bool(self.initial) log.debug('have_data: %s button_clicked: %s', have_acct_data, button_clicked) if button_clicked and not have_acct_data: state = 'initial_nocache' elif button_clicked: state = 'initial' elif idle: state = 'reconnect_idle' else: state = 'reconnect' url = net.UrlQueryObject('http://%s:%s/load/all/json' % (self.host, self.port), revision = getattr(sys, 'REVISION', 'unknown'), tag = getattr(sys, 'TAG', 'unknown'), username = self.username, version = version, state = state, v = version, **k) log.debug('calling loadbalance URL: %s', url) if self.mode == 'async': return self.call_async(url, callback=callback) elif self.mode == 'console': return self.get_urllib(url) elif self.mode == 'threaded': return threads.threaded(self.get_urllib)(url, callback=callback) else: return callbacks.callback_adapter(self.get_urllib)(url, callback=callback)
def __call__(self, method, callback=None, prepare=False, **k): k = prepare_args(k) data = self.prepare_call(method, **k) if prepare: return data if pref('facebook.api.https', False, bool): url = self.secure_server_url else: url = self.server_url log.info("calling method: %s", method) log.info_s("calling: %s with %r", url, k) callback.error += self.handle_error if self.mode == 'async': return self.call_asynchttp(url, data, callback=callback) elif self.mode == 'console': return call_urllib2(url, data) elif self.mode == 'threaded': from util.threads import threaded return threaded(call_urllib2)(url, data, callback=callback) else: return callback_adapter(call_urllib2)(url, data, callback=callback) log.info("called method: %s", method)
def asyn(identifier, *args, **kwargs): threaded(syn)(identifier, *args, **kwargs)