示例#1
0
文件: service.py 项目: cstbox/core
 def log_setLevel(self, level):
     """ Local override of log_setLevel fo handing the propagation of the
     level setting to the child service objects."""
     Loggable.log_setLevel(self, level)
     for so in [
             o for o in self._objects
             if isinstance(o, Loggable) and o is not self
     ]:
         so.log_setLevel(level)
示例#2
0
文件: evtdb.py 项目: cstbox/ext-evtdb
    def __init__(self, channel, dao): #pylint: disable=E1002
        """
        :param str channel: the event channel
        """
        super(EventDatabaseObject, self).__init__()

        self._channel = channel
        self._dao = dao

        Loggable.__init__(self, logname='SO:%s' % self._channel)
示例#3
0
文件: evtmgr.py 项目: cstbox/core
    def __init__(self, channel):
        """
        :param str channel: the event channel
        """
        super(EventManagerObject, self).__init__()

        self._emitLock = threading.Lock()
        self._channel = channel

        Loggable.__init__(self, logname='SO:%s' % self._channel)
示例#4
0
文件: evtmgr.py 项目: cstbox/core
    def __init__(self, channel):
        """
        :param str channel: the event channel
        """
        super(EventManagerObject, self).__init__()

        self._emitLock = threading.Lock()
        self._channel = channel

        Loggable.__init__(self, logname='SO:%s' % self._channel)
示例#5
0
文件: network.py 项目: cstbox/core
    def log_setLevel(self, level):
        """
        Defines the logging level for the container and its service objects.

        :param level: logging level (see module :py:mod:`logging`)
        """
        Loggable.log_setLevel(self, level)
        if self._polling_thread:
            self._polling_thread.log_setLevel(level)
        for haldev in (e.haldev for e in self._devices.itervalues() if isinstance(e.haldev, Loggable)):
            haldev.log_setLevel(self.log_getEffectiveLevel())
示例#6
0
文件: c_serial.py 项目: cstbox/core
    def __init__(self, owner):
        """
        :param CoordinatorServiceObject owner: the owning coordinator
        """
        threading.Thread.__init__(self)

        self._owner = owner
        self._serial_port = owner.serial_port
        self.name = 'ser-' + owner.coordinator_id
        self._terminate = False

        Loggable.__init__(self, logname='SerRX:%s' % owner.coordinator_id)
示例#7
0
文件: c_serial.py 项目: cstbox/core
    def __init__(self, owner):
        """
        :param CoordinatorServiceObject owner: the owning coordinator
        """
        threading.Thread.__init__(self)

        self._owner = owner
        self._serial_port = owner.serial_port
        self.name = 'ser-' + owner.coordinator_id
        self._terminate = False

        Loggable.__init__(self, logname='SerRX:%s' % owner.coordinator_id)
示例#8
0
文件: network.py 项目: cstbox/core
    def log_setLevel(self, level):
        """
        Defines the logging level for the container and its service objects.

        :param level: logging level (see module :py:mod:`logging`)
        """
        Loggable.log_setLevel(self, level)
        if self._polling_thread:
            self._polling_thread.log_setLevel(level)
        for haldev in (e.haldev for e in self._devices.itervalues()
                       if isinstance(e.haldev, Loggable)):
            haldev.log_setLevel(self.log_getEffectiveLevel())
示例#9
0
    def __init__(self, rules=None):
        """ Initializes the rules list by compiling their specifications.

        :param rules: optional rules list
        :raises ValueError: if invalid regex, or if the topic format contains replaceable parameters
            not found in the regex
        """
        Loggable.__init__(self)

        # cache for speeding up computations
        self._cache = {}

        # filtering and transformation transformation rules
        self.rules = rules[:] if rules else []
示例#10
0
文件: network.py 项目: cstbox/core
    def __init__(self, owner, tasks):
        """
        :param CoordinatorServiceObject owner: the coordinator in charge of the polling tasks
        :param tasks: the list of tasks corresponding to polling actions to be managed
        """
        threading.Thread.__init__(self)

        self._owner = owner
        self._tasks = tasks
        self._terminate = False
        self._task_trigger_checking_period = self.DFLT_TASK_CHECKING_PERIOD
        self._stats_file_path = self.STATS_STORAGE_PATH % self._owner.coordinator_id

        Loggable.__init__(self, logname='Poll:%s' % self._owner.coordinator_id)
示例#11
0
文件: network.py 项目: cstbox/core
    def __init__(self, cid):
        """
        :param str cid: coordinator id
        """
        dbus.service.Object.__init__(self)
        self._cid = cid
        self._cfg = None
        self._evtmgr = None
        self._polling_thread = None
        self._poll_req_interval = None
        self._devices = {}
        self._error_count = 0

        Loggable.__init__(self, logname='%s' % str(self))
示例#12
0
文件: network.py 项目: cstbox/core
    def __init__(self, cid):
        """
        :param str cid: coordinator id
        """
        dbus.service.Object.__init__(self)
        self._cid = cid
        self._cfg = None
        self._evtmgr = None
        self._polling_thread = None
        self._poll_req_interval = None
        self._devices = {}
        self._error_count = 0

        Loggable.__init__(self, logname='%s' % str(self))
