Exemple #1
0
    def start(self):
        #
        # Should I also call ConnectionMixin.start() and
        # EventProducerMixin.start()????
        ConfigurableNode.start(self)
        msg = ''
        _msg = ''

        # This node is a child of DirectPPP, which in turn is a child of a Port.
        self.port = self.parent.parent

        try:
            if self.enable:
                _msg = ('%s.%s did not start..\nReason\n' %
                        (str(self.parent.name), str(self.name)))
                self._enable_direct_ppp()
                self._start_ppp_program()
            else:
                _msg = ('Could not disable %s.%s ' %
                        (self.parent.name, self.name))
                self._disable_direct_ppp()
                self._start_ppp_program()

        except EPermission, e:
            msg += _msg
            msg += str(e.keywords['reason'])
Exemple #2
0
 def configure(self, config):
     ConfigurableNode.configure(self, config)
     message = ''
     if not (config.has_key('message') and config['message']):
         for var in self.variables:
             if message:
                 message += ', '
             message += '%s = ${%s}' % (var['vn'], var['vn'])
         set_attribute(self, 'message', message, {})
     else:
         set_attribute(self, 'message', REQUIRED, config)
     set_attribute(self, 'subject', '', config, str)
     set_attribute(self, 'send_retries', 3, config, int)
     set_attribute(self, 'enabled', 1, config, as_boolean)
     set_attribute(self, 'prodnode', '', config, str)
     set_attribute(self, 'eventmodule', '', config, str)
     set_attribute(self, 'eventclass', '', config, str)
     set_attribute(self, 'debug', 0, config, int)
     self._event_class = None
     # Try to import our specified event class.
     try:
         x = __import__(self.eventmodule, {}, {}, self.eventclass)
         self._event_class = eval('x.%s' % self.eventclass)
     except:
         msglog.log('broadway', msglog.types.WARN,
                    'Got exception trying to import event class.')
         msglog.exception()
     self._manager = self.parent.parent
    def configure(self, config):
        """method configure(): Called by MFW."""
        self.debug_print('Starting configuration...', 0)

        ConfigurableNode.configure(self, config)

        self.debug_print('Configuration complete.', 0)
Exemple #4
0
 def __init__(self, prop_type_id, prop_type_name, prop_inst_num, dev):
    ConfigurableNode.__init__(self)
    self._prop_type_id = prop_type_id
    self._prop_type_name = prop_type_name
    self._prop_inst_num = prop_inst_num
    self._dev = dev
    self.running = 0
Exemple #5
0
 def __init__(self):
     ConfigurableNode.__init__(self)
     self._url = 'unknown'
     self._poll_event = None
     self._period = 0.2
     # Pre-load attributes.
     self.off_text = "Off"
     self.on_text = "On"
     self.auto_text = "Auto"
     self.reverse_output = 0
     self.output = REQUIRED
     self.input = REQUIRED
     self.period = self._period
     self.asyncOK = 1
     self.state = 2
     self.debug = 0
     self.__running = False
     self._init_debug()
     self.OFF = EnumeratedValue(0, self.off_text)
     self.ON = EnumeratedValue(1, self.on_text)
     self.AUTO = EnumeratedValue(2, self.auto_text)
     self._NORMAL = 0
     self._SAFETY = 1
     self._output_state = self._NORMAL
     self._output_lock = Lock()
     self._changes_at = 0
     self._waiting_value = None
     self._value = None
     self._lock = Lock()
     return
Exemple #6
0
 def start( self ):
     #
     # Should I also call ConnectionMixin.start() and 
     # EventProducerMixin.start()????
     ConfigurableNode.start( self )
     msg = ''
     _msg = ''
     
     # This node is a child of DirectPPP, which in turn is a child of a Port.
     self.port = self.parent.parent
     
     try:
         if self.enable:
             _msg =  ( '%s.%s did not start..\nReason\n'
                       % (str( self.parent.name ), str( self.name )) )
             self._enable_direct_ppp()
             self._start_ppp_program()
         else:
             _msg = ( 'Could not disable %s.%s ' 
                      % (self.parent.name, self.name) )
             self._disable_direct_ppp()    
             self._start_ppp_program()
             
     except EPermission, e:
         msg += _msg
         msg += str( e.keywords['reason'] )
