def _generate_private(self): if self.__dict__.has_key('private'): QTools.qassert(type(self.__dict__['private']) == list) self.__dict__['data'] = {} for key in self.private: QTools.qassert(type(key) == str) self.__dict__['data'][key] = None
def __init__(self, print_method, remind_interval=None): threading.Thread.__init__(self) self.lock = QLock.QLock() self.lock.set_name('e300') self.lock.set_pid() QTools.qassert(callable(print_method)) self.set_remind_interval(remind_interval) self.request_queue = Queue.Queue(256) self.response_queue = Queue.Queue(256) self.input = E300_RAW self.daemon = True self.state = 'init' self._print = print_method
def __init__(self, print_method, server): threading.Thread.__init__(self) QTools.qassert(callable(print_method)) self.request_queue = Queue.Queue(256) self.response_queue = Queue.Queue(256) self.clean_complete = threading.Condition() self.cleaning = False self.daemon = True self.running = False self.halting = False self._print = print_method self.server = server self.socket = None self.notifier = Notifier() self.id_counter = QTools.Counter(negatives=False, wrap=99999999) self.outstanding = {} self.applied = {} self.clean_requests = {}
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__())
def execute(self, action): QTools.qassert(isinstance(action, QAction.QAction)) try: action.execute(self.q330) except Quasar.QDPDevice.TimeoutException, ex: raise QTools.QExMessage(str(ex))
def set_forced(self, forced=True): QTools.qassert(forced in (True, False)) self.forced = forced
def set_verbosity(self, verbosity): QTools.qassert(type(verbosity) == type(int(1))) self.verbosity = verbosity
def add_option(self, option): QTools.qassert(type(option) == optparse.Option) self.option_list.append(option)
def _add_results(self, items): QTools.qassert(type(items) == list) self._result_data.extend(items)
def execute(self, q330): self._clear_results() QTools.qassert(isinstance(q330, Quasar.Q330.Q330)) if '_execute' not in dir(self): raise NotImplementedError("method _execute() is not implemented") self._execute(q330)