示例#13
0
文件: network.py 项目: cstbox/core
    def __init__(self, owner, tasks):
        """
        :param CoordinatorServiceObject owner: the coordinator in charge of the polling tasks
        :param tasks: the list of tasks corresponding to polling actions to be managed
        """
        threading.Thread.__init__(self)

        self._owner = owner
        self._tasks = tasks
        self._terminate = False
        self._task_trigger_checking_period = self.DFLT_TASK_CHECKING_PERIOD
        self._stats_file_path = self.STATS_STORAGE_PATH % self._owner.coordinator_id

        Loggable.__init__(self, logname='Poll:%s' % self._owner.coordinator_id)
示例#14
0
    def __init__(self, rules=None):
        """ Initializes the rules list by compiling their specifications.

        :param rules: optional rules list
        :raises ValueError: if invalid regex, or if the topic format contains replaceable parameters
            not found in the regex
        """
        Loggable.__init__(self)

        # cache for speeding up computations
        self._cache = {}

        # filtering and transformation transformation rules
        self.rules = rules[:] if rules else []
示例#15
0
    def __init__(self, cfg):
        """
        The service object is configured based on the content of the configuration data, provided as
        a dictionary by the process which instantiates it.

        See :py:meth:`configure` method documentation for specifications of the configuration data.

        Note that providing no filter at all is invalid, since it would make the gateway useless.

        :param dict cfg: the configuration data
        :raises ValueError: if both filters are unset
        """
        super(MQTTGatewayServiceObject, self).__init__()
        Loggable.__init__(self, logname='SO')

        self._lock = threading.Lock()

        self.configure(cfg, self.logger)
示例#16
0
文件: service.py 项目: cstbox/core
    def __init__(self, name, conn=None, svc_objects=None, auto_fw_object=True):
        """
        :param str name:
            the container's name. It is used to build the well-known name which will
            be claimed (see pycstbox.commons.make_bus_name())

        :param dbus_connection conn:
            the connection to the bus used by the service.
            Set to the session bus if not provided.

        :param list svc_objects:
            an optional list of service objects, which will be automatically added to
            the container during its initialization. The items of this list are tuples
            containing the service object instance and the path to be associated for it

        :param bool auto_fw_object:
            if True (the default) a service object implementing framework level functions
            is automatically created and added. If False, it is the responsibility of
            the application to provide it and adding it if framework level functions are
            required.
        """
        self._name = name
        self._conn = conn if conn else dbus.SessionBus()
        self._objects = []

        # claim our "well known" name on the conn
        self._wkn = dbus.service.BusName(dbuslib.make_bus_name(name),
                                         self._conn)

        self._loop = None
        self._terminate_lock = threading.Lock()

        Loggable.__init__(self, logname='SC:%s' % self._name)

        # adds a service controller object if asked for
        if auto_fw_object:
            fwobj = _FrameworkServiceObject(self)
            self.add(fwobj, SYSTEM_OBJECT_PATH)

        # add provided service objects
        self.add_objects(svc_objects)
示例#17
0
    def __init__(self, port, unit_id, logname, retries=DEFAULT_RETRIES):
        """
        :param str port: serial port on which the RS485 interface is connected
        :param int unit_id: the address of the device
        :param str logname: the (short) root for the name of the log
        :param int retries: number of retries in case of communication errors
        """
        super(RTUModbusHWDevice, self).__init__(port=port, slaveaddress=int(unit_id))

        self._first_poll = True
        self.poll_req_interval = 0
        self.retries = retries
        self.terminate = False
        self.communication_error = False

        self.total_reads = 0
        self.total_errors = 0

        Loggable.__init__(self, logname='%s-%03d' % (logname, self.unit_id))

        self.log_info('created %s instance with unit id=%d on port %s', self.__class__.__name__, unit_id, port)
示例#18
0
文件: service.py 项目: cstbox/core
    def __init__(self, name, conn=None, svc_objects=None, auto_fw_object=True):
        """
        :param str name:
            the container's name. It is used to build the well-known name which will
            be claimed (see pycstbox.commons.make_bus_name())

        :param dbus_connection conn:
            the connection to the bus used by the service.
            Set to the session bus if not provided.

        :param list svc_objects:
            an optional list of service objects, which will be automatically added to
            the container during its initialization. The items of this list are tuples
            containing the service object instance and the path to be associated for it

        :param bool auto_fw_object:
            if True (the default) a service object implementing framework level functions
            is automatically created and added. If False, it is the responsibility of
            the application to provide it and adding it if framework level functions are
            required.
        """
        self._name = name
        self._conn = conn if conn else dbus.SessionBus()
        self._objects = []

        # claim our "well known" name on the conn
        self._wkn = dbus.service.BusName(dbuslib.make_bus_name(name), self._conn)

        self._loop = None
        self._terminate_lock = threading.Lock()

        Loggable.__init__(self, logname='SC:%s' % self._name)

        # adds a service controller object if asked for
        if auto_fw_object:
            fwobj = _FrameworkServiceObject(self)
            self.add(fwobj, SYSTEM_OBJECT_PATH)

        # add provided service objects
        self.add_objects(svc_objects)
