GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 4cba95...bc8c01 )
by Nat
01:04
created

WebServer.__init__()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
1
#!/usr/bin/env python
2
# Nat Morris (c) 2017
3
4
import cherrypy
5
import copy
6
import imageio
7
from cctvgifbuffer import version
8
9
10
class WebServer(object):
11
12
    service = None
13
14
    def __init__(self, service):
15
        self.service = service
16
17
    @cherrypy.expose
18
    def index(self):
19
        return "cctv-gif-buffer v%s" % (version())
20
21
    @cherrypy.expose
22
    def gif(self, camera):
23
        if camera not in self.service.cameras.keys():
24
            raise cherrypy.HTTPError(404, "Camera not found")
25
        camobject = self.service.cameras[camera]
26
        # obtain a temporary lock to copy the buffer
27
        with camobject["lock"]:
28
            x = copy.copy(camobject["buffer"])
29
        imageio.mimsave("test.gif", x, 'GIF', duration=2)
30
        return self.service.cameras.keys()
31
32
    def start(self):
33
        cherrypy.server.socket_host = '0.0.0.0'
34
        cherrypy.quickstart(self)
35