Exemple #7
0
 def __init__(self, parent):
     self.__parent = parent
     self.__cov_count = 0
     self._old_value = None
     ConfigurableNode.__init__(self)
     EventProducerMixin.__init__(self)
     return
Exemple #8
0
 def __init__( self ):
     ConfigurableNode.__init__( self )
     EventProducerMixin.__init__( self )
     #
     # Set old value to something which will never be valid so that
     # we always generate an event on startup.
     self.old_value = -99
Exemple #9
0
 def configure(self,config):
     ConfigurableNode.configure(self, config)
     message = ''
     if not (config.has_key('message') and config['message']):
         for var in self.variables:
             if message:
                 message += ', '
             message += '%s = ${%s}' % (var['vn'],var['vn'])
         set_attribute(self, 'message', message, {})
     else:
         set_attribute(self, 'message', REQUIRED, config)
     set_attribute(self, 'subject', '', config, str)
     set_attribute(self, 'send_retries', 3, config, int)
     set_attribute(self, 'enabled', 1, config, as_boolean)
     set_attribute(self, 'prodnode', '', config, str)
     set_attribute(self, 'eventmodule', '', config, str)
     set_attribute(self, 'eventclass', '', config, str)
     set_attribute(self, 'debug', 0, config, int)
     self._event_class = None
      # Try to import our specified event class.
     try:
         x = __import__(self.eventmodule, {}, {}, self.eventclass)
         self._event_class = eval('x.%s' % self.eventclass)
     except:
         msglog.log('broadway',msglog.types.WARN,
                    'Got exception trying to import event class.')
         msglog.exception()
     self._manager = self.parent.parent
Exemple #10
0
 def __init__(self):
     ConfigurableNode.__init__(self)
     self._url = 'unknown'
     self._poll_event = None
     self._period = 0.2
     # Pre-load attributes.
     self.off_text = "Off"
     self.on_text = "On"
     self.auto_text = "Auto"
     self.reverse_output = 0
     self.output = REQUIRED
     self.input = REQUIRED
     self.period = self._period
     self.asyncOK = 1
     self.state = 2
     self.debug = 0
     self.__running = False
     self._init_debug()
     self.OFF = EnumeratedValue(0, self.off_text)
     self.ON = EnumeratedValue(1, self.on_text)
     self.AUTO = EnumeratedValue(2, self.auto_text)
     self._NORMAL = 0
     self._SAFETY = 1
     self._output_state = self._NORMAL
     self._output_lock = Lock()
     self._changes_at = 0
     self._waiting_value = None
     self._value = None
     self._lock = Lock()
     return
Exemple #11
0
 def __init__(self, parent):
     self.__parent = parent
     self.__cov_count = 0
     self._old_value = None
     ConfigurableNode.__init__(self)
     EventProducerMixin.__init__(self)
     return
Exemple #12
0
 def configure(self, config):
     set_attribute(self, 'enable', 0, config, int)
     set_attribute(self, 'user_id', '', config)
     set_attribute(self, 'password', '', config)
     set_attribute(self, 'local_ip', '', config)
     set_attribute(self, 'client_ip', '', config)
     set_attribute(self, 'debug', 0, config, int)
     ConfigurableNode.configure(self, config)
Exemple #13
0
 def configure( self, config ):
     set_attribute( self, 'enable', 0, config, int )   
     set_attribute( self, 'user_id', '', config )   
     set_attribute( self, 'password', '', config )   
     set_attribute( self, 'local_ip', '', config )   
     set_attribute( self, 'client_ip', '', config )   
     set_attribute( self, 'debug', 0, config, int )         
     ConfigurableNode.configure( self, config )
Exemple #14
0
 def __init__(self):
     ConfigurableNode.__init__(self)
     EventProducerMixin.__init__(self)
     EventConsumerMixin.__init__(self)
     self._current_id = None
     self._event_class = None
     self.start_counter = 0
     self.pnode_obj = None
     self.pnode_subscribed = 0
Exemple #15
0
 def prune(self, force=False):
     ConfigurableNode.prune(self, force)
     new_value = ENoSuchNode(self._pruned_url)
     self._value = new_value
     cov = ChangeOfValueEvent(self, self._old_value, new_value,
                              time.time())
     self._old_value = new_value
     self.event_generate(cov)
     return
