Esempio 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
Esempio 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
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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()
Esempio 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)
Esempio 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)
Esempio 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()
Esempio 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)
Esempio 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()
Esempio 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()
Esempio 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)
Esempio 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")
Esempio n. 15
0
 def destroy(self):
     """ Destroy fetch thread
     """
     self._event.set()
     self._fetch_thread.join()
     AbstractParameter.destroy(self)
Esempio 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")
Esempio 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
Esempio n. 18
0
 def destroy(self):
     """ Destroy fetch thread
     """
     self._event.set()
     self._fetch_thread.join()
     AbstractParameter.destroy(self)
Esempio 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
Esempio 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)
Esempio 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")
Esempio n. 22
0
 def destroy(self):
     """ Destroy fetch thread
     """
     AbstractParameter.destroy(self)
Esempio 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)")
Esempio 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
Esempio 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")