Ejemplo n.º 1
0
 def GET(self):
     qdict = web.input()
     if 'substation' not in qdict:
         qdict['substation'] = str(gv.substation_index)
     subid = int(qdict['substation'])
     subprocess.call(['rm', 'static/images/camera_temp.jpg'])
     if process_page_request('view_camera', qdict):
         if gv.plugin_data['ca']['enable_camera'] == 'on':
             subprocess.call(['cp', 'static/images/camera.jpg', 'static/images/camera_temp.jpg'])
         return template_render.camera(0, gv.plugin_data['ca'])
     elif 'substation' not in qdict:
         raise web.seeother('/suslv?head=Cameras&continuation=ca')
     else:
         try:
             subid, data = load_and_save_remote(qdict, [], 'susldr', 'data', {'camera':1, 'cai':1})
             if data['cai']:
                 try:
                     with open('static/images/camera_temp.jpg', mode='wb') as file: # b is important -> binary
                         file.write(base64.b64decode(data['cai']))
                 except Exception as ex:
                     gv.logger.critical('Could not write camera_temp.jpg.  ex: ' + str(ex))
             return template_render.camera(subid, data['camera'])
         except Exception as ex:
             gv.logger.exception('view_camera: No response from slave: ' +
                            gv.plugin_data['su']['subinfo'][subid]['name'] + ' Exception: ' + str(ex))
             gv.plugin_data['su']['subinfo'][subid]['status'] = 'unreachable'
             raise web.seeother('/unreachable')
Ejemplo n.º 2
0
 def GET(self):
     qdict = web.input()
     if 'substation' not in qdict:
         qdict['substation'] = str(gv.substation_index)
     subid = int(qdict['substation'])
     subprocess.call(['rm', 'static/images/camera_temp.jpg'])
     if process_page_request('view_camera', qdict):
         if gv.plugin_data['ca']['enable_camera'] == 'on':
             subprocess.call([
                 'cp', 'static/images/camera.jpg',
                 'static/images/camera_temp.jpg'
             ])
         return template_render.camera(0, gv.plugin_data['ca'])
     elif 'substation' not in qdict:
         raise web.seeother('/suslv?head=Cameras&continuation=ca')
     else:
         try:
             subid, data = load_and_save_remote(qdict, [], 'susldr', 'data',
                                                {
                                                    'camera': 1,
                                                    'cai': 1
                                                })
             if data['cai']:
                 try:
                     with open(
                             'static/images/camera_temp.jpg',
                             mode='wb') as file:  # b is important -> binary
                         file.write(base64.b64decode(data['cai']))
                 except Exception as ex:
                     gv.logger.critical(
                         'Could not write camera_temp.jpg.  ex: ' + str(ex))
             return template_render.camera(subid, data['camera'])
         except Exception as ex:
             gv.logger.exception(
                 'view_camera: No response from slave: ' +
                 gv.plugin_data['su']['subinfo'][subid]['name'] +
                 ' Exception: ' + str(ex))
             gv.plugin_data['su']['subinfo'][subid][
                 'status'] = 'unreachable'
             raise web.seeother('/unreachable')
Ejemplo n.º 3
0
 def GET(self):
     with open('./data/camera.json', 'r') as f:  # Read the settings from file
         params = json.load(f)
     return template_render.camera(params)