示例#19
0
    def __init__(self, rules=None):
        """ Initializes the rules list by compiling their specifications.

        The specifications are provided as an iterable of 3 parts tuples, which items are :

            - a string containing the regex to be applied to fully qualified variable names,
            which can contain capture groups intended to be used for the topic string expansion
            - the MQTT topic string (or topic format string) to be used for publication
            - the callable used to build the MQTT message payload

        :param rules: an iterable of tuples, as described above
        :param logger: optional logging object
        :raises ValueError: if invalid regex, or if the topic format contains replaceable parameters
            not found in the regex
        """
        Loggable.__init__(self)

        # cache for speeding up computations
        self._cache = {}

        # filtering and  transformation rules
        self.rules = rules or []
示例#20
0
    def __init__(self, rules=None):
        """ Initializes the rules list by compiling their specifications.

        The specifications are provided as an iterable of 3 parts tuples, which items are :

            - a string containing the regex to be applied to fully qualified variable names,
            which can contain capture groups intended to be used for the topic string expansion
            - the MQTT topic string (or topic format string) to be used for publication
            - the callable used to build the MQTT message payload

        :param rules: an iterable of tuples, as described above
        :param logger: optional logging object
        :raises ValueError: if invalid regex, or if the topic format contains replaceable parameters
            not found in the regex
        """
        Loggable.__init__(self)

        # cache for speeding up computations
        self._cache = {}

        # filtering and  transformation rules
        self.rules = rules or []
示例#21
0
文件: export.py 项目: cstbox/core
    def __init__(self, jobname, jobid, parms, logger=None):
        """
        :param str jobname: job name (should be unique across the application)
        :param str jobid: the job id.
            Must be unique and allow sorting a job list and reflect their chronology
        :param parms: the execution parameters
        :param logger: (optional) message logger
        :raises ValueError: if mandatory parameters are not all non empty
        """
        if not jobname or not jobid or parms is None:
            raise ValueError("missing mandatory parameter")

        self._name = jobname

        Loggable.__init__(self, logname=jobname)

        self._id = jobid
        self._parms = parms

        self._error = None

        self.log_info('- job %s:%s created :', jobname, jobid)
        self.log_info('  + parameters : %s', self._format_parms())
示例#22
0
    def __init__(self, jobname, jobid, parms, logger=None):
        """
        :param str jobname: job name (should be unique across the application)
        :param str jobid: the job id.
            Must be unique and allow sorting a job list and reflect their chronology
        :param parms: the execution parameters
        :param logger: (optional) message logger
        :raises ValueError: if mandatory parameters are not all non empty
        """
        if not jobname or not jobid or parms is None:
            raise ValueError("missing mandatory parameter")

        self._name = jobname

        Loggable.__init__(self, logname=jobname)

        self._id = jobid
        self._parms = parms

        self._error = None

        self.log_info('- job %s:%s created :', jobname, jobid)
        self.log_info('  + parameters : %s', self._format_parms())
示例#23
0
文件: process.py 项目: cstbox/ext-dwh
 def __init__(self):
     Loggable.__init__(self, logname='evt-expproc')
     self._failed_jobs = {}
示例#24
0
文件: service.py 项目: cstbox/core
 def log_setLevel(self, level):
     """ Local override of log_setLevel fo handing the propagation of the
     level setting to the child service objects."""
     Loggable.log_setLevel(self, level)
     for so in [o for o in self._objects if isinstance(o, Loggable) and o is not self]:
         so.log_setLevel(level)
示例#25
0
文件: core.py 项目: cstbox/ext-mqtt
 def __init__(self, logger, *args, **kwargs):
     Loggable.__init__(self, logger)
     self.log_warning('using a simulated connector')
     mqtt_client.Client.__init__(self, *args, **kwargs)
示例#26
0
文件: st814.py 项目: cstbox/ext-zwave
 def __init__(self, port, unit_id):
     self._first_poll = True
     self.url = port
     self.address = int(unit_id)
     Loggable.__init__(self, logname='zwave%03d' % self.address)
示例#27
0
文件: process.py 项目: cstbox/ext-dwh
 def __init__(self):
     Loggable.__init__(self, logname='cfg-proc')
     self.data = None
示例#28
0
 def __init__(self, *args, **kwargs):
     unittest.TestCase.__init__(self, *args, **kwargs)
     Loggable.__init__(self)
示例#29
0
文件: process.py 项目: cstbox/ext-dwh
 def __init__(self):
     Loggable.__init__(self, logname='cfg-expproc')
示例#30
0
文件: core.py 项目: cstbox/ext-mqtt
 def __init__(self, logger, *args, **kwargs):
     Loggable.__init__(self, logger)
     self.log_warning('using a simulated connector')
     mqtt_client.Client.__init__(self, *args, **kwargs)