Esempio n. 1
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'gte', 1)

        arg_device_id = self.args[0]
        self.comm.set_from_file(arg_device_id, self.options.reg_file)

        if self.options.address:
            self.comm.set_address(self.options.address)
        if self.options.port:
            self.comm.set_port(self.options.port)

        
        action = QPing.QPing(self.comm.get_device_type(), self.options.show_restricted, self.options.show_unavailable)
        try:
            if self.options.detect:
                action.action = 'detect'
            elif self.options.info:
                action.action = 'info'
            elif len(self.args) > 1:
                action.action = 'status'
                action.status = self.args[1:]
            else:
                action.action = 'monitor'
        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())
Esempio n. 2
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'eq', 0)

        target_address = None
        if self.options.address:
            target_address = self.options.address

        target_host = '255.255.255.255'
        if self.options.target_host:
            target_host = self.options.target_host
        port = 5330
        if self.options.port:
            port = self.options.port
        self.comm.set_address(target_host)
        self.comm.set_port(port)
        action = QPoll.QPoll()
        self.comm.execute(action)


        for response in action.get_result_data():
            (ip, port) = response.getSourceIPAddressInfo()
            if not target_address or (target_address == ip):
                print "Q330 [%s]:" % str(response.getKMIPropertyTag())
                print "    S/N:  %X" % response.getSerialNumber()
                print "    IP:   %s" % ip
                print "    Port: %s" % port
                print
Esempio n. 3
0
    def _run_start(self):
        QTools.assert_arg_count(self.args, "gte", 9)
        QTools.assert_arg_count(self.args, "lte", 10)

        try:
            int(self.args[0])
            arg_device_id = self.args[0]
        except:
            raise QTools.QExArgs("invalid type for argument 'device'")
        if not self.comm.set_from_file(arg_device_id, self.options.reg_file):
            raise QTools.QExArgs("invalid entry for Q330 #%d in configuration" % int(arg_device_id))

        e300_type = None
        if self.options.e300_raw:
            if e300_type:
                raise QTools.QExArgs("You may only specify one of: --e300-raw | --e300-velocity | --e300-acceleration")
            e300_type = E300.E300_RAW

        if self.options.e300_velocity:
            if e300_type:
                raise QTools.QExArgs("You may only specify one of: --e300-raw | --e300-velocity | --e300-acceleration")
            e300_type = E300.E300_VELOCITY

        if self.options.e300_acceleration:
            if e300_type:
                raise QTools.QExArgs("You may only specify one of: --e300-raw | --e300-velocity | --e300-acceleration")
            e300_type = E300.E300_ACCELERATION

        e300_remind_interval = None
        if self.options.e300_remind_interval:
            e300_remind_interval = self.options.e300_remind_interval

        try:
            arg_wave_form = self.args[7]
            action = QCal.QCal(arg_wave_form)
            action.channels = self.args[1]
            action.cal_monitor = self.args[2]
            action.amplitude = self.args[3]
            action.settle = self.args[4]
            action.duration = self.args[5]
            action.trailer = self.args[6]
            # self.args[10] <-- wave_form; set on QCal class instantiation
            if action.wave_form == "sine":
                QTools.assert_arg_count(self.args, "eq", 9)
                action.frequency = self.args[8]
            elif action.wave_form == "step":
                QTools.assert_arg_count(self.args, "eq", 9)
                action.polarity = self.args[8]
            elif action.wave_form == "random":
                QTools.assert_arg_count(self.args, "eq", 10)
                action.frequency = self.args[8]
                action.noise = self.args[9]
            action.coupling = "R"
            if self.options.capacitive:
                action.coupling = "C"
        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())
Esempio n. 4
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'eq', 1)

        arg_device_id = self.args[0]
        self.comm.set_from_file(arg_device_id, self.options.reg_file)

        action = QAuth.QAuth()
        try:
            if self.options.file:
                action.file = self.options.file
        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())
Esempio n. 5
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'gt', 1)

        arg_device_id = self.args[0]
        self.comm.set_from_file(arg_device_id, self.options.reg_file)

        arg_sections = self.args[1:]
        action = QView.QView()
        try:
            action.sections = arg_sections
        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())
