Пример #1
0
    def discoverReceiver(self):
        receivers = eISCP.discover(timeout=1)
        receiver = receivers[0]
        return receiver  
        
 
                
Пример #2
0
def discovery(timeout=3):
    avrs = eISCP.discover(timeout)
    for avr in avrs:
        client.addDevice("%s:%s" % (avr.host, avr.port), "avreceiver")
Пример #3
0
def discovery(timeout=3):
	avrs = eISCP.discover(timeout)
	for avr in avrs:
		client.addDevice("%s:%s" % (avr.host, avr.port), "avreceiver")
Пример #4
0
def main(argv=sys.argv):
    basename = os.path.basename(argv[0])
    options = docopt.docopt(__doc__, help=True)

    # List commands
    if options['--discover']:
        for receiver in eISCP.discover(timeout=1):
            print '%s %s:%s' % (receiver.info['model_name'], receiver.host,
                                receiver.port)
        return

    # List available commands
    if options['--help-commands']:
        # List the zones
        if not options['<zone>']:
            print 'Available zones:'
            for zone in commands.COMMANDS:
                print '  %s' % zone
            print 'Use %s --help-commands <zone> to see a list of '\
                  'commands for that zone.' % basename
            return
        # List the commands
        selected_zone = options['<zone>']
        if not selected_zone in commands.COMMANDS:
            print 'No such zone: %s' % selected_zone
            return 1
        if not options['<command>']:
            print 'Available commands for this zone:'
            for _, command in commands.COMMANDS[selected_zone].items():
                print '  %s - %s' % (command['name'], command['description'])
            print 'Use %s --help-commands %s <command> to see a list '\
                  'of possible values.' % (basename, selected_zone)
            return
        # List values
        selected_command = options['<command>'][0]
        selected_command = commands.COMMAND_MAPPINGS[selected_zone].get(
            selected_command, selected_command)
        if not selected_command in commands.COMMANDS[selected_zone]:
            print 'No such command in zone: %s' % selected_command
            return 1
        print 'Possible values for this command:'
        cmddata = commands.COMMANDS[selected_zone][selected_command]
        for range, value in cmddata['values'].items():
            print '  %s - %s' % (value['name'], value['description'])
        return

    # Determine the receivers the command should run on
    if options['--host']:
        receivers = [eISCP(options['--host'], int(options['--port']))]
    else:
        receivers = eISCP.discover(timeout=1)
        if not options['--all']:
            if options['--name']:
                receivers = [
                    r for r in receivers
                    if options['--name'] in r.info['model_name']
                ]
            else:
                receivers = receivers[:1]
        if not receivers:
            print 'No receivers found.'
            return 1

    # List of commands to execute - deal with special shortcut case
    to_execute = options['<command>']

    # Execute commands
    for receiver in receivers:
        with receiver:
            for command in to_execute:
                if command.isupper() and command.isalnum():
                    iscp_command = command
                    raw_response = True
                else:
                    try:
                        iscp_command = command_to_iscp(command)
                    except ValueError, e:
                        print 'Error:', e
                        return 2
                    raw_response = False

                print '%s: %s' % (receiver, iscp_command)
                response = receiver.raw(iscp_command)
                if not raw_response:
                    response = iscp_to_command(response)
                print response
Пример #5
0
def main(argv=sys.argv):
    basename = os.path.basename(argv[0])
    options = docopt.docopt(__doc__, help=True)

    # List commands
    if options['--discover']:
        for receiver in eISCP.discover(timeout=1):
            print "%s %s:%s" % (
                receiver.info['model_name'], receiver.host, receiver.port)
        return

    # List available commands
    if options['--help-commands']:
        # List the zones
        if not options['<zone>']:
            print "Available zones:"
            for zone in commands.COMMANDS:
                print "  %s" % zone
            print "Use %s --help-commands <zone> to see a list of "\
                  "commands for that zone." % basename
            return
        # List the commands
        selected_zone = options['<zone>']
        if not selected_zone in commands.COMMANDS:
            print 'No such zone: %s' % selected_zone
            return 1
        if not options['<command>']:
            print 'Available commands for this zone:'
            for _, command in commands.COMMANDS[selected_zone].items():
                print "  %s - %s" % (command['name'], command['description'])
            print "Use %s --help-commands %s <command> to see a list "\
                  "of possible values." % (basename, selected_zone)
            return
        # List values
        selected_command = options['<command>'][0]
        selected_command = commands.COMMAND_MAPPINGS[selected_zone].get(
            selected_command, selected_command)
        if not selected_command in commands.COMMANDS[selected_zone]:
            print 'No such command in zone: %s' % selected_command
            return 1
        print 'Possible values for this command:'
        cmddata = commands.COMMANDS[selected_zone][selected_command]
        for range, value in cmddata['values'].items():
            print "  %s - %s" % (value['name'], value['description'])
        return

    # Determine the receivers the command should run on
    if options['--host']:
        receivers = [eISCP(options['--host'], int(options['--port']))]
    else:
        receivers = eISCP.discover(timeout=1)
        if not options['--all']:
            if options['--name']:
                receivers = [r for r in receivers
                             if options['--name'] in r.info['model_name']]
            else:
                receivers = receivers[:1]
        if not receivers:
            print "No receivers found."
            return 1

    # List of commands to execute - deal with special shortcut case
    to_execute = options['<command>']

    # Execute commands
    for receiver in receivers:
        with receiver:
            for command in to_execute:
                if command.isupper() and command.isalnum():
                    iscp_command = command
                    raw_response = True
                else:
                    try:
                        iscp_command = command_to_iscp(command)
                    except ValueError, e:
                        print "Error:", e
                        return 2
                    raw_response = False

                print '%s: %s' % (receiver, iscp_command)
                response = receiver.raw(iscp_command)
                if not raw_response:
                    response = iscp_to_command(response)
                print response