From f1b0472fce069fe7fa2e20d0a720f4d967d4fc58 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Wed, 14 Apr 2021 17:52:09 +0300 Subject: [PATCH] Add Orchestrator ProcessDefIntervalCall - very helpfull function for the periodic call Update Guide --- .../Orchestrator/__Orchestrator__.py | 44 +++++++++ Wiki/ENG_Guide/html/Orchestrator/02_Defs.html | 90 +++++++++++------- .../Orchestrator/__Orchestrator__.html | 44 +++++++++ Wiki/ENG_Guide/html/genindex.html | 6 +- Wiki/ENG_Guide/html/objects.inv | Bin 1332 -> 1344 bytes Wiki/ENG_Guide/html/searchindex.js | 2 +- .../markdown/Orchestrator/02_Defs.md | 36 +++++++ 7 files changed, 186 insertions(+), 36 deletions(-) diff --git a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py index 4505684e..7f8eb6c1 100644 --- a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py +++ b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py @@ -942,6 +942,50 @@ def ProcessListGet(inProcessNameWOExeList=None): pass return lResult +def ProcessDefIntervalCall(inDef, inIntervalSecFloat, inIntervalAsyncBool=False, inDefArgList=None, inDefArgDict=None, inExecuteInNewThreadBool=True, inLogger=None): + """ + Use this procedure if you need to run periodically some def. Set def, args, interval and enjoy :) + + :param inDef: def link, which will be called with interval inIntervalSecFloat + :param inIntervalSecFloat: Interval in seconds between call + :param inIntervalAsyncBool: False - wait interval before next call after the previous iteration result; True - wait interval after previous iteration call + :param inDefArgList: List of the args in def. Default None (empty list) + :param inDefArgDict: Dict of the args in def. Default None (empty dict) + :param inExecuteInNewThreadBool: True - create new thread for the periodic execution; False - execute in current thread. Default: True + :return: + """ + #Some edits on start + if inDefArgDict is None: inDefArgDict = {} + if inDefArgList is None: inDefArgList = [] + + # Internal def to execute periodically + def __Execute__(inDef, inIntervalSecFloat, inIntervalAsyncBool, inDefArgList, inDefArgDict, inLogger): + while True: + try: + # Call async if needed + if inIntervalAsyncBool==False: # Case wait result then wait + inDef(*inDefArgList, **inDefArgDict) + else: # Case dont wait result - run sleep then new iteration (use many threads) + lThread2 = threading.Thread(target=__Execute__, + kwargs={"inDef": inDef, "inIntervalSecFloat": inIntervalSecFloat, + "inIntervalAsyncBool": inIntervalAsyncBool, "inDefArgList": inDefArgList, + "inDefArgDict": inDefArgDict}) + lThread2.start() + except Exception as e: + if inLogger: inLogger.exception(f"ProcessDefIntervalCall: Interval call has been failed. Traceback is below. Code will sleep for the next call") + # Sleep interval + time.sleep(inIntervalSecFloat) + # Check to call in new thread + if inExecuteInNewThreadBool: + lThread = threading.Thread(target=__Execute__, + kwargs={"inDef":inDef, "inIntervalSecFloat":inIntervalSecFloat, + "inIntervalAsyncBool":inIntervalAsyncBool, "inDefArgList":inDefArgList, + "inDefArgDict":inDefArgDict, "inLogger":inLogger}) + lThread.start() + else: + __Execute__(inDef=inDef, inIntervalSecFloat=inIntervalSecFloat, inIntervalAsyncBool=inIntervalAsyncBool, inDefArgList=inDefArgList, inDefArgDict=inDefArgDict, inLogger=inLogger) + + # Python def - start module function def PythonStart(inModulePathStr, inDefNameStr, inArgList=None, inArgDict=None, inLogger = None): """ diff --git a/Wiki/ENG_Guide/html/Orchestrator/02_Defs.html b/Wiki/ENG_Guide/html/Orchestrator/02_Defs.html index a0047603..c971ca33 100644 --- a/Wiki/ENG_Guide/html/Orchestrator/02_Defs.html +++ b/Wiki/ENG_Guide/html/Orchestrator/02_Defs.html @@ -305,103 +305,106 @@

OrchestratorSessionSave([inGSettings])

Orchestrator session save in file _SessionLast_RDPList.json (encoding = “utf-8”)

-

