Exemplo n.º 1
0
 def fill(self, params):
     AbstractParameter.fill(self, params)
     params = self.get_parameters()
     if "cron" in params:
         self.expr = CronExpression(params["cron"])
     else:
         self.expr = None
Exemplo n.º 2
0
 def fill(self, params):
     AbstractParameter.fill(self, params)
     params = self.get_parameters()
     if "cron" in params:
         self.expr = CronExpression(params["cron"])
     else:
         self.expr = None
Exemplo n.º 3
0
    def __init__(self, log=None, trigger=None):
        AbstractParameter.__init__(self, log, trigger)
        self.log = log

        #self.set_type("string")
        #self.add_expected_entry("sensor_id", "integer", "The sensor id to check")

        # first, let's get the devices list
        try:
            cli = MQSyncReq(zmq.Context())
            msg = MQMessage()
            msg.set_action('device.get')
            json_devices = cli.request('dbmgr', msg.get(), timeout=10).get()[1]
            devices = json.loads(json_devices)['devices']
            print(devices)
            sensors_list = []
            for dev in devices:
                name = dev['name']
                for sen_idx in dev['sensors']:
                    sen_name = dev['sensors'][sen_idx]['name']
                    sen_id = dev['sensors'][sen_idx]['id']
                    sensors_list.append([
                        '{0} : {1}'.format(name, sen_name),
                        '{0}'.format(sen_id)
                    ])
            print(sensors_list)
        except:
            self.log.error("Error while getting devices list : {0}".format(
                traceback.format_exc()))

        # then, et's configure our sensor id selector :)
        self.set_type("list")
        self.add_expected_entry("sensor_id", "list", "The sensor id to check")
        #list_sensors = [['sensor1', 'sensor2'], ['a', 'A']]
        self.set_list_of_values("sensor_id", sensors_list)
Exemplo n.º 4
0
    def __init__(self, log = None, trigger = None):
        AbstractParameter.__init__(self, log, trigger)
        self.log = log

        #self.set_type("string")
        #self.add_expected_entry("sensor_id", "integer", "The sensor id to check")

        # first, let's get the devices list
        try:
            cli = MQSyncReq(zmq.Context())
            msg = MQMessage()
            msg.set_action('device.get')
            json_devices = cli.request('dbmgr', msg.get(), timeout=10).get()[1]
            devices = json.loads(json_devices)['devices']
            print(devices)
            sensors_list = []
            for dev in devices:
                name = dev['name']
                for sen_idx in dev['sensors']:
                    sen_name = dev['sensors'][sen_idx]['name']
                    sen_id = dev['sensors'][sen_idx]['id']
                    sensors_list.append(['{0} : {1}'.format(name, sen_name), 
                                         '{0}'.format(sen_id)])
            print(sensors_list)
        except:
            self.log.error("Error while getting devices list : {0}".format(traceback.format_exc()))



        # then, et's configure our sensor id selector :)
        self.set_type("list")
        self.add_expected_entry("sensor_id", "list", "The sensor id to check")
        #list_sensors = [['sensor1', 'sensor2'], ['a', 'A']]
        self.set_list_of_values("sensor_id", sensors_list)
Exemplo n.º 5
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("list")
     self.add_expected_entry("usage", "list", "Sensor usage")
     the_list = [["value", "value"],
                 ["trigger if the value change", "trigger_on_change"],
                 ["trigger if the value change or last update time change", "trigger_on_all"]]
     self.set_list_of_values("usage", the_list)