Exemple #16
0
 def __init__(self):
     ConfigurableNode.__init__(self)
     EventProducerMixin.__init__(self)
     EventConsumerMixin.__init__(self)
     self._current_id = None
     self._event_class = None
     self.start_counter = 0
     self.pnode_obj = None
     self.pnode_subscribed = 0
Exemple #17
0
    def configure(self, config):
        """method configure(): Called by MFW."""
        self.debug_print('Starting configuration...', 0)

        ConfigurableNode.configure(self, config) # includes addition of "parent" attr

        self._port = self.parent

        self.debug_print('Configuration complete.', 0)
Exemple #18
0
 def __init__( self ):
     ConfigurableNode.__init__( self )
     self.isRunning = 0
     self.ipcheck_pid = 0
     self._lock = Lock()
     self.thread = None
     self.first_time = 0
     self.log_name = 'broadway'
     self.update_count = 0
Exemple #19
0
 def start(self):
     self.DEBUG3("start():\n")
     ConfigurableNode.start(self)
     self.__running = True
     self._begin_critical_section()
     try: self._poll_input()
     finally: self._end_critical_section()
     self.DEBUG3("start: return\n")
     return
Exemple #20
0
 def prune(self, force=False):
     ConfigurableNode.prune(self, force)
     new_value = ENoSuchNode(self._pruned_url)
     self._value = new_value
     cov = ChangeOfValueEvent(self, self._old_value, new_value,
                              time.time())
     self._old_value = new_value
     self.event_generate(cov)
     return
Exemple #21
0
 def stop(self):
     self.DEBUG3("stop():\n")
     ConfigurableNode.stop(self)
     self.__running = False
     self._begin_critical_section()
     try: self._cancel_polling()
     finally: self._end_critical_section()
     self.DEBUG3("stop: return\n")
     return
Exemple #22
0
 def configure( self, config_dict ):     
     ConfigurableNode.configure( self, config_dict )
     set_attribute( self, 'enable', 0, config_dict, int )
     set_attribute( self, 'debug', 0, config_dict, int )
     
     set_attribute( self, 'ddns_service', 0, config_dict )
     set_attribute( self, 'ddns_acct', 0, config_dict )
     set_attribute( self, 'ddns_pswd', 0, config_dict )
     set_attribute( self, 'host_name', 0, config_dict )
     map_to_attribute( self, 'period', 0, config_dict, map_to_seconds )
Exemple #23
0
	def configure(self, config):
		"""method configure(): Called by MFW."""
		self.debug_print('Starting configuration...', 0)
		
		ConfigurableNode.configure(self, config) # includes addition of "parent" attr
		
		try:
			self.parent.open()
		except termios.error, details:
			print 'termios.error: %s.' % str(details)
Exemple #24
0
 def start(self):
     self.DEBUG3("start():\n")
     ConfigurableNode.start(self)
     self.__running = True
     self._begin_critical_section()
     try:
         self._poll_input()
     finally:
         self._end_critical_section()
     self.DEBUG3("start: return\n")
     return
Exemple #25
0
 def stop(self):
     self.DEBUG3("stop():\n")
     ConfigurableNode.stop(self)
     self.__running = False
     self._begin_critical_section()
     try:
         self._cancel_polling()
     finally:
         self._end_critical_section()
     self.DEBUG3("stop: return\n")
     return
Exemple #26
0
    def configure(self, config):
        """method configure(): Called by MFW."""
        self.debug_print('Starting configuration...', 0)

        ConfigurableNode.configure(
            self, config)  # includes addition of "parent" attr

        try:
            self.parent.open()
        except termios.error, details:
            print 'termios.error: %s.' % str(details)
Exemple #27
0
 def start(self):
     self.DEBUG3("start():\n")
     self.OFF.text(self.off_text)
     self.ON.text(self.on_text)
     self.AUTO.text(self.auto_text)
     ConfigurableNode.start(self)
     self.__running = True
     self._begin_critical_section()
     try: self._poll_input()
     finally: self._end_critical_section()
     self.DEBUG3("start: return\n")
     return