ProcessIsStarted(inProcessNameWOExeStr)

+

ProcessDefIntervalCall(inDef, inIntervalSecFloat)

+

Use this procedure if you need to run periodically some def.

+ +

ProcessIsStarted(inProcessNameWOExeStr)

Check if there is any running process that contains the given name processName.

-

ProcessListGet([inProcessNameWOExeList])

+

ProcessListGet([inProcessNameWOExeList])

Return process list on the orchestrator machine sorted by Memory Usage.

-

ProcessStart(inPathStr, inArgList[, …])

+

ProcessStart(inPathStr, inArgList[, …])

Start process locally.

-

ProcessStop(inProcessNameWOExeStr, …[, …])

+

ProcessStop(inProcessNameWOExeStr, …[, …])

Stop process on the orchestrator machine.

-

ProcessorActivityItemAppend(inGSettings[, …])

+

ProcessorActivityItemAppend(inGSettings[, …])

Create and add activity item in processor queue.

-

ProcessorActivityItemCreate(inDef[, …])

+

ProcessorActivityItemCreate(inDef[, …])

Create activity item.

-

ProcessorAliasDefCreate(inGSettings, inDef)

+

ProcessorAliasDefCreate(inGSettings, inDef)

Create alias for def (can be used in ActivityItem in field Def) !WHEN DEF ALIAS IS REQUIRED! - Def alias is required when you try to call Python def from the Orchestrator WEB side (because you can’t transmit Python def object out of the Python environment)

-

ProcessorAliasDefUpdate(inGSettings, inDef, …)

+

ProcessorAliasDefUpdate(inGSettings, inDef, …)

Update alias for def (can be used in ActivityItem in field Def).

-

PythonStart(inModulePathStr, inDefNameStr[, …])

+

PythonStart(inModulePathStr, inDefNameStr[, …])

Import module and run def in the Orchestrator process.

-

RDPSessionCMDRun(inGSettings, …[, inModeStr])

+

RDPSessionCMDRun(inGSettings, …[, inModeStr])

Send CMD command to the RDP session “RUN” window

-

RDPSessionConnect(inGSettings, …[, …])

+

RDPSessionConnect(inGSettings, …[, …])

Create new RDPSession in RobotRDPActive. Attention - activity will be ignored if RDP key is already exists

-

RDPSessionDisconnect(inGSettings, …[, …])

+

RDPSessionDisconnect(inGSettings, …[, …])

Disconnect the RDP session and stop monitoring it.

-

RDPSessionDublicatesResolve(inGSettings)

+

RDPSessionDublicatesResolve(inGSettings)

DEVELOPING Search duplicates in GSettings RDPlist !def is developing!

-

RDPSessionFileStoredRecieve(inGSettings, …)

+

RDPSessionFileStoredRecieve(inGSettings, …)

Recieve file from RDP session to the Orchestrator session using shared drive in RDP (see RDP Configuration Dict, Shared drive)

-

RDPSessionFileStoredSend(inGSettings, …)

+

RDPSessionFileStoredSend(inGSettings, …)

Send file from Orchestrator session to the RDP session using shared drive in RDP (see RDP Configuration Dict, Shared drive)

-

RDPSessionLogoff(inGSettings, inRDPSessionKeyStr)

+

RDPSessionLogoff(inGSettings, inRDPSessionKeyStr)

Logoff the RDP session from the Orchestrator process (close all apps in session when logoff)

-

RDPSessionMonitorStop(inGSettings, …)

+

RDPSessionMonitorStop(inGSettings, …)

Stop monitoring the RDP session by the Orchestrator process.

-

RDPSessionProcessStartIfNotRunning(…[, …])

+

RDPSessionProcessStartIfNotRunning(…[, …])

Start process in RDP if it is not running (check by the arg inProcessNameWEXEStr)

-

RDPSessionProcessStop(inGSettings, …)

+

RDPSessionProcessStop(inGSettings, …)

Send CMD command to the RDP session “RUN” window.

-

RDPSessionReconnect(inGSettings, …[, …])

+

RDPSessionReconnect(inGSettings, …[, …])

Reconnect the RDP session

-

RDPSessionResponsibilityCheck(inGSettings, …)

+

RDPSessionResponsibilityCheck(inGSettings, …)

DEVELOPING, MAYBE NOT USEFUL Check RDP Session responsibility TODO NEED DEV + TEST

-

