Ejemplo n.º 1
0
 def validate(self):
         err = ""
         if not is_bool(self.parameters['sleep_enabled']['value'].upper()):
                 err=err+"Invalid value of sleep_enabled - should be True or False"
         if not is_number(self.parameters['sleep_time']['value'],True):
                 return "Invalid value of sleep_time - must be positive number!"
         actions = action_manager.parse_payload(self.payload)
         #module custom validation
         for command in actions:
                 if command['action'] not in self.required_actions:
                         return "Invalid value of payload - unknown action - %s !" % command['action']
         #action validation
         return action_manager.validate_actions(actions)
Ejemplo n.º 2
0
 def execute(self, payload, device):
         """
         It's executed after all parameters all set.
         """
         if self.parameters['sleep_enabled']['value'].upper()=="TRUE":
                 payload = ("sleep(%i);"% int(self.parameters['sleep_time']['value']) ) + payload
         parsed_payload = action_manager.parse_payload(payload)
         device_input = None
         print_info("Processing payload")
         for command in parsed_payload:
                 processed = device.perform_action(command['action'], command['arguments'])
                 if device_input == None:
                         device_input = processed
                 else:
                         device_input = device_input + processed
         print_info("Payload ready. Let's program device !")
         out = device.perform_action("program",device_input)
         return out