Ejemplo n.º 1
0
 def _stream_reader(self):
     try:
         while True:
             resp = self.stream.buffer_single_response(None)
             if not resp:
                 return
             self.stream.ack_response(resp.id)
             if resp.object['type'] == 'socket':
                 self.q_socket_messages.broadcast(resp)
             if resp.object['type'] == 'http':
                 self.q_http_replies.broadcast(resp)
             if resp.object['type'] == 'terminate':
                 self.session.deactivate()
             if resp.object['type'] == 'restart-master':
                 aj.restart()
             if resp.object['type'] == 'reload-config':
                 aj.config.load()
                 aj.config.ensure_structure()
                 self.stream.send({
                     'type': 'config-data',
                     'data': aj.config.data,
                 })
             if resp.object['type'] == 'log':
                 method = {
                     'info': logging.info,
                     'warn': logging.warn,
                     'debug': logging.debug,
                     'error': logging.error,
                     'critical': logging.critical,
                 }.get(resp.object['method'], None)
                 if method:
                     method(resp.object['message'],
                            extra=resp.object['kwargs'])
     except greenlet.GreenletExit:
         pass
Ejemplo n.º 2
0
 def _stream_reader(self):
     try:
         while True:
             resp = self.stream.buffer_single_response(None)
             if not resp:
                 return
             self.stream.ack_response(resp.id)
             if resp.object['type'] == 'socket':
                 self.q_socket_messages.broadcast(resp)
             if resp.object['type'] == 'http':
                 self.q_http_replies.broadcast(resp)
             if resp.object['type'] == 'terminate':
                 self.session.deactivate()
             if resp.object['type'] == 'restart-master':
                 aj.restart()
             if resp.object['type'] == 'reload-config':
                 aj.config.load()
                 aj.config.ensure_structure()
                 self.gateway_middleware.broadcast_config_data()
             if resp.object['type'] == 'log':
                 method = {
                     'info': logging.info,
                     'warn': logging.warn,
                     'debug': logging.debug,
                     'error': logging.error,
                     'critical': logging.critical,
                 }.get(resp.object['method'], None)
                 if method:
                     method('%s', resp.object['message'], extra=resp.object['kwargs'])
     except greenlet.GreenletExit:
         pass
Ejemplo n.º 3
0
 def _stream_reader(self):
     try:
         while True:
             resp = self.stream.buffer_single_response(None)
             if not resp:
                 return
             self.stream.ack_response(resp.id)
             if resp.object['type'] == 'socket':
                 self.q_socket_messages.broadcast(resp)
             if resp.object['type'] == 'http':
                 self.q_http_replies.broadcast(resp)
             if resp.object['type'] == 'terminate':
                 self.session.deactivate()
             if resp.object['type'] == 'restart-master':
                 aj.restart()
     except greenlet.GreenletExit:
         pass
Ejemplo n.º 4
0
 def _stream_reader(self):
     try:
         while True:
             resp = self.stream.buffer_single_response(None)
             if not resp:
                 return
             self.stream.ack_response(resp.id)
             if resp.object['type'] == 'socket':
                 self.q_socket_messages.broadcast(resp)
             if resp.object['type'] == 'http':
                 self.q_http_replies.broadcast(resp)
             if resp.object['type'] == 'terminate':
                 if self.session != self.gateway_middleware:
                     # Not the restricted session, we can disable it
                     self.session.deactivate()
             if resp.object['type'] == 'restart-master':
                 aj.restart()
             if resp.object['type'] == 'update-sessionlist':
                 self.gateway_middleware.broadcast_sessionlist()
             if resp.object['type'] == 'reload-config':
                 aj.config.load()
                 aj.users.load()
                 aj.config.ensure_structure()
                 self.gateway_middleware.broadcast_config_data()
             if resp.object['type'] == 'log':
                 method = {
                     'info': logging.info,
                     'warn': logging.warning,
                     'warning': logging.warning,
                     'debug': logging.debug,
                     'error': logging.error,
                     'critical': logging.critical,
                 }.get(resp.object['method'], None)
                 if method:
                     method(f"{resp.object['message']}",
                            extra=resp.object['kwargs'])
     except greenlet.GreenletExit:
         pass
Ejemplo n.º 5
0
 def _stream_reader(self):
     try:
         while True:
             resp = self.stream.buffer_single_response(None)
             if not resp:
                 return
             self.stream.ack_response(resp.id)
             if resp.object['type'] == 'socket':
                 self.q_socket_messages.broadcast(resp)
             if resp.object['type'] == 'http':
                 self.q_http_replies.broadcast(resp)
             if resp.object['type'] == 'terminate':
                 self.session.deactivate()
             if resp.object['type'] == 'restart-master':
                 aj.restart()
             if resp.object['type'] == 'reload-config':
                 aj.config.load()
                 aj.config.ensure_structure()
                 self.stream.send({
                     'type': 'config-data',
                     'data': aj.config.data,
                 })
     except greenlet.GreenletExit:
         pass