Exemplo n.º 6
0
 def __init__(self, log = None, trigger = None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("string")
     self.add_expected_entry("cron", "string", "Cron expression")
     self.expr = None
     self._event = Event()
     self._fetch_thread = Thread(target=self._check,name="CronParameter.check")
     self._fetch_thread.start()
Exemplo n.º 7
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("list")
     self.add_expected_entry("operator", "string",
                             "Operator to use for comparison")
     list_operator = [
         '<', '>', '==', '!=', '<=', '>=', 'is', 'in', 'not in'
     ]
     self.set_list_of_values("operator", list_operator)
Exemplo n.º 8
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("list")
     self.add_expected_entry("operator", "list", "Operator to use for comparison")
     list_operator = ['==', '<', '>', '<=', '>=', '!=']
     the_list = []
     for op in list_operator:
        the_list.append([op, op])
     self.set_list_of_values("operator", the_list)
Exemplo n.º 9
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("string")
     self.add_expected_entry("cron", "string", "Cron expression")
     self.expr = None
     self._event = Event()
     self._fetch_thread = Thread(target=self._check,
                                 name="CronParameter.check")
     self._fetch_thread.start()
Exemplo n.º 10
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("list")
     self.add_expected_entry("operator", "list",
                             "Operator to use for comparison")
     list_operator = ['==', '<', '>', '<=', '>=', '!=']
     the_list = []
     for op in list_operator:
         the_list.append([op, op])
     self.set_list_of_values("operator", the_list)
Exemplo n.º 11
0
 def __init__(self, log = None, trigger = None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("url")
     self.add_expected_entry("urlpath", "string", "Url the script will fetch")
     self.add_expected_entry("interval", "string", "Interval between 2 fetch in second")
     self.set_default_value("interval", "10")
     self._result = None
     self._event = Event()
     self._fetch_thread = Thread(target=self._fetch,name="UrlParameter.fetch")
     self._fetch_thread.start()
Exemplo n.º 12
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("url")
     self.add_expected_entry("urlpath", "string", "Url")
     self.add_expected_entry("interval", "string",
                             "Number of seconds between 2 checks")
     self.set_default_value("interval", "10")
     self._result = None
     self._event = Event()
     self._fetch_thread = Thread(target=self._fetch,
                                 name="UrlParameter.fetch")
     self._fetch_thread.start()
Exemplo n.º 13
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("list")
     self.add_expected_entry("usage", "list", "Sensor usage")
     the_list = [
         ["value", "value"],
         ["trigger if the value change", "trigger_on_change"],
         [
             "trigger if the value change or last update time change",
             "trigger_on_all"
         ]
     ]
     self.set_list_of_values("usage", the_list)
Exemplo n.º 14
0
 def __init__(self, log = None, trigger = None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("string")
     self.add_expected_entry("text", "string", "Text")
Exemplo n.º 15
0
 def destroy(self):
     """ Destroy fetch thread
     """
     self._event.set()
     self._fetch_thread.join()
     AbstractParameter.destroy(self)
Exemplo n.º 16
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("string")
     self.add_expected_entry("sensor_id", "integer",
                             "The sensor id to check")
Exemplo n.º 17
0
 def __init__(self, log = None, trigger = None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("string")
     self.add_expected_entry("sensor_id", "integer", "The sensor id to check")
     self.log = log
Exemplo n.º 18
0
 def destroy(self):
     """ Destroy fetch thread
     """
     self._event.set()
     self._fetch_thread.join()
     AbstractParameter.destroy(self)
Exemplo n.º 19
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("string")
     self.add_expected_entry("cron", "string", "Cron timed trigger")
     self.expr = None
Exemplo n.º 20
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("list")
     self.add_expected_entry("operator", "string", "Operator to use for comparison")
     list_operator = ['<', '>', '==', '!=', '<=', '>=', 'is', 'in', 'not in']
     self.set_list_of_values("operator", list_operator)
Exemplo n.º 21
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("string")
     self.add_expected_entry("text", "string", "Some text")
Exemplo n.º 22
0
 def destroy(self):
     """ Destroy fetch thread
     """
     AbstractParameter.destroy(self)
Exemplo n.º 23
0
 def __init__(self, log = None, trigger = None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("integer")
     self.add_expected_entry("time", "string", "Time (hh:mm)")
Exemplo n.º 24
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("string")
     self.add_expected_entry("cron", "string", "Cron timed trigger")
     self.expr = None
Exemplo n.º 25
0
 def __init__(self, log=None, trigger=None):
     AbstractParameter.__init__(self, log, trigger)
     self.set_type("int")
     self.add_expected_entry("id", "int", "Block Id")