Passed
Push — master ( 157197...45eeb8 )
by Dave
01:00
created

backend.fcmcamera.CameraService.take_picture()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
2
import backend.fcmservice
3
#from backend.fcmservice import BaseService
4
from helpers.camerahelper import take_picture
5
from domain.sensors import SensorValue
6
7
class CameraService(backend.fcmservice.BaseService):
8
    #def __init__(self, config, cache):
9
    #    super(CameraService, config, cache)
10
11
    def take_picture(self, file_name='fullcycle_camera.png'):
12
        pic = take_picture(file_name,
13
                           super().configuration.get('camera.size'),
14
                           super().configuration.get('camera.quality'),
15
                           super().configuration.get('camera.brightness'),
16
                           super().configuration.get('camera.contrast'))
17
        return pic
18
19
def store_picture_cache(self, file_name):
20
    if os.path.isfile(file_name):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable os does not seem to be defined.
Loading history...
21
        with open(file_name, 'rb') as photofile:
22
            picdata = photofile.read()
23
        #picture will be handled like a sensor
24
        reading = SensorValue('fullcyclecamera', base64.b64encode(picdata), 'camera')
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable base64 does not seem to be defined.
Loading history...
25
        message = super().createmessageenvelope()
26
        sensorjson = message.jsonserialize(SensorValueSchema(), reading)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable SensorValueSchema does not seem to be defined.
Loading history...
27
        self.cache.tryputcache(CacheKeys.camera, sensorjson)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable CacheKeys does not seem to be defined.
Loading history...
28
29
30
31