Exemple #28
0
 def start(self):
     self.DEBUG3("start():\n")
     self.OFF.text(self.off_text)
     self.ON.text(self.on_text)
     self.AUTO.text(self.auto_text)
     ConfigurableNode.start(self)
     self.__running = True
     self._begin_critical_section()
     try:
         self._poll_input()
     finally:
         self._end_critical_section()
     self.DEBUG3("start: return\n")
     return
Exemple #29
0
	def start(self):
		self.debug_print('Starting...', 0)
		ConfigurableNode.start(self)
		
		poll_obj = select.poll()
		poll_obj.register(self.parent.file.fileno(), select.POLLIN)
		
		count = 0
		while count < 10:
			evt_prs = poll_obj.poll()
			print 'Got event pair %s.' % evt_prs
			self.parent.file.read(1024)
			count = count + 1
			time.sleep(0.5)
Exemple #30
0
    def start(self):
        self.debug_print('Starting...', 0)
        ConfigurableNode.start(self)

        poll_obj = select.poll()
        poll_obj.register(self.parent.file.fileno(), select.POLLIN)

        count = 0
        while count < 10:
            evt_prs = poll_obj.poll()
            print 'Got event pair %s.' % evt_prs
            self.parent.file.read(1024)
            count = count + 1
            time.sleep(0.5)
    def configuration(self):
        config = ConfigurableNode.configuration(self)

        get_attribute(self, 'value', config, str)
        get_attribute(self, 'debug', config, str)
        get_attribute(self, '__node_id__', config)
        return config
Exemple #32
0
 def configuration(self):
     config = ConfigurableNode.configuration(self)
     
     get_attribute(self, 'value',config, str)
     get_attribute(self, 'debug',config, str)
     get_attribute(self, '__node_id__', config)
     return config
Exemple #33
0
 def configuration(self):
     config = ConfigurableNode.configuration(self)
     get_attribute(self, 'enable', config)
     get_attribute(self, 'user_id', config)
     get_attribute(self, 'password', config)
     get_attribute(self, 'local_ip', config)
     get_attribute(self, 'client_ip', config)
     get_attribute(self, 'debug', config)
     return config
Exemple #34
0
 def configuration(self):
     config = ConfigurableNode.configuration( self )
     get_attribute( self, 'enable', config )        
     get_attribute( self, 'user_id', config )        
     get_attribute( self, 'password', config )        
     get_attribute( self, 'local_ip', config )        
     get_attribute( self, 'client_ip', config )        
     get_attribute( self, 'debug', config )        
     return config
Exemple #35
0
 def configure(self, config):
     set_attribute(self, 'debug', self.debug, config, int)
     self._init_debug()
     self.DEBUG3("configure(%r):\n", config)
     ConfigurableNode.configure(self, config)
     self._url = as_node_url(self)
     if self.output is REQUIRED:
         self.output = self.parent
     set_attribute(self, 'output', self.parent, config, self.as_deferred_node)
     set_attribute(self, 'input', REQUIRED, config, self.as_deferred_node)
     set_attribute(self, 'period', self.period, config, float)
     set_attribute(self, 'asyncOK', self.asyncOK, config, int)
     # in cov mode, only changing values are driven.
     set_attribute(self, 'cov_mode', self.cov_mode, config, int)
     set_attribute(self, 'enabled', 1, config, as_boolean)
     set_attribute(self, 'backoff_on_failure', 0, config, as_boolean)
     set_attribute(self, 'conversion', self.conversion, config, str)
     self._period = self.period
     return
Exemple #36
0
 def configuration(self):
     config = ConfigurableNode.configuration(self)
     get_attribute(self, 'output', config, as_node_url)
     get_attribute(self, 'input', config, as_node_url)
     get_attribute(self, 'period', config, str)
     get_attribute(self, 'asyncOK', config, str)
     get_attribute(self, 'debug', config, str)
     get_attribute(self, 'enabled', config, str)
     get_attribute(self, 'backoff_on_failure', config, str)
     get_attribute(self, 'conversion', config, str)
     return config
