MCPcopy Create free account
hub / github.com/StackStorm/st2 / __init__

Method __init__

st2reactor/st2reactor/container/sensor_wrapper.py:166–267  ·  view source on GitHub ↗

:param pack: Name of the pack this sensor belongs to. :type pack: ``str`` :param file_path: Path to the sensor module file. :type file_path: ``str`` :param class_name: Sensor class name. :type class_name: ``str`` :param trigger_types: A lis

(
        self,
        pack,
        file_path,
        class_name,
        trigger_types,
        poll_interval=None,
        parent_args=None,
        db_ensure_indexes=True,
    )

Source from the content-addressed store, hash-verified

164
165class SensorWrapper(object):
166 def __init__(
167 self,
168 pack,
169 file_path,
170 class_name,
171 trigger_types,
172 poll_interval=None,
173 parent_args=None,
174 db_ensure_indexes=True,
175 ):
176 """
177 :param pack: Name of the pack this sensor belongs to.
178 :type pack: ``str``
179
180 :param file_path: Path to the sensor module file.
181 :type file_path: ``str``
182
183 :param class_name: Sensor class name.
184 :type class_name: ``str``
185
186 :param trigger_types: A list of references to trigger types which
187 belong to this sensor.
188 :type trigger_types: ``list`` of ``str``
189
190 :param poll_interval: Sensor poll interval (in seconds).
191 :type poll_interval: ``int`` or ``None``
192
193 :param parent_args: Command line arguments passed to the parent process.
194 :type parse_args: ``list``
195
196 :param db_ensure_indexes: True to ensure indexes. This should really only be set to False
197 in tests to speed things up.
198 """
199 self._pack = pack
200 self._file_path = file_path
201 self._class_name = class_name
202 self._trigger_types = trigger_types or []
203 self._poll_interval = poll_interval
204 self._parent_args = parent_args or []
205 self._trigger_names = {}
206
207 # 1. Parse the config with inherited parent args
208 try:
209 config.parse_args(args=self._parent_args)
210 except Exception:
211 LOG.exception(
212 "Failed to parse config using parent args "
213 '(parent_args=%s): "%s".' % (str(self._parent_args))
214 )
215
216 # 2. Establish DB connection
217 username = (
218 cfg.CONF.database.username
219 if hasattr(cfg.CONF.database, "username")
220 else None
221 )
222 password = (
223 cfg.CONF.database.password

Callers

nothing calls this directly

Calls 6

_get_sensor_instanceMethod · 0.95
db_setup_with_retryFunction · 0.90
TriggerWatcherClass · 0.90
getLoggerMethod · 0.80
setupMethod · 0.45

Tested by

no test coverage detected