def get_device(self, device_name):
        """ get the device ip address """

        host = None
        dummy = None

        is_ip_addr = device_name is not None and re.match(
            "[0-9]+.[0-9]+.[0-9]+.[0-9]+$", device_name) is not None

        if is_ip_addr:
            host = device_name
            try:
                #print "ip_addr:", host.encode('utf-8'), "device name:", cc_device_finder.get_device_name(host).encode('utf-8')
                print >> sys.stderr, "ip_addr:", host.encode(
                    'utf-8'), "device name:", cc_device_finder.get_device_name(
                        host).encode('utf-8')

            except socket.error:
                sys.exit("No Chromecast found on ip:" + host)
        else:
            host, name = cc_device_finder.find_device(name=device_name)
            if host is None:
                sys.exit("No Chromecast found on the network")

            #print "device name:", name
            print >> sys.stderr, "device name:", name
        return host
    def get_device(self, device_name):
        """ get the device ip address """

        is_ip_addr = device_name is not None and re.match("[0-9]+.[0-9]+.[0-9]+.[0-9]+$", device_name) is not None

        if is_ip_addr:
            host = device_name
            try:
                print "ip_addr:", host, "device name:", cc_device_finder.get_device_name(host)
            except socket.error:
                sys.exit("No Chromecast found on ip:" + host)
        else:
            host, name = cc_device_finder.find_device(name=device_name)
            if host is None:
                sys.exit("No Chromecast found on the network")

            print "device name:", name

        return host
예제 #3
0
    def get_device(self, device_name):
        """ get the device ip address """

        host = None

        is_ip_addr = device_name is not None and re.match(
            "[0-9]+.[0-9]+.[0-9]+.[0-9]+$", device_name) is not None

        if is_ip_addr:
            host = device_name
            try:
                print("ip_addr: " + host + " device name: " +
                      cc_device_finder.get_device_name(host))
            except socket.error:
                sys.exit("No Chromecast found on ip:" + host)
        else:
            host, name = cc_device_finder.find_device(name=device_name)
            if host is None:
                sys.exit("No Chromecast found on the network")

            print("device name:", name)

        return host