def get(self, path): try: uri = self.get_argument('uri') except: return self.shared_resource(path) try: data = get_plugin_info(uri) except: raise web.HTTPError(404) try: root = data['gui']['resourcesDirectory'] except: raise web.HTTPError(404) try: super(EffectResource, self).initialize(root) return super(EffectResource, self).get(path) except web.HTTPError as e: if e.status_code != 404: raise e return self.shared_resource(path) except IOError: raise web.HTTPError(404)
def get(self): uri = self.get_argument('uri') try: data = get_plugin_info(uri) except: raise HTTPError(404) self.set_header('Content-type', 'application/json') self.write(json.dumps(data))
def post(self): result = {} for uri in self.uris: try: info = get_plugin_info(uri) except: continue result[uri] = info self.set_header('Content-Type', 'application/json') self.write(json.dumps(result))
def get(self): uri = self.get_argument('uri') try: data = get_plugin_info(uri) except: print("ERROR in webserver.py: get_plugin_info for '%s' failed" % uri) raise web.HTTPError(404) self.set_header('Content-type', 'application/json') self.write(json.dumps(data)) self.finish()
def get(self): uri = self.get_argument('uri') try: data = get_plugin_info(uri) except: raise web.HTTPError(404) try: path = data['gui']['javascript'] except: raise web.HTTPError(404) if not os.path.exists(path): raise web.HTTPError(404) with open(path, 'rb') as fd: self.set_header('Content-type', 'text/javascript') self.write(fd.read())
def get(self, instance): uri = self.get_argument('uri') x = self.request.arguments.get('x', [0])[0] y = self.request.arguments.get('y', [0])[0] resp = yield gen.Task(SESSION.web_add, instance, uri, x, y) self.set_header('Content-type', 'application/json') if resp >= 0: try: data = get_plugin_info(uri) except: print("ERROR in webserver.py: get_plugin_info for '%s' failed" % uri) raise web.HTTPError(404) self.write(json.dumps(data)) else: self.write(json.dumps(False)) self.finish()
def get(self, image): uri = self.get_argument('uri') try: data = get_plugin_info(uri) except: raise web.HTTPError(404) try: path = data['gui'][image] except: path = None if path is None or not os.path.exists(path): try: path = DEFAULT_ICON_IMAGE[image] except: raise web.HTTPError(404) with open(path, 'rb') as fd: self.set_header('Content-type', 'image/png') self.write(fd.read())
def get(self, instance): uri = self.get_argument('uri') x = self.request.arguments.get('x', [0])[0] y = self.request.arguments.get('y', [0])[0] resp = yield gen.Task(SESSION.web_add, instance, uri, x, y) self.set_header('Content-type', 'application/json') if resp >= 0: try: data = get_plugin_info(uri) except: print( "ERROR in webserver.py: get_plugin_info for '%s' failed" % uri) raise web.HTTPError(404) self.write(json.dumps(data)) else: self.write(json.dumps(False)) self.finish()
def get(self, instance): uri = self.get_argument('uri') x = self.request.arguments.get('x', [0])[0] y = self.request.arguments.get('y', [0])[0] try: data = get_plugin_info(uri) except: raise web.HTTPError(404) res = yield gen.Task(SESSION.add, uri, instance, x, y) if self.request.connection.stream.closed(): return if res >= 0: #options['instance'] = res self.write(json.dumps(data)) else: self.write(json.dumps(False)) self.finish()
def address(self, instance, port, actuator_uri, label, maximum, minimum, value, steps, callback): instance_id = self.mapper.get_id(instance) old_actuator_uri = self._unaddress(instance, port) if (not actuator_uri) or actuator_uri == "null": self.hmi.control_rm(instance_id, port, callback) if old_actuator_uri is not None: old_actuator_hw = self._uri2hw_map[old_actuator_uri] self._address_next(old_actuator_hw) return data = self.instances.get(instance, None) if data is None: callback(False) return options = [] if port == ":bypass": ctype = ADDRESSING_CTYPE_BYPASS unit = "none" else: for port_info in get_plugin_info( data["uri"])["ports"]["control"]["input"]: if port_info["symbol"] != port: continue break else: callback(False) return pprops = port_info["properties"] unit = port_info["units"]["symbol"] if "symbol" in port_info[ "units"] else "none" if "toggled" in pprops: ctype = ADDRESSING_CTYPE_TOGGLED elif "integer" in pprops: ctype = ADDRESSING_CTYPE_INTEGER else: ctype = ADDRESSING_CTYPE_LINEAR if "logarithmic" in pprops: ctype |= ADDRESSING_CTYPE_LOGARITHMIC if "trigger" in pprops: ctype |= ADDRESSING_CTYPE_TRIGGER if "tap_tempo" in pprops: # TODO ctype |= ADDRESSING_CTYPE_TAP_TEMPO if len(port_info["scalePoints"] ) >= 2: # and "enumeration" in pprops: ctype |= ADDRESSING_CTYPE_SCALE_POINTS | ADDRESSING_CTYPE_ENUMERATION if "enumeration" in pprops: ctype |= ADDRESSING_CTYPE_ENUMERATION for scalePoint in port_info["scalePoints"]: options.append((scalePoint["value"], scalePoint["label"])) del port_info, pprops addressing = { 'actuator_uri': actuator_uri, 'instance_id': instance_id, 'port': port, 'label': label, 'type': ctype, 'unit': unit, 'minimum': minimum, 'maximum': maximum, 'value': value, 'steps': steps, 'options': options, } self.instances[instance]['addressing'][port] = addressing self.addressings[actuator_uri]['addrs'].append(addressing) self.addressings[actuator_uri]['idx'] = len( self.addressings[actuator_uri]['addrs']) - 1 if old_actuator_uri is not None: self._addressing_load(old_actuator_uri) self._addressing_load(actuator_uri, callback)
def __init__(self): QMainWindow.__init__(self) gCarla.gui = self URI = sys.argv[1] # ---------------------------------------------------------------------------------------------------- # Internal stuff self.fCurrentFrame = None self.fDocElemement = None self.fCanSetValues = False self.fNeedsShow = False self.fSizeSetup = False self.fQuitReceived = False self.fWasRepainted = False self.fPlugin = get_plugin_info(URI) self.fPorts = self.fPlugin['ports'] self.fPortSymbols = {} self.fPortValues = {} for port in self.fPorts['control']['input'] + self.fPorts['control']['output']: self.fPortSymbols[port['index']] = port['symbol'] self.fPortValues [port['index']] = port['ranges']['default'] # ---------------------------------------------------------------------------------------------------- # Init pipe if len(sys.argv) == 7: self.fPipeClient = gCarla.utils.pipe_client_new(lambda s,msg: self.msgCallback(msg)) else: self.fPipeClient = None # ---------------------------------------------------------------------------------------------------- # Init Web server self.fWebServerThread = WebServerThread(self) self.fWebServerThread.start() # ---------------------------------------------------------------------------------------------------- # Set up GUI self.setContentsMargins(0, 0, 0, 0) self.fWebview = QWebView(self) #self.fWebview.setAttribute(Qt.WA_OpaquePaintEvent, False) #self.fWebview.setAttribute(Qt.WA_TranslucentBackground, True) self.setCentralWidget(self.fWebview) page = self.fWebview.page() page.setViewportSize(QSize(980, 600)) mainFrame = page.mainFrame() mainFrame.setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) mainFrame.setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) palette = self.fWebview.palette() palette.setBrush(QPalette.Base, palette.brush(QPalette.Window)) page.setPalette(palette) self.fWebview.setPalette(palette) settings = self.fWebview.settings() settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True) self.fWebview.loadFinished.connect(self.slot_webviewLoadFinished) url = "http://127.0.0.1:%s/icon.html#%s" % (PORT, URI) print("url:", url) self.fWebview.load(QUrl(url)) # ---------------------------------------------------------------------------------------------------- # Connect actions to functions self.SIGTERM.connect(self.slot_handleSIGTERM) # ---------------------------------------------------------------------------------------------------- # Final setup self.fIdleTimer = self.startTimer(30) if self.fPipeClient is None: # testing, show UI only self.setWindowTitle("TestUI") self.fNeedsShow = True
def __init__(self): QMainWindow.__init__(self) gCarla.gui = self URI = sys.argv[1] # ---------------------------------------------------------------------------------------------------- # Internal stuff self.fCurrentFrame = None self.fDocElemement = None self.fCanSetValues = False self.fNeedsShow = False self.fSizeSetup = False self.fQuitReceived = False self.fWasRepainted = False self.fPlugin = get_plugin_info(URI) self.fPorts = self.fPlugin['ports'] self.fPortSymbols = {} self.fPortValues = {} for port in self.fPorts['control']['input'] + self.fPorts['control'][ 'output']: self.fPortSymbols[port['index']] = port['symbol'] self.fPortValues[port['index']] = port['ranges']['default'] # ---------------------------------------------------------------------------------------------------- # Init pipe if len(sys.argv) == 7: self.fPipeClient = gCarla.utils.pipe_client_new( lambda s, msg: self.msgCallback(msg)) else: self.fPipeClient = None # ---------------------------------------------------------------------------------------------------- # Init Web server self.fWebServerThread = WebServerThread(self) self.fWebServerThread.start() # ---------------------------------------------------------------------------------------------------- # Set up GUI self.setContentsMargins(0, 0, 0, 0) self.fWebview = QWebView(self) #self.fWebview.setAttribute(Qt.WA_OpaquePaintEvent, False) #self.fWebview.setAttribute(Qt.WA_TranslucentBackground, True) self.setCentralWidget(self.fWebview) page = self.fWebview.page() page.setViewportSize(QSize(980, 600)) mainFrame = page.mainFrame() mainFrame.setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) mainFrame.setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) palette = self.fWebview.palette() palette.setBrush(QPalette.Base, palette.brush(QPalette.Window)) page.setPalette(palette) self.fWebview.setPalette(palette) settings = self.fWebview.settings() settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True) self.fWebview.loadFinished.connect(self.slot_webviewLoadFinished) url = "http://127.0.0.1:%s/icon.html#%s" % (PORT, URI) print("url:", url) self.fWebview.load(QUrl(url)) # ---------------------------------------------------------------------------------------------------- # Connect actions to functions self.SIGTERM.connect(self.slot_handleSIGTERM) # ---------------------------------------------------------------------------------------------------- # Final setup self.fIdleTimer = self.startTimer(30) if self.fPipeClient is None: # testing, show UI only self.setWindowTitle("TestUI") self.fNeedsShow = True
def address(self, instance, port, actuator_uri, label, maximum, minimum, value, steps, callback): instance_id = self.mapper.get_id(instance) old_actuator_uri = self._unaddress(instance, port) if (not actuator_uri) or actuator_uri == "null": self.hmi.control_rm(instance_id, port, callback) if old_actuator_uri is not None: old_actuator_hw = self._uri2hw_map[old_actuator_uri] self._address_next(old_actuator_hw) return data = self.instances.get(instance, None) if data is None: callback(False) return options = [] if port == ":bypass": ctype = ADDRESSING_CTYPE_BYPASS unit = "none" else: for port_info in get_plugin_info(data["uri"])["ports"]["control"]["input"]: if port_info["symbol"] != port: continue break else: callback(False) return pprops = port_info["properties"] unit = port_info["units"]["symbol"] if "symbol" in port_info["units"] else "none" if "toggled" in pprops: ctype = ADDRESSING_CTYPE_TOGGLED elif "integer" in pprops: ctype = ADDRESSING_CTYPE_INTEGER else: ctype = ADDRESSING_CTYPE_LINEAR if "logarithmic" in pprops: ctype |= ADDRESSING_CTYPE_LOGARITHMIC if "trigger" in pprops: ctype |= ADDRESSING_CTYPE_TRIGGER if "tap_tempo" in pprops: # TODO ctype |= ADDRESSING_CTYPE_TAP_TEMPO if len(port_info["scalePoints"]) >= 2: # and "enumeration" in pprops: ctype |= ADDRESSING_CTYPE_SCALE_POINTS|ADDRESSING_CTYPE_ENUMERATION if "enumeration" in pprops: ctype |= ADDRESSING_CTYPE_ENUMERATION for scalePoint in port_info["scalePoints"]: options.append((scalePoint["value"], scalePoint["label"])) del port_info, pprops addressing = { 'actuator_uri': actuator_uri, 'instance_id': instance_id, 'port': port, 'label': label, 'type': ctype, 'unit': unit, 'minimum': minimum, 'maximum': maximum, 'value': value, 'steps': steps, 'options': options, } self.instances[instance]['addressing'][port] = addressing self.addressings[actuator_uri]['addrs'].append(addressing) self.addressings[actuator_uri]['idx'] = len(self.addressings[actuator_uri]['addrs']) - 1 if old_actuator_uri is not None: self._addressing_load(old_actuator_uri) self._addressing_load(actuator_uri, callback)