def auth(self, callback): Log.d(TAG, "auth") if "Authorization" in self.request.headers: login, passw = get_loginpass(self.request.headers["Authorization"]) if login == self.login and passw == self.passw: callback() return
def on_close(self, *args, **kwargs): Log.d(TAG, "on_open %r" % id(self)) if not self.is_closed and self.is_static: self.is_closed = True if self._static_connection is not None: self._static_connection.abort() self._static_connection = None super(StaticSocketHandler, self)._break_cycles()
def _execute_callbacks(queue, *args, **kwargs): # type: (list, tuple, dict) -> None for i in range(len(queue)): callback = queue.pop() try: callback(*args, **kwargs) except Exception as e: Log.e(TAG, b"callback execute error", e) Log.d(TAG, b"callbacks execution done")
def main(): psql = models.Model.set_parameters(**s.POSTGRES) redis = RedisClient(**s.REDIS) initializer = dict(relay=object(), push=object(), session=object(), auth=AuthManager(redis)) application = tornado.web.Application([ (r'^/session/(?P<device_id>\d+)/(?P<number>[0-9\+]{3,15})$', MainHandler, initializer) ]) server = tornado.httpserver.HTTPServer(application) server.listen(s.SERVER_PORT, s.SERVER_HOST) server.start() Log.d(TAG, "OpenRedPhoneServer is run")
def on_open(self, *args, **kwargs): Log.d(TAG, "on_open %r" % id(self))
def __del__(self): # Will not be invoke if there is a memory leak somewhere # TODO(s1z): Remove it when everything is done Log.d(TAG, "__del__ %s" % StaticSocketHandler.__name__)
def on_close_callback(self): Log.d(TAG, "on_connected_callback") if self.is_running is True: self._client.disconnect() yield self.connect()
def _handle_response(self, data): try: response = httputil.parse_response_start_line(data) Log.d(TAG, b"_handle_response %r" % response) except httputil.HTTPInputError as e: Log.e(TAG, b"_handle_response error", e)
def __del__(self): # Will not be invoke if there is a memory leak somewhere # TODO(s1z): Remove it when everything is done Log.d(TAG, b"__del__ %r" % MainHandler.__name__)
def on_connected_callback(self): Log.d(TAG, "on_connected_callback")
def delete(self, device_id, number): Log.d(TAG, "delete") return self.handle_delete(device_id, number)
def busy(self, device_id, number): Log.d(TAG, "busy") return self.handle_busy(device_id, number)
def ring(self, device_id, number): Log.d(TAG, "ring") return self.handle_ring(device_id, number)
def get(self, device_id, number): Log.d(TAG, "get") return self.handle_create(device_id, number)
def handle_create(self, device_id, number): Log.d(TAG, "handle_create: %r, %r" % (device_id, number)) self.set_status(200) self.finish()