diff --git a/jumpserver.py b/jumpserver.py index 5b7efa806..bfc27142f 100755 --- a/jumpserver.py +++ b/jumpserver.py @@ -19,6 +19,8 @@ import pxssh import pexpect cur_dir = os.path.dirname(__file__) +if not cur_dir: + cur_dir = "./" sys.path.append('%s/webroot/AutoSa/' % cur_dir) os.environ['DJANGO_SETTINGS_MODULE'] = 'AutoSa.settings' diff --git a/webroot/AutoSa/AutoSa/urls.py b/webroot/AutoSa/AutoSa/urls.py index 4d2999d97..6bf1ea5a3 100644 --- a/webroot/AutoSa/AutoSa/urls.py +++ b/webroot/AutoSa/AutoSa/urls.py @@ -32,4 +32,5 @@ urlpatterns = patterns('', (r'^upFile/$', views.upFile), (r'^downFile/$', views.downFile), (r'^logView/$', views.logView), + (r'^logHistory/$', views.logHistory), ) diff --git a/webroot/AutoSa/AutoSa/views.py b/webroot/AutoSa/AutoSa/views.py index 45509baed..a6ddffe02 100644 --- a/webroot/AutoSa/AutoSa/views.py +++ b/webroot/AutoSa/AutoSa/views.py @@ -976,6 +976,23 @@ def logView(request): context_instance=RequestContext(request)) +@admin_required +def logHistory(request): + if request.method == 'GET': + logid = request.GET.get('id', 0) + log = Logs.objects.filter(id=int(logid)) + if log: + log = log[0] + log_his = "%s.his" % log.filename + if os.path.isfile(log_his): + f = open(log_his) + content = f.read() + return render_to_response(content) + + + + + diff --git a/webroot/AutoSa/log_handler.py b/webroot/AutoSa/log_handler.py index ed35864a6..9709e7d44 100755 --- a/webroot/AutoSa/log_handler.py +++ b/webroot/AutoSa/log_handler.py @@ -17,9 +17,12 @@ def log_hanler(logid): if log: log = log[0] filename = log.logfile - os.system('cat %s | grep "DateTime" > %s.his' % (filename, filename)) - os.system('cat %s | grep "\[.*@.*\][\$\#]" >> %s.his' % (filename, filename)) - os.system('cat %s | grep "EndTime" >> %s.his' % (filename, filename)) + ret1 = os.system('cat %s | grep "DateTime" > %s.his' % (filename, filename)) + ret2 = os.system('cat %s | grep "\[.*@.*\][\$\#]" >> %s.his' % (filename, filename)) + ret3 = os.system('cat %s | grep "EndTime" >> %s.his' % (filename, filename)) + if (ret1 + ret2 + ret3) == 0: + print 'Handler % ok.' % filename + def set_finish(id): diff --git a/webroot/AutoSa/templates/logHistory.html b/webroot/AutoSa/templates/logHistory.html new file mode 100644 index 000000000..8050f593d --- /dev/null +++ b/webroot/AutoSa/templates/logHistory.html @@ -0,0 +1,18 @@ +{% extends 'base.html' %} +{% block content %} + +
+ +{% end block %} \ No newline at end of file diff --git a/webroot/AutoSa/templates/logView.html b/webroot/AutoSa/templates/logView.html index cf1343bda..9f584b0c7 100644 --- a/webroot/AutoSa/templates/logView.html +++ b/webroot/AutoSa/templates/logView.html @@ -23,7 +23,7 @@