diff options
Diffstat (limited to 'sbhs_server/webcam')
-rw-r--r-- | sbhs_server/webcam/__init__.py | 0 | ||||
-rw-r--r-- | sbhs_server/webcam/__init__.pyc | bin | 0 -> 145 bytes | |||
-rw-r--r-- | sbhs_server/webcam/admin.py | 3 | ||||
-rw-r--r-- | sbhs_server/webcam/management/__init__.py | 0 | ||||
-rw-r--r-- | sbhs_server/webcam/management/__init__.pyc | bin | 0 -> 156 bytes | |||
-rw-r--r-- | sbhs_server/webcam/management/commands/__init__.py | 0 | ||||
-rw-r--r-- | sbhs_server/webcam/management/commands/reload_images.py | 12 | ||||
-rw-r--r-- | sbhs_server/webcam/models.py | 3 | ||||
-rw-r--r-- | sbhs_server/webcam/models.pyc | bin | 0 -> 199 bytes | |||
-rw-r--r-- | sbhs_server/webcam/tests.py | 3 | ||||
-rw-r--r-- | sbhs_server/webcam/views.py | 47 | ||||
-rw-r--r-- | sbhs_server/webcam/views.py-bkup | 47 |
12 files changed, 115 insertions, 0 deletions
diff --git a/sbhs_server/webcam/__init__.py b/sbhs_server/webcam/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/sbhs_server/webcam/__init__.py diff --git a/sbhs_server/webcam/__init__.pyc b/sbhs_server/webcam/__init__.pyc Binary files differnew file mode 100644 index 0000000..b3d3fc2 --- /dev/null +++ b/sbhs_server/webcam/__init__.pyc diff --git a/sbhs_server/webcam/admin.py b/sbhs_server/webcam/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/sbhs_server/webcam/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/sbhs_server/webcam/management/__init__.py b/sbhs_server/webcam/management/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/sbhs_server/webcam/management/__init__.py diff --git a/sbhs_server/webcam/management/__init__.pyc b/sbhs_server/webcam/management/__init__.pyc Binary files differnew file mode 100644 index 0000000..be6dca2 --- /dev/null +++ b/sbhs_server/webcam/management/__init__.pyc diff --git a/sbhs_server/webcam/management/commands/__init__.py b/sbhs_server/webcam/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/sbhs_server/webcam/management/commands/__init__.py diff --git a/sbhs_server/webcam/management/commands/reload_images.py b/sbhs_server/webcam/management/commands/reload_images.py new file mode 100644 index 0000000..5b735cb --- /dev/null +++ b/sbhs_server/webcam/management/commands/reload_images.py @@ -0,0 +1,12 @@ +from django.core.management.base import BaseCommand +from sbhs_server.tables.models import Board +from sbhs_server.webcam.views import load_image + +class Command(BaseCommand): + args = '' + help = 'Reloads images for all SBHS machines' + + def handle(self, *args, **options): + boards = Board.objects.all() + for b in boards: + load_image(b.mid) diff --git a/sbhs_server/webcam/models.py b/sbhs_server/webcam/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/sbhs_server/webcam/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/sbhs_server/webcam/models.pyc b/sbhs_server/webcam/models.pyc Binary files differnew file mode 100644 index 0000000..9026348 --- /dev/null +++ b/sbhs_server/webcam/models.pyc diff --git a/sbhs_server/webcam/tests.py b/sbhs_server/webcam/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/sbhs_server/webcam/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/sbhs_server/webcam/views.py b/sbhs_server/webcam/views.py new file mode 100644 index 0000000..d765730 --- /dev/null +++ b/sbhs_server/webcam/views.py @@ -0,0 +1,47 @@ +from django.shortcuts import render +from django.contrib.auth.decorators import login_required +import os, requests +from sbhs_server import settings +from django.http import HttpResponse +from sbhs_server.admin.views import checkadmin +from sbhs_server.tables.models import Board +# Create your views here. +# + +def load_image(mid): +# for images on server 15, it will gstream the photos on reload + if int(mid) in range(8,17): + command = "streamer -q -f jpeg -c /dev/video" + str(mid) + command += " -o " + settings.WEBCAM_DIR + "/image" + str(mid) + ".jpeg" + os.system(command) + + else: + take_snapshot = requests.get("http://10.102.152.16:8080/webcams/%d/take_snapshot" % int(mid)) + get_image_link = "http://10.102.152.16:8080/webcams/%d/get_image_data" % int(mid) + + command = "curl -s %s > %s/image%d.jpeg" % (get_image_link, str(settings.WEBCAM_DIR), int(mid)) + os.system(command) +def reload(req, mid): + + load_image(mid) + return HttpResponse("") + +@login_required(redirect_field_name=None) +def show_video(req): + board = req.user.board + + image_link = board.image_link() + mid = str(board.mid) + +# image_link = board.image_link() + + return render(req, "webcam/show_video.html", {"image_link": image_link, "mid": mid}) + + +@login_required(redirect_field_name=None) +def show_video_to_admin(req, mid): + checkadmin(req) + board = Board.objects.get(mid=int(mid)) + image_link = board.image_link() + mid = str(board.mid) + return render(req, "webcam/show_video.html", {"image_link": image_link, "mid": mid}) diff --git a/sbhs_server/webcam/views.py-bkup b/sbhs_server/webcam/views.py-bkup new file mode 100644 index 0000000..d765730 --- /dev/null +++ b/sbhs_server/webcam/views.py-bkup @@ -0,0 +1,47 @@ +from django.shortcuts import render +from django.contrib.auth.decorators import login_required +import os, requests +from sbhs_server import settings +from django.http import HttpResponse +from sbhs_server.admin.views import checkadmin +from sbhs_server.tables.models import Board +# Create your views here. +# + +def load_image(mid): +# for images on server 15, it will gstream the photos on reload + if int(mid) in range(8,17): + command = "streamer -q -f jpeg -c /dev/video" + str(mid) + command += " -o " + settings.WEBCAM_DIR + "/image" + str(mid) + ".jpeg" + os.system(command) + + else: + take_snapshot = requests.get("http://10.102.152.16:8080/webcams/%d/take_snapshot" % int(mid)) + get_image_link = "http://10.102.152.16:8080/webcams/%d/get_image_data" % int(mid) + + command = "curl -s %s > %s/image%d.jpeg" % (get_image_link, str(settings.WEBCAM_DIR), int(mid)) + os.system(command) +def reload(req, mid): + + load_image(mid) + return HttpResponse("") + +@login_required(redirect_field_name=None) +def show_video(req): + board = req.user.board + + image_link = board.image_link() + mid = str(board.mid) + +# image_link = board.image_link() + + return render(req, "webcam/show_video.html", {"image_link": image_link, "mid": mid}) + + +@login_required(redirect_field_name=None) +def show_video_to_admin(req, mid): + checkadmin(req) + board = Board.objects.get(mid=int(mid)) + image_link = board.image_link() + mid = str(board.mid) + return render(req, "webcam/show_video.html", {"image_link": image_link, "mid": mid}) |