From 1a63d32fe35cfee34ec354bb50d61b63dd3786d0 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 24 Nov 2015 16:31:06 +0800 Subject: [PATCH] fix bug --- jlog/views.py | 1 + jumpserver/api.py | 5 ++++- run_websocket.py | 19 +++++++------------ templates/jlog/log_online.html | 18 +++--------------- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/jlog/views.py b/jlog/views.py index 472f2c3b7..6e319c808 100644 --- a/jlog/views.py +++ b/jlog/views.py @@ -51,6 +51,7 @@ def log_list(request, offset): web_monitor_uri = 'ws://%s/monitor' % WEB_SOCKET_HOST web_kill_uri = 'http://%s/kill' % WEB_SOCKET_HOST + session_id = request.session.session_key return render_to_response('jlog/log_%s.html' % offset, locals(), context_instance=RequestContext(request)) diff --git a/jumpserver/api.py b/jumpserver/api.py index 7e2a0d0ef..b44d5d4e5 100644 --- a/jumpserver/api.py +++ b/jumpserver/api.py @@ -54,7 +54,10 @@ def get_asset_info(asset): if default: info['port'] = default.default_port info['username'] = default.default_user - info['password'] = CRYPTOR.decrypt(default.default_password) + try: + info['password'] = CRYPTOR.decrypt(default.default_password) + except ServerError: + pass info['ssh_key'] = default.default_pri_key_path else: info['port'] = asset.port diff --git a/run_websocket.py b/run_websocket.py index d4ce8bb74..168d50ba9 100644 --- a/run_websocket.py +++ b/run_websocket.py @@ -42,7 +42,7 @@ def require_auth(role='user'): if request.get_cookie('sessionid'): session_key = request.get_cookie('sessionid') else: - session_key = request.get_secure_cookie('sessionid') + session_key = request.get_argument('sessionid', '') logger.debug('Websocket: session_key: %s' % session_key) if session_key: @@ -62,7 +62,10 @@ def require_auth(role='user'): return func(request, *args, **kwargs) else: logger.debug('Websocket: session expired: %s' % session_key) - request.close() + try: + request.close() + except AttributeError: + pass logger.warning('Websocket: Request auth failed.') # asset_id = int(request.get_argument('id', 9999)) # print asset_id @@ -99,14 +102,7 @@ class EventHandler(ProcessEvent): def __init__(self, client=None): self.client = client - def process_IN_CREATE(self, event): - print "Create file:%s." % os.path.join(event.path, event.name) - - def process_IN_DELETE(self, event): - print "Delete file:%s." % os.path.join(event.path, event.name) - def process_IN_MODIFY(self, event): - print "Modify file:%s." % os.path.join(event.path, event.name) self.client.write_message(f.read()) @@ -222,12 +218,11 @@ class WebTerminalKillHandler(tornado.web.RequestHandler): ws_id = self.get_argument('id') Log.objects.filter(id=ws_id).update(is_finished=True) for ws in WebTerminalHandler.clients: - print ws.id if ws.id == int(ws_id): - print "killed" + logger.debug("Kill log id %s" % ws_id) ws.log.save() ws.close() - print len(WebTerminalHandler.clients) + logger.debug('Websocket: web terminal client num: %s' % len(WebTerminalHandler.clients)) class WebTerminalHandler(tornado.websocket.WebSocketHandler): diff --git a/templates/jlog/log_online.html b/templates/jlog/log_online.html index 42ea11a38..562c530a4 100644 --- a/templates/jlog/log_online.html +++ b/templates/jlog/log_online.html @@ -50,7 +50,7 @@