def cfg_details(about): if about == 'tvservice': result = {} result['resolution'] = display.available() result['status'] = display.current() return jsonify(result) elif about == 'current': image, mime = display.get() response = app.make_response(image) response.headers.set('Content-Type', mime) return response elif about == 'drivers': result = drivers.list().keys() return jsonify(result) elif about == 'timezone': result = helper.timezoneList() return jsonify(result) elif about == 'version': output = subprocess.check_output(['git', 'log', '-n1'], stderr=void) lines = output.split('\n') infoDate = lines[2][5:].strip() infoCommit = lines[0][7:].strip() output = subprocess.check_output(['git', 'status'], stderr=void) lines = output.split('\n') infoBranch = lines[0][10:].strip() return jsonify({'date':infoDate, 'commit':infoCommit, 'branch': infoBranch}) elif about == 'color': return jsonify(slideshow.getColorInformation()) elif about == 'sensor': return jsonify({'sensor' : colormatch.hasSensor()}) elif about == 'display': return jsonify({'display':display.isEnabled()}) abort(404)
def handle(self, app, about): if about == 'tvservice': result = {} result['resolution'] = self.displaymgr.available() result['status'] = self.displaymgr.current() return self.jsonify(result) elif about == 'current': image, mime = self.displaymgr.get() response = app.make_response(image) response.headers.set('Content-Type', mime) return response elif about == 'drivers': result = self.drivermgr.list().keys() return self.jsonify(result) elif about == 'timezone': result = helper.timezoneList() return self.jsonify(result) elif about == 'version': output = subprocess.check_output(['git', 'log', '-n1'], stderr=self.void) lines = output.split('\n') infoDate = lines[2][5:].strip() infoCommit = lines[0][7:].strip() output = subprocess.check_output(['git', 'status'], stderr=self.void) lines = output.split('\n') infoBranch = lines[0][10:].strip() return self.jsonify({ 'date': infoDate, 'commit': infoCommit, 'branch': infoBranch }) elif about == 'color': return self.jsonify(self.slideshow.getColorInformation()) elif about == 'sensor': return self.jsonify({'sensor': self.colormatch.hasSensor()}) elif about == 'display': return self.jsonify({'display': self.displaymgr.isEnabled()}) elif about == 'network': return self.jsonify({'network': helper.hasNetwork()}) elif about == 'hardware': output = '' try: output = subprocess.check_output( ['/opt/vc/bin/vcgencmd', 'get_throttled'], stderr=self.void) except: logging.exception('Unable to execute /opt/vc/bin/vcgencmd') if not output.startswith('throttled='): logging.error('Output from vcgencmd get_throttled has changed') output = 'throttled=0x0' try: h = int(output[10:].strip(), 16) except: logging.exception( 'Unable to convert output from vcgencmd get_throttled') result = { 'undervoltage': h & (1 << 0 | 1 << 16) > 0, 'frequency': h & (1 << 1 | 1 << 17) > 0, 'throttling': h & (1 << 2 | 1 << 18) > 0, 'temperature': h & (1 << 3 | 1 << 19) > 0 } return self.jsonify(result) elif about == 'messages': # This should be made more general purpose since other parts need similar service msgs = [] images = self.servicemgr.getTotalImageCount timeneeded = images * self.settings.getUser('interval') timeavailable = self.settings.getUser('refresh') * 3600 if timeavailable > 0 and timeneeded > timeavailable: msgs.append({ 'level': 'WARNING', 'message': 'Change every %d seconds with %d images will take %dh, refresh keywords is %dh' % (self.settings.getUser('interval'), images, timeneeded / 3600, timeavailable / 3600), 'link': None }) return self.jsonify(msgs) self.setAbort(404)