Exemple #37
0
 def configuration(self):
     config = ConfigurableNode.configuration(self)
     get_attribute(self, 'message', config)
     get_attribute(self, 'subject', config)
     get_attribute(self, 'send_retries', config)
     get_attribute(self, 'enabled', config, str)
     get_attribute(self, 'prodnode', config, str)
     get_attribute(self, 'eventmodule', config, str)
     get_attribute(self, 'eventclass', config, str)
     get_attribute(self, 'debug', config, int)
     return config
Exemple #38
0
 def configure(self, config):
     set_attribute(self, 'debug', self.debug, config, int)
     self._init_debug()
     self.DEBUG3("configure(%r):\n", config)
     ConfigurableNode.configure(self, config)
     self._url = as_node_url(self)
     if self.output is REQUIRED:
         self.output = self.parent
     set_attribute(self, 'output', self.parent, config,
                   self.as_deferred_node)
     set_attribute(self, 'input', REQUIRED, config, self.as_deferred_node)
     set_attribute(self, 'period', self.period, config, float)
     set_attribute(self, 'asyncOK', self.asyncOK, config, int)
     # in cov mode, only changing values are driven.
     set_attribute(self, 'cov_mode', self.cov_mode, config, int)
     set_attribute(self, 'enabled', 1, config, as_boolean)
     set_attribute(self, 'backoff_on_failure', 0, config, as_boolean)
     set_attribute(self, 'conversion', self.conversion, config, str)
     self._period = self.period
     return
Exemple #39
0
 def configuration(self):
     config = ConfigurableNode.configuration(self)
     get_attribute(self, 'output', config, as_node_url)
     get_attribute(self, 'input', config, as_node_url)
     get_attribute(self, 'period', config, str)
     get_attribute(self, 'asyncOK', config, str)
     get_attribute(self, 'debug', config, str)
     get_attribute(self, 'enabled', config, str)
     get_attribute(self, 'backoff_on_failure', config, str)
     get_attribute(self, 'conversion', config, str)
     return config
Exemple #40
0
 def configuration(self):
     config = ConfigurableNode.configuration(self)
     get_attribute(self, 'message', config)
     get_attribute(self, 'subject', config)
     get_attribute(self, 'send_retries', config)
     get_attribute(self, 'enabled', config, str)
     get_attribute(self, 'prodnode', config, str)
     get_attribute(self, 'eventmodule', config, str)
     get_attribute(self, 'eventclass', config, str)
     get_attribute(self, 'debug', config, int)
     return config
Exemple #41
0
 def __init__(self):
     ConfigurableNode.__init__(self)
     self._url = 'unknown'
     self._poll_event = None
     self._period = 30
     # Pre-load attributes.
     self.output = REQUIRED
     self.input = REQUIRED
     self.period = self._period
     self.asyncOK = 1
     self.cov_mode = 0
     self.debug = 0
     self.conversion = 'none'
     self.__running = False
     self._thread_pool = ThreadPoolSingleton()
     self._init_debug()
     self._output_lock = Lock()
     self._changes_at = 0
     self._value = None
     self._lock = Lock()
     return
Exemple #42
0
 def configuration( self ):
     config_dict = ConfigurableNode.configuration( self )
     get_attribute( self, 'enable', config_dict )
     get_attribute( self, 'debug', config_dict )
     
     get_attribute( self, 'ddns_service', config_dict )
     get_attribute( self, 'ddns_acct', config_dict )
     get_attribute( self, 'ddns_pswd', config_dict )
     get_attribute( self, 'host_name', config_dict )
     map_from_attribute( self, 'period', config_dict, map_from_seconds )
     
     return config_dict
Exemple #43
0
 def __init__(self):
     ConfigurableNode.__init__(self)
     self._url = 'unknown'
     self._poll_event = None
     self._period = 30
     # Pre-load attributes.
     self.output = REQUIRED
     self.input = REQUIRED
     self.period = self._period
     self.asyncOK = 1
     self.cov_mode = 0
     self.debug = 0
     self.conversion = 'none'
     self.__running = False
     self._thread_pool = ThreadPoolSingleton()
     self._init_debug()
     self._output_lock = Lock()
     self._changes_at = 0
     self._value = None 
     self._lock = Lock()
     return