Esempio n. 6
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'eq', 1)

        try:
            arg_device_id = self.args[0]
        except:
            raise QTools.QExArgs("invalid type for argument 'device'")
        if not self.comm.set_from_file(arg_device_id, self.options.reg_file):
            raise QTools.QExArgs("invalid entry for Q330 #%d in configuration" % int(arg_device_id))

        action = QReboot.QReboot()

        self.comm.register()
        self.comm.execute(action)
Esempio n. 7
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'eq', 2)

        try:
            arg_device_id = self.args[0]
        except:
            raise QTools.QExArgs("invalid type for argument 'device'")
        if not self.comm.set_from_file(arg_device_id, self.options.reg_file):
            raise QTools.QExArgs("invalid entry for Q330 #%d in configuration" % int(arg_device_id))

        action = QGps.QGps()
        try:
            action.action = self.args[1]
        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())
Esempio n. 8
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'eq', 2)

        arg_device_id = self.args[0]
        self.comm.set_from_file(arg_device_id, self.options.reg_file)

        arg_channels = self.args[1]
        action = QQuickView.QQuickView()

        if self.options.verbosity:
            action.verbosity = self.options.verbosity
        try:
            action.channels = arg_channels
        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())
Esempio n. 9
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'eq', 3)

        try:
            arg_device_id = self.args[0]
        except:
            raise QTools.QExArgs("invalid type for argument 'device'")
        if not self.comm.set_from_file(arg_device_id, self.options.reg_file):
            raise QTools.QExArgs("invalid entry for Q330 #%d in configuration" % int(arg_device_id))

        try:
            action = QConfig.QConfig()
            action.action = self.args[1]
            action.type   = self.args[2]
            if self.options.offset:
                action.offset = self.options.offset
            if self.options.bytes:
                action.bytes  = self.options.bytes
        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())
Esempio n. 10
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'gt', 2)
        arg_device_id = self.args[0]
        try:
            int(arg_device_id)
        except:
            raise QTools.QExArgs("invalid type for argument 'device'")
        if not self.comm.set_from_file(arg_device_id, self.options.reg_file):
            raise QTools.QExArgs("invalid entry for Q330 #%d in configuration" % int(arg_device_id))

        arg_interface = self.args[1]
        arg_action    = self.args[2]
        arg_timeout   = 1

        if self.args[2] == 'off':
            QTools.assert_arg_count(self.args, 'eq', 3)
        else:
            QTools.assert_arg_count(self.args, 'eq', 4)
            arg_timeout = self.args[3]

        try:
            action = QBaler.QBaler()
            action.interface = arg_interface
            action.action    = arg_action
            action.timeout   = arg_timeout
            action.verbosity = self.options.verbosity
        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())
Esempio n. 11
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'gte', 1)

        arg_device_id = self.args[0]
        self.comm.set_from_file(arg_device_id, self.options.reg_file)

        arg_status = ['Detect']
        if self.options.address:
            self.comm.set_address(self.options.address)
        if self.options.port:
            self.comm.set_port(self.options.port)
        if self.options.info:
            arg_status = ['info']

        if len(self.args) > 1:
            arg_status = self.args[1:]

        arg_delay = 3 # 3 second default delay
        if self.options.delay:
            QTools.qassert(type(arg_delay) in (int, long))
            arg_delay = self.options.delay

        action = QPing.QPing(self.comm.get_device_type(), self.options.show_restricted, self.options.show_unavailable)
        try:
            if 'all' in arg_status:
                raise ValueError('status')
            if arg_status is not None:
                if 'Detect' in arg_status:
                    action.action = 'detect'
                elif 'info' in map(lambda a: a.lower(), arg_status):
                    action.action = 'info'
                else:
                    action.action = 'status'
                    action.status = arg_status
            else:
                action.action = 'monitor'
        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())
Esempio n. 12
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'eq', 2)

        try:
            arg_device_id = self.args[0]
        except:
            raise QTools.QExArgs("invalid type for argument 'device'")
        if not self.comm.set_from_file(arg_device_id, self.options.reg_file):
            raise QTools.QExArgs("invalid entry for Q330 #%d in configuration" % int(arg_device_id))

        try:
            action = QModule.QModule()
            action.action = self.args[1]

            if self.options.module_file:
                action.module_file = self.options.module_file
            elif action.action == 'install':
                module_file = ""
                while not os.path.isfile(module_file):
                    module_file = raw_input("core module file: ")
                action.module_file = module_file

        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())
