コード例 #1
0
ファイル: step.py プロジェクト: SamPool1/WALKOFF
 def _update_xml(self, step_xml):
     self.action = step_xml.find('action').text
     self.app = step_xml.find('app').text
     device_field = step_xml.find('device')
     self.device = device_field.text if device_field is not None else ''
     risk_field = step_xml.find('risk')
     self.risk = int(risk_field.text) if risk_field is not None else 0
     self.input = {
         arg.tag: arguments.Argument(key=arg.tag,
                                     value=arg.text,
                                     format=arg.get('format'))
         for arg in step_xml.findall('input/*')
     }
     self.conditionals = [
         nextstep.NextStep(xml=next_step_element,
                           parent_name=self.name,
                           ancestry=self.ancestry)
         for next_step_element in step_xml.findall('next')
     ]
     self.errors = [
         nextstep.NextStep(xml=error_step_element,
                           parent_name=self.name,
                           ancestry=self.ancestry)
         for error_step_element in step_xml.findall('error')
     ]
コード例 #2
0
 def _update_xml(self, step_xml):
     self.action = step_xml.find("action").text
     self.app = step_xml.find("app").text
     self.device = step_xml.find("device").text
     self.input = {arg.tag: arguments.Argument(key=arg.tag, value=arg.text, format=arg.get("format"))
                   for arg in step_xml.findall("input/*")}
     self.conditionals = [nextstep.NextStep(xml=next_step_element, parent_name=self.name, ancestry=self.ancestry)
                          for next_step_element in step_xml.findall("next")]
     self.errors = [nextstep.NextStep(xml=error_step_element, parent_name=self.name, ancestry=self.ancestry)
                    for error_step_element in step_xml.findall("error")]
コード例 #3
0
 def _from_xml(self, step_xml, parent_name='', ancestry=None):
     name = step_xml.get("id")
     ExecutionElement.__init__(self, name=name, parent_name=parent_name, ancestry=ancestry)
     self.action = step_xml.find("action").text
     self.app = step_xml.find("app").text
     self.device = step_xml.find("device").text
     self.input = {arg.tag: arguments.Argument(key=arg.tag, value=arg.text, format=arg.get("format"))
                   for arg in step_xml.findall("input/*")}
     self.conditionals = [nextstep.NextStep(xml=next_step_element, parent_name=self.name, ancestry=self.ancestry)
                          for next_step_element in step_xml.findall("next")]
     self.errors = [nextstep.NextStep(xml=error_step_element, parent_name=self.name, ancestry=self.ancestry)
                    for error_step_element in step_xml.findall("error")]
コード例 #4
0
ファイル: step.py プロジェクト: SamPool1/WALKOFF
    def _from_xml(self, step_xml, parent_name='', ancestry=None):
        name = step_xml.get('id')
        ExecutionElement.__init__(self,
                                  name=name,
                                  parent_name=parent_name,
                                  ancestry=ancestry)
        self.action = step_xml.find('action').text
        self.app = step_xml.find('app').text
        device_field = step_xml.find('device')
        self.device = device_field.text if device_field is not None else ''
        risk_field = step_xml.find('risk')
        self.risk = int(risk_field.text) if risk_field is not None else 0

        self.input = {
            arg.tag: arguments.Argument(key=arg.tag,
                                        value=arg.text,
                                        format=arg.get('format'))
            for arg in step_xml.findall('input/*')
        }
        self.conditionals = [
            nextstep.NextStep(xml=next_step_element,
                              parent_name=self.name,
                              ancestry=self.ancestry)
            for next_step_element in step_xml.findall('next')
        ]
        self.errors = [
            nextstep.NextStep(xml=error_step_element,
                              parent_name=self.name,
                              ancestry=self.ancestry)
            for error_step_element in step_xml.findall('error')
        ]
        self.widgets = [
            _Widget(widget.get('app'), widget.text)
            for widget in step_xml.findall('widgets/*')
        ]
        position = step_xml.find('position')
        if position is None:
            self.position = {}
        else:
            x_position = position.find('x')
            y_position = position.find('y')
            if x_position is not None and y_position is not None:
                self.position = {'x': x_position.text, 'y': y_position.text}
            else:
                self.position = {}
コード例 #5
0
ファイル: step.py プロジェクト: ondrocks/WALKOFF
 def _update_xml(self, step_xml):
     self.action = step_xml.find('action').text
     self.app = step_xml.find('app').text
     device_field = step_xml.find('device')
     self.device = device_field.text if device_field is not None else ''
     risk_field = step_xml.find('risk')
     self.risk = risk_field.text if risk_field is not None else 0
     input_xml = step_xml.find('inputs')
     if input_xml is not None:
         inputs = inputs_xml_to_dict(input_xml) or {}
         if not self.templated:
             self.input = validate_app_action_parameters(self.input_api, inputs, self.app, self.action)
         else:
             self.input = inputs
     else:
         self.input = validate_app_action_parameters(self.input_api, {}, self.app, self.action)
     self.conditionals = [nextstep.NextStep(xml=next_step_element, parent_name=self.name, ancestry=self.ancestry)
                          for next_step_element in step_xml.findall('next')]
     self.errors = [nextstep.NextStep(xml=error_step_element, parent_name=self.name, ancestry=self.ancestry)
                    for error_step_element in step_xml.findall('error')]
コード例 #6
0
ファイル: step.py プロジェクト: ondrocks/WALKOFF
    def _from_xml(self, step_xml, parent_name='', ancestry=None):
        self.raw_xml = step_xml
        name = step_xml.get('id')
        ExecutionElement.__init__(self, name=name, parent_name=parent_name, ancestry=ancestry)

        self.action = step_xml.find('action').text
        self.app = step_xml.find('app').text
        self.run, self.input_api = get_app_action_api(self.app, self.action)
        is_templated_xml = step_xml.find('templated')
        self.templated = is_templated_xml is not None and bool(is_templated_xml.text)
        get_app_action(self.app, self.run)
        input_xml = step_xml.find('inputs')
        if input_xml is not None:
            inputs = inputs_xml_to_dict(input_xml) or {}
            if not self.templated:
                self.input = validate_app_action_parameters(self.input_api, inputs, self.app, self.action)
            else:
                self.input = inputs
        else:
            self.input = validate_app_action_parameters(self.input_api, {}, self.app, self.action)
        device_field = step_xml.find('device')
        self.device = device_field.text if device_field is not None else ''
        risk_field = step_xml.find('risk')
        self.risk = risk_field.text if risk_field is not None else 0
        self.conditionals = [nextstep.NextStep(xml=next_step_element, parent_name=self.name, ancestry=self.ancestry)
                             for next_step_element in step_xml.findall('next')]
        self.errors = [nextstep.NextStep(xml=error_step_element, parent_name=self.name, ancestry=self.ancestry)
                       for error_step_element in step_xml.findall('error')]
        self.widgets = [_Widget(widget.get('app'), widget.text) for widget in step_xml.findall('widgets/*')]
        position = step_xml.find('position')
        if position is None:
            self.position = {}
        else:
            x_position = position.find('x')
            y_position = position.find('y')
            if x_position is not None and y_position is not None:
                self.position = {'x': x_position.text, 'y': y_position.text}
            else:
                self.position = {}