예제 #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
예제 #2
0
파일: gate.py 프로젝트: Dolphi2/ajenti
 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
예제 #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
예제 #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
예제 #5
0
파일: gate.py 프로젝트: tawanda/ajenti
 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