Esempio n. 13
0
    def _run(self):
        QTools.assert_arg_count(self.args, 'gte', 1)

        arg_count = 3
        if self.args[0] == 'indices':
            print "Section Indices:"
            for value in sorted(Profile.section_map.values()):
                index,_,description,_,_ = value
                print "  % 3d : %s" % (index, description)
            return
        elif self.args[0] == 'list':
            QTools.assert_arg_count(self.args, 'eq', 2)
            config_file = self.args[1]
            print "Reading clone from %s ..." % os.path.abspath(config_file)
            profile = Profile.getProfileFromFile(config_file)
            profile.listFileContents()
            return
        elif self.args[0] == 'diff':
            QTools.assert_arg_count(self.args, 'eq', 3)
            file1 = self.args[1]
            file2 = self.args[2]

            print "Reading configuration from %s..." % file1,
            sys.stdout.flush()
            try:
                profile1 = Profile.getProfileFromFile(file1)
            except:
                print "Failed!"
                return
            print "Done."

            print "Reading configuration from %s..." % file2,
            sys.stdout.flush()
            try:
                profile2 = Profile.getProfileFromFile(file2)
            except:
                print "Failed!"
                return
            print "Done."
            profile1.diff(profile2)
            return

        if (len(self.args) > 1) and (self.args[1] == 'edit'):
            arg_count = 2

        QTools.assert_arg_count(self.args, 'eq', arg_count)
        arg_device_id = self.args[0]
        try:
            int(arg_device_id)
        except:
            raise QTools.QExArgs("invalid type for argument 'device'")
        if not self.comm.set_from_file(arg_device_id, self.options.reg_file):
            raise QTools.QExArgs("invalid entry for Q330 #%d in configuration" % int(arg_device_id))

        config_count   = 0
        config_type    = ''
        config_subset  = None
        mysql_password = ''
        if self.options.subset and len(self.options.subset):
            try:
                config_subset = QTools.expand_int_list_set(self.options.subset)
            except ValueError:
                raise QTools.QExArgs("invalid value(s) for option '--subset'")
        if self.options.config_file:
            config_info = self.options.config_file
            config_type = 'file'
            config_count += 1
        if self.options.config_sqlite:
            if not Store.SQLITE:
                raise QTools.QExMessage("SQLite support is not included with this python install")
            config_info = self.options.config_sqlite
            config_type = 'sqlite'
            config_count += 1
        if self.options.config_mysql:
            if not Store.MYSQL:
                raise QTools.QExMessage("MySQL support is not included with this python install")
            config_info = self.options.config_mysql
            config_type = 'mysql'
            config_count += 1
        if self.options.config_text:
            config_info = self.options.config_text
            config_type = 'text'
            config_count += 1
        if self.options.mysql_passwd:
            mysql_password = self.options.mysql_passwd

        try:
            action = QClone.QClone()
            action.action = self.args[1]
            if action.action != "edit":
                action.file = self.args[2]
            action.subset    = config_subset
            action.verbosity = self.options.verbosity
            action.mysql_password = mysql_password
            if self.options.max_tries:
                action.tries = self.options.max_tries
            if self.options.force:
                action.confirm = False
            if config_count > 1:
                raise QTools.QExArgs("You may only select one of --config-[file|sqlite|mysql|text]")
            elif config_count == 1:
                action.config = (config_type, config_info)
            if self.options.write_base_port:
                action.write_base_port = True
            if self.options.write_ethernet_ip_address:
                action.write_ethernet_ip_address = True
            if self.options.write_ethernet_mac_address:
                action.write_ethernet_mac_address = True
            if self.options.write_slave_processor_parameters:
                action.write_slave_processor_parameters = True
            if self.options.write_web_page:
                action.write_web_page = True
        except TypeError, msg:
            raise QTools.QExArgs("invalid type for argument '%s'" % msg.__str__())