From 1279fb3a64c277cc760b0ec6f5c2e4367c44257b Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Thu, 6 Jan 2022 22:59:39 +0300 Subject: [PATCH] # Add Debugging toolbox in Web (ActivityItem send from front) --- .../Orchestrator/Managers/Process.py | 11 +++-- .../Orchestrator/SettingsTemplate.py | 3 +- Sources/pyOpenRPA/Orchestrator/Web/Index.js | 41 +++++++++++++++++ .../pyOpenRPA/Orchestrator/Web/Index.xhtml | 46 +++++++++++++++++++ 4 files changed, 97 insertions(+), 4 deletions(-) diff --git a/Sources/pyOpenRPA/Orchestrator/Managers/Process.py b/Sources/pyOpenRPA/Orchestrator/Managers/Process.py index fc6a1db7..c3e0ab53 100644 --- a/Sources/pyOpenRPA/Orchestrator/Managers/Process.py +++ b/Sources/pyOpenRPA/Orchestrator/Managers/Process.py @@ -20,14 +20,18 @@ class Process(): mAgentHostNameStr = None mAgentUserNameStr = None mStartPathStr = None + mStartCMDStr = None mProcessNameWOExeStr = None mStopSafeTimeoutSecFloat = None mStatusStr = None # 0_STOPPED 1_STOPPED_MANUAL 2_STOP_SAFE 3_STOP_SAFE_MANUAL 4_STARTED 5_STARTED_MANUAL - def __init__(self, inAgentHostNameStr, inAgentUserNameStr, mStartPathStr, mProcessNameWOExeStr, mStopSafeTimeoutSecFloat=120): + def __init__(self, inAgentHostNameStr, inAgentUserNameStr, inProcessNameWOExeStr, inStartPathStr=None, inStartCMDStr = None, inStopSafeTimeoutSecFloat=120): self.mAgentHostNameStr = inAgentHostNameStr self.mAgentUserNameStr = inAgentUserNameStr - + self.mStartPathStr = inStartPathStr + self.mStartCMDStr = inStartCMDStr + self.mProcessNameWOExeStr = inProcessNameWOExeStr + self.mStopSafeTimeoutSecFloat = inStopSafeTimeoutSecFloat def Manual2Auto(self): """ @@ -47,7 +51,8 @@ class Process(): :return: """ # Send activity item to agent - wait result - lCMDStr = f"start {os.path.abspath(self.mStartPathStr)}" + if self.mStartPathStr is not None: lCMDStr = f"start {os.path.abspath(self.mStartPathStr)}" + elif self.mStartCMDStr is not None: lCMDStr = f"start {self.mStartCMDStr}" lActivityItemStart = __Orchestrator__.ProcessorActivityItemCreate(inDef="OSCMD", inArgDict={"inCMDStr":lCMDStr,"inSendOutputToOrchestratorLogsBool":False}, inArgGSettingsStr="inGSettings") diff --git a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py index 6d59a801..e9a9ebdf 100644 --- a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py +++ b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py @@ -299,7 +299,8 @@ def __UACClientAdminCreate__(): "RestartOrchestratorBool": True, # Restart orchestrator activity "RestartOrchestratorGITPullBool": True, # Turn off (RDP remember) orc + git pull + Turn on (rdp remember) "RestartPCBool": True, # Send CMD to restart pc - "NothingBool":True # USe option if you dont want to give some access to the RDP controls + "NothingBool":True, # USe option if you dont want to give some access to the RDP controls + "Debugging":True # Debugging tool }, "ActivityDict": { # Empty dict - all access "ActivityListExecuteBool": True, # Execute activity at the current thread diff --git a/Sources/pyOpenRPA/Orchestrator/Web/Index.js b/Sources/pyOpenRPA/Orchestrator/Web/Index.js index f4f7be28..018fdde0 100644 --- a/Sources/pyOpenRPA/Orchestrator/Web/Index.js +++ b/Sources/pyOpenRPA/Orchestrator/Web/Index.js @@ -883,6 +883,7 @@ $(document).ready(function() { if (lUACAsk(["pyOpenRPADict","AdminDict","RestartOrchestratorBool"])) { $(".UACClient-pyOpenRPADict-AdminDict-RestartOrchestratorBool").show(); } if (lUACAsk(["pyOpenRPADict","AdminDict","RestartOrchestratorGITPullBool"])) { $(".UACClient-pyOpenRPADict-AdminDict-RestartOrchestratorGITPullBool").show(); } if (lUACAsk(["pyOpenRPADict","AdminDict","RestartPCBool"])) { $(".UACClient-pyOpenRPADict-AdminDict-RestartPCBool").show(); } + if (lUACAsk(["pyOpenRPADict","AdminDict","Debugging"])) { $(".UACClient-pyOpenRPADict-AdminDict-Debugging").show(); } } @@ -893,4 +894,44 @@ $(document).ready(function() { mGlobal.pyOpenRPA.ServerLogListDoRenderTrue(); // Init button to freeze/unfreeze textare with logs $('.ui.dropdown').dropdown(); + + //////////////////////////////////////////// + // Debugging + /// Execute ActivityItem + mGlobal.pyOpenRPA.DebuggingExecute=function() { + ///EXAMPLE + // { + // "Def":"OSCMD", // def link or def alias (look gSettings["Processor"]["AliasDefDict"]) + // "ArgList":[], // Args list + // "ArgDict":{"inCMDStr":lCMDCode,"inRunAsyncBool":false}, // Args dictionary + // "ArgGSettings": null, // Name of GSettings attribute: str (ArgDict) or index (for ArgList) + // "ArgLogger": "inLogger" // Name of GSettings attribute: str (ArgDict) or index (for ArgList) + // } + ///Подготовить конфигурацию + lArgListStr = $(".mGlobal-pyOpenRPA-Debugging-ArgList")[0].value + lArgDictStr = $(".mGlobal-pyOpenRPA-Debugging-ArgDict")[0].value + lArgGSettingsStr = $(".mGlobal-pyOpenRPA-Debugging-ArgGSettings")[0].value + lArgLoggerStr = $(".mGlobal-pyOpenRPA-Debugging-ArgLogger")[0].value + lActivityItem = { + "Def":$(".mGlobal-pyOpenRPA-Debugging-Def")[0].value, // def link or def alias (look gSettings["Processor"]["AliasDefDict"]) + "ArgList":(lArgListStr == "" ? [] : JSON.parse(lArgListStr)), // Args list + "ArgDict":(lArgDictStr == "" ? {} : JSON.parse(lArgDictStr)), // Args dictionary + "ArgGSettings": (lArgGSettingsStr == "" ? null : lArgGSettingsStr), // Name of GSettings attribute: str (ArgDict) or index (for ArgList) + "ArgLogger": (lArgLoggerStr == "" ? null : lArgLoggerStr) // Name of GSettings attribute: str (ArgDict) or index (for ArgList) + } + lData = [lActivityItem] + $.ajax({ + type: "POST", + url: '/pyOpenRPA/ActivityListExecute', + data: JSON.stringify(lData), + success: + function(lData,l2,l3) + { + var lResponseJSON=JSON.parse(lData) + console.log(lResponseJSON) + $(".mGlobal-pyOpenRPA-Debugging-Output")[0].value = lData + }, + dataType: "text" + }); + } }); \ No newline at end of file diff --git a/Sources/pyOpenRPA/Orchestrator/Web/Index.xhtml b/Sources/pyOpenRPA/Orchestrator/Web/Index.xhtml index 74e4976d..c355bbd4 100644 --- a/Sources/pyOpenRPA/Orchestrator/Web/Index.xhtml +++ b/Sources/pyOpenRPA/Orchestrator/Web/Index.xhtml @@ -298,6 +298,52 @@ +