RDPTemplateCreate(inLoginStr, inPasswordStr)

+

RDPTemplateCreate(inLoginStr, inPasswordStr)

Create RDP connect dict item/ Use it connect/reconnect (Orchestrator.RDPSessionConnect)

-

SchedulerActivityTimeAddWeekly(inGSettings)

+

SchedulerActivityTimeAddWeekly(inGSettings)

Add activity item list in scheduler.

-

UACKeyListCheck(inRequest, inRoleKeyList)

+

UACKeyListCheck(inRequest, inRoleKeyList)

Check is client is has access for the key list

-

UACSuperTokenUpdate(inGSettings, inSuperTokenStr)

+

UACSuperTokenUpdate(inGSettings, inSuperTokenStr)

Add supertoken for the all access (it is need for the robot communication without human)

-

UACUpdate(inGSettings, inADLoginStr[, …])

+

UACUpdate(inGSettings, inADLoginStr[, …])

Update user access (UAC)

-

WebCPUpdate(inGSettings, inCPKeyStr[, …])

+

WebCPUpdate(inGSettings, inCPKeyStr[, …])

Add control panel HTML, JSON generator or JS when page init

-

WebURLConnectDef(inGSettings, inMethodStr, …)

+

WebURLConnectDef(inGSettings, inMethodStr, …)

Connect URL to DEF

-

WebURLConnectFile(inGSettings, inMethodStr, …)

+

WebURLConnectFile(inGSettings, inMethodStr, …)

Connect URL to File

-

WebURLConnectFolder(inGSettings, …)

+

WebURLConnectFolder(inGSettings, …)

Connect URL to Folder

-

WebUserInfoGet(inRequest)

+

WebUserInfoGet(inRequest)

Return User info about request

-

WebUserIsSuperToken(inRequest, inGSettings)

+

WebUserIsSuperToken(inRequest, inGSettings)

Return bool if request is authentificated with supetoken (token which is never expires)

-

WebUserUACHierarchyGet(inRequest)

+

WebUserUACHierarchyGet(inRequest)

Return User UAC Hierarchy DICT Return {…}

@@ -726,6 +729,27 @@ +
+
+pyOpenRPA.Orchestrator.__Orchestrator__.ProcessDefIntervalCall(inDef, inIntervalSecFloat, inIntervalAsyncBool=False, inDefArgList=None, inDefArgDict=None, inExecuteInNewThreadBool=True, inLogger=None)[source]
+

Use this procedure if you need to run periodically some def. Set def, args, interval and enjoy :)

+
+
Parameters
+
    +
  • inDef – def link, which will be called with interval inIntervalSecFloat

  • +
  • inIntervalSecFloat – Interval in seconds between call

  • +
  • inIntervalAsyncBool – False - wait interval before next call after the previous iteration result; True - wait interval after previous iteration call

  • +
  • inDefArgList – List of the args in def. Default None (empty list)

  • +
  • inDefArgDict – Dict of the args in def. Default None (empty dict)

  • +
  • inExecuteInNewThreadBool – True - create new thread for the periodic execution; False - execute in current thread. Default: True

  • +
+
+
Returns
+

