def get(self, module=None): if Environment.ips and self.request.remote_ip not in Environment.ips: raise tornado.web.HTTPError(403) if module == "eureka_info": self.set_header( "Access-Control-Allow-Headers", "Content-Type") self.set_header( "Access-Control-Allow-Origin", "https://cast.google.com") self.set_header("Content-Type", "application/json") if 'sign' in self.request.query: name = 'Chromecast8991' signData = self.sign_data else: name = Environment.friendlyName signData = '' self.write(render(self.status).generate( name=name, friendlyName=Environment.friendlyName, buildVersion='leapcast %s' % leapcast.__version__, signData=signData, uuid=Environment.uuid) ) elif module == "supported_timezones": self.set_header("Content-Type", "application/json") self.write(self.timezones) elif module == "supported_locales": self.set_header("Content-Type", "application/json") self.write(self.locales) elif module == "scan_results": self.set_header("Content-Type", "application/json") self.write(self.wifi_networks) else: raise tornado.web.HTTPError(404)
def datagramReceived(self, datagram, address): if "urn:dial-multiscreen-org:service:dial:1" in datagram and "M-SEARCH" in datagram: logging.debug("{} wrote:".format(address)) logging.debug(datagram) data = render(self.header).substitute( ip=self.get_remote_ip(address), uuid=Environment.uuid) self.reply(data, address)
def get(self, module=None): if Environment.ips and self.request.remote_ip not in Environment.ips: raise tornado.web.HTTPError(403) if module == "eureka_info": self.set_header("Access-Control-Allow-Headers", "Content-Type") self.set_header("Access-Control-Allow-Origin", "https://cast.google.com") self.set_header("Content-Type", "application/json") if 'sign' in self.request.query: name = 'Chromecast8991' signData = self.sign_data else: name = Environment.friendlyName signData = '' self.write( render(self.status).generate( name=name, friendlyName=Environment.friendlyName, buildVersion='leapcast %s' % leapcast.__version__, signData=signData, uuid=Environment.uuid)) elif module == "supported_timezones": self.set_header("Content-Type", "application/json") self.write(self.timezones) elif module == "supported_locales": self.set_header("Content-Type", "application/json") self.write(self.locales) elif module == "scan_results": self.set_header("Content-Type", "application/json") self.write(self.wifi_networks) else: raise tornado.web.HTTPError(404)
def datagramReceived(self, datagram, address): if "urn:dial-multiscreen-org:service:dial:1" in datagram and "M-SEARCH" in datagram: data = render(self.header).substitute( ip=self.get_remote_ip(address), uuid=Environment.uuid ) self.transport.write(data, address)
def launch(self, data): appurl = render(self.url).substitute(query=data) if not Environment.fullscreen: appurl = '--app="%s"' % appurl command_line = '''%s --incognito --no-first-run --kiosk --user-agent="%s" %s''' % ( Environment.chrome, Environment.user_agent, appurl) args = shlex.split(command_line) return subprocess.Popen(args)
def datagramReceived(self, datagram, address): if "urn:dial-multiscreen-org:service:dial:1" in datagram and "M-SEARCH" in datagram: logging.debug("{} wrote:".format(address)) logging.debug(datagram) data = render(self.header).substitute( ip=self.get_remote_ip(address), uuid=Environment.uuid ) self.reply(data, address)
def post(self, sec): '''Start app''' self.clear() self.set_status(201) self.set_header('Location', self._getLocation(self.get_name())) status = self.get_app_status() if status['browser'] is None: status['state'] = 'running' if self.url == "https://tv.pandora.com/cast?{{ query }}": appurl = render(self.url.replace("{{ query }}", self.request.body)).generate(query=self.request.body) else: appurl = render(self.url).generate(query=self.request.body) status['browser'] = Browser(appurl) status['connectionSvcURL'] = 'http://%s/connection/%s' % ( self.ip, self.get_name()) status['protocols'] = self.supported_protocols status['app'] = App.get_instance(sec) self.set_app_status(status) self.finish()
def post(self, sec): '''Start app''' self.clear() self.set_status(201) self.set_header('Location', self._getLocation(self.get_name())) status = self.get_app_status() if status['browser'] is None: status['state'] = 'running' if self.url == "https://tv.pandora.com/cast?{{ query }}": appurl = render( self.url.replace( "{{ query }}", self.request.body)).generate(query=self.request.body) else: appurl = render(self.url).generate(query=self.request.body) status['browser'] = Browser(appurl) status['connectionSvcURL'] = 'http://%s/connection/%s' % ( self.ip, self.get_name()) status['protocols'] = self.supported_protocols status['app'] = App.get_instance(sec) self.set_app_status(status) self.finish()
def post(self, sec): '''Start app''' self.clear() self.set_status(201) self.set_header('Location', self._getLocation(self.get_name())) status = self.get_app_status() if status['browser'] is None: status['state'] = 'running' status['link'] = '''<link rel='run' href='web-1'/>''' appurl = render(self.url).substitute(query=self.request.body) status['browser'] = Browser(appurl) status['connectionSvcURL'] = 'http://%s/connection/%s' % ( self.ip, self.get_name()) status['protocols'] = self.protocols status['app'] = App.get_instance(sec) self.set_app_status(status) self.finish()
def post(self, sec): '''Start app''' self.clear() self.set_status(201) self.set_header("Location", self._getLocation(self.get_name())) status = self.get_app_status() if status["browser"] is None: status["state"] = "running" status["link"] = '''<link rel="run" href="web-1"/>''' appurl = render(self.url).substitute(query=self.request.body) status["browser"] = self.browser(appurl) status["connectionSvcURL"] = "http://%s/connection/%s" % ( self.ip, self.get_name()) status["protocols"] = self.protocols status["app"] = App.get_instance(sec) self.set_app_status(status) self.finish()
def get(self): if self.request.uri == "/apps": for app, astatus in Environment.global_status.items(): if astatus["state"] == "running": self.redirect("/apps/%s" % app) self.set_status(204) self.set_header("Access-Control-Allow-Method", "GET, POST, DELETE, OPTIONS") self.set_header("Access-Control-Expose-Headers", "Location") else: self.set_header("Access-Control-Allow-Method", "GET, POST, DELETE, OPTIONS") self.set_header("Access-Control-Expose-Headers", "Location") self.add_header("Application-URL", "http://%s/apps" % self.request.host) self.set_header("Content-Type", "application/xml") self.write( render(self.device).generate( friendlyName=Environment.friendlyName, uuid=Environment.uuid, path="http://%s" % self.request.host ) )
def get(self): if self.request.uri == "/apps": for app, astatus in Environment.global_status.items(): if astatus["state"] == "running": self.redirect("/apps/%s" % app) self.set_status(204) self.set_header("Access-Control-Allow-Method", "GET, POST, DELETE, OPTIONS") self.set_header("Access-Control-Expose-Headers", "Location") else: self.set_header("Access-Control-Allow-Method", "GET, POST, DELETE, OPTIONS") self.set_header("Access-Control-Expose-Headers", "Location") self.add_header("Application-URL", "http://%s/apps" % self.request.host) self.set_header("Content-Type", "application/xml") self.write( render(self.device).generate( friendlyName=Environment.friendlyName, uuid=Environment.uuid, path="http://%s" % self.request.host))
def _toXML(self, data): return render(self.service).substitute(data)
def toInfo(cls): data = copy.deepcopy(cls.application_status) data['name'] = cls.__name__ data = Environment.global_status.get(cls.__name__, data) return render(cls.service).generate(data)
def _toXML(self, data): return render(self.service).generate(**data)
def toInfo(cls): data = copy.deepcopy(cls.application_status) data["name"] = cls.__name__ data = Environment.global_status.get(cls.__name__, data) return render(cls.service).substitute(data)
def datagramReceived(self, datagram, address): if "urn:dial-multiscreen-org:service:dial:1" in datagram and "M-SEARCH" in datagram: data = render(self.header).generate(ip=self.get_remote_ip(address), uuid=Environment.uuid) self.reply(data, address)