def get(keys, on_items, on_error=None, **kwargs): get_helper(url=add_params(endpoint('get_items'), key=keys, allow_multiple=True), on_response=partial(_handle_items, on_items=on_items, on_error=on_error), on_error=on_error)
def delete(url, on_created=None, on_error=None): errback = on_error or make_errback(frames_back=2) try: def handle_response(response): if response.code == 200: callback = partial( _handle_delete, on_created=on_created, on_error=errback) response.deliverBody(JsonReceiver.create(callback, errback)) else: errback('returned %s' % response.code) agent = Agent(reactor) headers = Headers(get_auth_headers()) d = agent.request( 'DELETE', add_params(url, rid=uuid4().hex), headers=headers) d.addCallbacks(handle_response, errback) except Exception as ex: errback('error %s' % ex)
def StartNotificationsService(headers, url, keys, systemurl): # start notification service Logger.info('StartNotificationsService:\nURL=%s\nKeys=%s' % (url, keys)) if platform == 'android': try: AUTH = headers.get('Authorization', '')[0] from api import add_params KEYS = add_params('', allow_multiple=True, key=keys, kind='Comment') print('starting notification service') from jnius import autoclass String = autoclass('java.lang.String') PythonActivity = autoclass('org.renpy.android.PythonActivity') theActivity = PythonActivity.mActivity aURL = String(url) aAUTH = String(AUTH) aKEYS = String(KEYS) aSYSTEMURL = String(systemurl) theActivity.startService(aURL, aAUTH, aKEYS, aSYSTEMURL) except: print('starting notification service -- failed') pass
def get(keys, on_items, on_error=None, **kwargs): get_helper( url=add_params(endpoint('get_items'), key=keys, allow_multiple=True), on_response=partial(_handle_items, on_items=on_items, on_error=on_error), on_error=on_error)