+
+
+
+
pyOpenRPA.Orchestrator.__Orchestrator__.ProcessIsStarted(inProcessNameWOExeStr)[source]
diff --git a/Wiki/ENG_Guide/html/_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html b/Wiki/ENG_Guide/html/_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html index 3459e423..efe01482 100644 --- a/Wiki/ENG_Guide/html/_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html +++ b/Wiki/ENG_Guide/html/_modules/pyOpenRPA/Orchestrator/__Orchestrator__.html @@ -1123,6 +1123,50 @@ pass return lResult +
[docs]def ProcessDefIntervalCall(inDef, inIntervalSecFloat, inIntervalAsyncBool=False, inDefArgList=None, inDefArgDict=None, inExecuteInNewThreadBool=True, inLogger=None): + """ + Use this procedure if you need to run periodically some def. Set def, args, interval and enjoy :) + + :param inDef: def link, which will be called with interval inIntervalSecFloat + :param inIntervalSecFloat: Interval in seconds between call + :param inIntervalAsyncBool: False - wait interval before next call after the previous iteration result; True - wait interval after previous iteration call + :param inDefArgList: List of the args in def. Default None (empty list) + :param inDefArgDict: Dict of the args in def. Default None (empty dict) + :param inExecuteInNewThreadBool: True - create new thread for the periodic execution; False - execute in current thread. Default: True + :return: + """ + #Some edits on start + if inDefArgDict is None: inDefArgDict = {} + if inDefArgList is None: inDefArgList = [] + + # Internal def to execute periodically + def __Execute__(inDef, inIntervalSecFloat, inIntervalAsyncBool, inDefArgList, inDefArgDict, inLogger): + while True: + try: + # Call async if needed + if inIntervalAsyncBool==False: # Case wait result then wait + inDef(*inDefArgList, **inDefArgDict) + else: # Case dont wait result - run sleep then new iteration (use many threads) + lThread2 = threading.Thread(target=__Execute__, + kwargs={"inDef": inDef, "inIntervalSecFloat": inIntervalSecFloat, + "inIntervalAsyncBool": inIntervalAsyncBool, "inDefArgList": inDefArgList, + "inDefArgDict": inDefArgDict}) + lThread2.start() + except Exception as e: + if inLogger: inLogger.exception(f"ProcessDefIntervalCall: Interval call has been failed. Traceback is below. Code will sleep for the next call") + # Sleep interval + time.sleep(inIntervalSecFloat) + # Check to call in new thread + if inExecuteInNewThreadBool: + lThread = threading.Thread(target=__Execute__, + kwargs={"inDef":inDef, "inIntervalSecFloat":inIntervalSecFloat, + "inIntervalAsyncBool":inIntervalAsyncBool, "inDefArgList":inDefArgList, + "inDefArgDict":inDefArgDict, "inLogger":inLogger}) + lThread.start() + else: + __Execute__(inDef=inDef, inIntervalSecFloat=inIntervalSecFloat, inIntervalAsyncBool=inIntervalAsyncBool, inDefArgList=inDefArgList, inDefArgDict=inDefArgDict, inLogger=inLogger)
+ + # Python def - start module function
[docs]def PythonStart(inModulePathStr, inDefNameStr, inArgList=None, inArgDict=None, inLogger = None): """ diff --git a/Wiki/ENG_Guide/html/genindex.html b/Wiki/ENG_Guide/html/genindex.html index 327e649e..91585461 100644 --- a/Wiki/ENG_Guide/html/genindex.html +++ b/Wiki/ENG_Guide/html/genindex.html @@ -277,6 +277,8 @@

P

    +
  • ProcessWOExeUpperUserListGet() (in module pyOpenRPA.Agent.__Agent__) +
  • PWASpecification_Get_PWAApplication() (in module pyOpenRPA.Robot.UIDesktop)
  • PWASpecification_Get_UIO() (in module pyOpenRPA.Robot.UIDesktop) diff --git a/Wiki/ENG_Guide/html/objects.inv b/Wiki/ENG_Guide/html/objects.inv index 157a20f2383017f6583cc3b8dd3fd90d07bc8425..90ba3b404981a973134fce9def62c0bc84193a30 100644 GIT binary patch delta 899 zcmV-}1AP3n3cw1m%K?8eDo=$0^@H*;<=iFJR0nqFAa+U8T}$*z5jZ>lnm{Hl@ug~& zFYY2~C!fQVbl~HRTGKu!*D8sfab;$Qp}?8lEhh6a++d_$q{20c6apgGOPMeoorfrW z;4H$k*O(h5cNDJ=e73~H5P_L*0TF{U@&&E}#ewWjZslg%U9=V$ub~PH8#lE}ELyjQDyUS8Of^e7*k;ftW8Xm@TxA?2YU6}+C!aa$N;Adcw zJa+U1V0kpCsn~x=SH*orp$``9k_S!rmfABctY}>@(0JiVhIx*ycZeV71 zpz^p{6#l*9gH2MouiRw!GS$$xjdU|C6+oXXOO@HTTfE2i9sBfga_HG^bVqi0JH^E? zyp=zfaw>ncu`j&Z#Ghjsk-?B0iE^a*wnBMB?IJ%n6H8sF2TrCj$GdY3-2?LAGr zi>q)flT2At*Z3(6jf`$7caA84u6%Nkk&mR3dRP7+ss)3O*k}NA`T+bD=noC`TKObh z>j&uOj{G*B2mUNy*%hft`yY{~nU3G59Ghw~IjeRHwT_d=CvIh|{=wfdVsCTs4 z=>>ZxjhVEoE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