コード例 #1
0
ファイル: dial.py プロジェクト: EiNSTeiN-/leapcast
    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)
コード例 #2
0
 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)
コード例 #3
0
    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)
コード例 #4
0
ファイル: ssdp.py プロジェクト: EdShaw/leapcast
 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)
コード例 #5
0
ファイル: leap.py プロジェクト: Rijkaard14/leapcast
 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)
コード例 #6
0
ファイル: ssdp.py プロジェクト: StephenFluin/leapcast
 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)
コード例 #7
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
    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()
コード例 #8
0
    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()
コード例 #9
0
ファイル: leap.py プロジェクト: EdShaw/leapcast
    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()
コード例 #10
0
ファイル: leap.py プロジェクト: tylerwhall/leapcast
    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()
コード例 #11
0
ファイル: leap_factory.py プロジェクト: ywrt/leapcast
    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()
コード例 #12
0
ファイル: dial.py プロジェクト: noamtm/leapcast
 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
             )
         )
コード例 #13
0
ファイル: rest.py プロジェクト: wiplug/leapcast
 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))
コード例 #14
0
ファイル: leap_factory.py プロジェクト: ywrt/leapcast
 def _toXML(self, data):
     return render(self.service).substitute(data)
コード例 #15
0
 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)
コード例 #16
0
 def _toXML(self, data):
     return render(self.service).generate(**data)
コード例 #17
0
ファイル: leap.py プロジェクト: tylerwhall/leapcast
 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)
コード例 #18
0
ファイル: leap.py プロジェクト: tylerwhall/leapcast
 def _toXML(self, data):
     return render(self.service).substitute(data)
コード例 #19
0
ファイル: leap_factory.py プロジェクト: borna/leapcast
 def _toXML(self, data):
     return render(self.service).generate(**data)
コード例 #20
0
 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)