Beispiel #1
0
 def new_step(step_uid, **kwargs):
     step = Step()
     step.uid = step_uid
     if step.uid == StepUids.NULL_STEP:
         step.script = "alert ('nullStep');"
         return step
     elif step.uid == StepUids.TEST_STEP:
         step.default_args_dict = {
             "isOk": True,
             "numLines": 4,
             "portion": 0.1234567890,
             "portion2": 1,
             "none": None,
             "hello": "HelloWorld",
             "hasReturn": True
         }
         step.script = """
             var step_result = args
             args.hello = "byeBye!!"
             alert ('testStep');
         """
         return step
     elif step.uid == StepUids.FROM_JSX:
         if "script_path_name" in kwargs.keys():
             step_pool = Facade.getInstance().retrieveProxy(StepPoolProxy.NAME).__get_step_pool()
             step = step_pool.get_step(file_path_name=kwargs["script_path_name"])
         return step
     else:
         print("StepFactory.new_step no step with such uid")
         return StepFactory.new_step(StepUids.NULL_STEP)
Beispiel #2
0
 def load_steps(self):
     for script_path_name in self.step_files:
         step = Step()
         self.steps.append(step)
         step.script_path_name = script_path_name
         with open(script_path_name, "r") as f:
             step.script = f.read()
Beispiel #3
0
 def new_step(step_uid, **kwargs):
     step = Step()
     step.uid = step_uid
     if step.uid == StepUids.NULL_STEP:
         step.script = "alert ('nullStep');"
         return step
     elif step.uid == StepUids.TEST_STEP:
         step.default_args_dict = {
             "isOk": True,
             "numLines": 4,
             "portion": 0.1234567890,
             "portion2": 1,
             "none": None,
             "hello": "HelloWorld",
             "hasReturn": True
         }
         step.script = """
             var step_result = args
             args.hello = "byeBye!!"
             alert ('testStep');
         """
         return step
     elif step.uid == StepUids.FROM_JSX:
         if "script_path_name" in kwargs.keys():
             step_pool = Facade.getInstance().retrieveProxy(
                 StepPoolProxy.NAME).__get_step_pool()
             step = step_pool.get_step(
                 file_path_name=kwargs["script_path_name"])
         return step
     else:
         print("StepFactory.new_step no step with such uid")
         return StepFactory.new_step(StepUids.NULL_STEP)
Beispiel #4
0
    def js_play(self, ps_app, action_script):
        ps_source_str = "({})"
        try:

            ps_source_str = ps_app.DoJavaScript(
                "returnStr = {}.toSource();\nif(app.documents.length != 0)\n{app.activeDocument.suspendHistory(\n'" +
                self.name + "', '" + action_script + "'),\n returnStr;}",
                [0],
                1  # PsJavaScriptExecutionMode: 1 (psNeverShowDebugger), 2 (psDebuggerOnError), 3 (psBeforeRunning)
            )

            # except pywintypes.com_error:
            #     ps_app.DoJavaScript("alert('Error in script:" + b + "');")
        finally:
            result_py_dict = Step.py_dict_from_ps_source_str(ps_source_str)
            return result_py_dict
Beispiel #5
0
 def get_step(self, step_uid):
     step = self.__get_step_pool().get_step(script_path_name=step_uid)
     if not step:
         step = Step()
     return step