Exemple #44
0
 def configure(self, config):
     set_attribute(self, 'debug', self.debug, config, int)
     self._init_debug()
     self.DEBUG3("configure(%r):\n", config)
     # @fixme Add the option to output on change (default), output every
     #        time, or the check the outputs state.
     ConfigurableNode.configure(self, config)
     self._url = as_node_url(self)
     if self.output is REQUIRED:
         self.output = self.parent
     set_attribute(self, 'off_text', self.off_text, config, str)
     set_attribute(self, 'on_text', self.on_text, config, str)
     set_attribute(self, 'auto_text', self.auto_text, config, str)
     set_attribute(self, 'reverse_output', self.reverse_output, config, int)
     set_attribute(self, 'output', self.parent, config, self.as_deferred_node)
     set_attribute(self, 'input', REQUIRED, config, self.as_deferred_node)
     set_attribute(self, 'period', self.period, config, float)
     set_attribute(self, 'asyncOK', self.asyncOK, config, int)
     set_attribute(self, 'state', self.state, config, self._set_state)
     set_attribute(self, 'enabled', 1, config, as_boolean)
     set_attribute(self, 'min_on_time', 0, config, float)
     set_attribute(self, 'min_off_time', 0, config, float)
     return
Exemple #45
0
 def configure(self, config):
     set_attribute(self, 'debug', self.debug, config, int)
     self._init_debug()
     self.DEBUG3("configure(%r):\n", config)
     # @fixme Add the option to output on change (default), output every
     #        time, or the check the outputs state.
     ConfigurableNode.configure(self, config)
     self._url = as_node_url(self)
     if self.output is REQUIRED:
         self.output = self.parent
     set_attribute(self, 'off_text', self.off_text, config, str)
     set_attribute(self, 'on_text', self.on_text, config, str)
     set_attribute(self, 'auto_text', self.auto_text, config, str)
     set_attribute(self, 'reverse_output', self.reverse_output, config, int)
     set_attribute(self, 'output', self.parent, config,
                   self.as_deferred_node)
     set_attribute(self, 'input', REQUIRED, config, self.as_deferred_node)
     set_attribute(self, 'period', self.period, config, float)
     set_attribute(self, 'asyncOK', self.asyncOK, config, int)
     set_attribute(self, 'state', self.state, config, self._set_state)
     set_attribute(self, 'enabled', 1, config, as_boolean)
     set_attribute(self, 'min_on_time', 0, config, float)
     set_attribute(self, 'min_off_time', 0, config, float)
     return
Exemple #46
0
 def configuration(self):
     config = ConfigurableNode.configuration(self)
     get_attribute(self, 'off_text', config, str)
     get_attribute(self, 'on_text', config, str)
     get_attribute(self, 'auto_text', config, str)
     get_attribute(self, 'reverse_output', config, str)
     get_attribute(self, 'output', config, self.as_deferred_node)
     get_attribute(self, 'input', config, as_node_url)
     get_attribute(self, 'period', config, str)
     get_attribute(self, 'asyncOK', config, str)
     get_attribute(self, 'state', config, str)
     get_attribute(self, 'debug', config, str)
     get_attribute(self, 'enabled', config, str)
     get_attribute(self, 'min_on_time', config, str)
     get_attribute(self, 'min_off_time', config, str)
     return config
Exemple #47
0
 def configuration(self):
     config = ConfigurableNode.configuration(self)
     get_attribute(self, 'off_text', config, str)
     get_attribute(self, 'on_text', config, str)
     get_attribute(self, 'auto_text', config, str)
     get_attribute(self, 'reverse_output', config, str)
     get_attribute(self, 'output', config, self.as_deferred_node)
     get_attribute(self, 'input', config, as_node_url)
     get_attribute(self, 'period', config, str)
     get_attribute(self, 'asyncOK', config, str)
     get_attribute(self, 'state', config, str)
     get_attribute(self, 'debug', config, str)
     get_attribute(self, 'enabled', config, str)
     get_attribute(self, 'min_on_time', config, str)
     get_attribute(self, 'min_off_time', config, str)
     return config
Exemple #48
0
	def stop(self):
		self.debug_print('Stopping...', 0)
		ConfigurableNode.stop(self)
Exemple #49
0
	def configuration(self):
		self.debug_print('Reading configuration...', 0)
		config = ConfigurableNode.configuration(self)
		return config
Exemple #50
0
	def __init__(self):
		ConfigurableNode.__init__(self)