summaryrefslogtreecommitdiff
path: root/myadmin
diff options
context:
space:
mode:
Diffstat (limited to 'myadmin')
-rw-r--r--myadmin/urls.py2
-rw-r--r--myadmin/views.py13
2 files changed, 14 insertions, 1 deletions
diff --git a/myadmin/urls.py b/myadmin/urls.py
index 4e929c7..417fbb0 100644
--- a/myadmin/urls.py
+++ b/myadmin/urls.py
@@ -12,7 +12,7 @@ urlpatterns = [
url(r'^admin/setdevice/?$', views.set_device_params, name='admin_set_device'),
url(r'^admin/gettemp/?$', views.get_device_temp, name='admin_get_temp'),
url(r'^admin/monitor/?$', views.monitor_experiment, name='admin_monitor'),
-
+ url(r'^admin/logs/([0-9]+)/?$', views.download_log, name='admin_logs'),
url(r'^admin/toggle_allotment_mode/?$', views.toggle_allotment_mode, name='admin_toggle_allotment_mode'),
] \ No newline at end of file
diff --git a/myadmin/views.py b/myadmin/views.py
index b4a4f33..bd896e3 100644
--- a/myadmin/views.py
+++ b/myadmin/views.py
@@ -128,6 +128,19 @@ def monitor_experiment(req):
data = {"user": current_user, "logs": logs}
return HttpResponse(json.dumps({"status_code":200, "message":data}), content_type="application/json")
+@login_required(redirect_field_name=None)
+def download_log(req, mid):
+ checkadmin(req)
+ try:
+ global_logfile = settings.SBHS_GLOBAL_LOG_DIR + "/" + mid + ".log"
+ f = open(global_logfile, "r")
+ data = f.read()
+ f.close()
+ return HttpResponse(data, content_type='text/text')
+ except:
+ return HttpResponse("Requested log file doesn't exist.")
+
+
@csrf_exempt
def reset_device(req):
"""Resets the device to fan = 100 and heat = 0