Managers. Git is ready - try to test

dev-linux
Ivan Maslov 3 years ago
parent 732506451e
commit 3f5a8e5687

@ -45,8 +45,13 @@ def JSInitGenerator():
"""
return lJSCheckVersion
def test():
#Orchestrator.WebRequestGet()
Orchestrator.WebRequestResponseSend("Hello my friend!")
#Orchestrator settings
def SettingsUpdate(inGSettings):
# New way to add CP defs in orchestrator - no gSettings..
Orchestrator.WebCPUpdate(inGSettings=inGSettings, inCPKeyStr="TEST", inHTMLRenderDef=CPRender, inJSONGeneratorDef=JSONGenerator, inJSInitGeneratorDef=JSInitGenerator)
Orchestrator.WebURLConnectDef(inMethodStr="GET", inURLStr="/test", inMatchTypeStr="Equal", inDef=test, inUACBool=False)
return inGSettings

@ -1,4 +1,6 @@
import psutil, datetime, logging, os, sys # stdout from logging
import psutil, datetime, logging, os, sys
from pyOpenRPA.Orchestrator.__Orchestrator__ import OrchestratorLoggerGet # stdout from logging
# Config settings
lPyOpenRPASourceFolderPathStr = r"..\Sources" # Path for test pyOpenRPA package
@ -16,7 +18,8 @@ if not Orchestrator.OrchestratorIsAdmin():
else:
gSettings = Orchestrator.GSettingsGet()
#gSettings = SettingsTemplate.Create(inModeStr="BASIC") # Create GSettings with basic configuration - no more config is available from the box - you can create own
# Set the debug level
OrchestratorLoggerGet().setLevel(logging.DEBUG)
# TEST Add User ND - Add Login ND to superuser of the Orchestrator
lUACClientDict = SettingsTemplate.__UACClientAdminCreate__()
Orchestrator.UACUpdate(inGSettings=gSettings, inADLoginStr="ND", inADStr="", inADIsDefaultBool=True, inURLList=[], inRoleHierarchyAllowedDict=lUACClientDict)
@ -33,3 +36,4 @@ else:
# Call the orchestrator def
Orchestrator.Orchestrator(inGSettings=gSettings, inDumpRestoreBool=False)

@ -6,6 +6,8 @@ from . import Process
from typing import List
from pyOpenRPA import Orchestrator
class Git():
mAgentHostNameStr = None
@ -60,7 +62,6 @@ class Git():
for lProcessItem in self.mProcessList:
lProcessItem.StatusRestore()
def __OSCMDShell__(self, inCMDStr):
"""
Detect the way of use and send the cmd. Wait for command execution!
@ -92,15 +93,39 @@ class Git():
return lCMDResultStr
def BranchRevIsLast(self, inBranchLocalStr: str, inBranchRemoteStr: str) -> bool:
pass
"""Get fetch and check if local branch revision is last (if check with remote)
:param inBranchLocalStr: _description_
:type inBranchLocalStr: str
:param inBranchRemoteStr: _description_
:type inBranchRemoteStr: str
:return: _description_
:rtype: bool
"""
lIsLastBool = False
self.Fetch()
lLocalBranchRevStr = self.BranchRevGet(inBranchNameStr=inBranchLocalStr)
lRemoteBranchRevStr = self.BranchRevGet(inBranchNameStr=inBranchRemoteStr)
if lLocalBranchRevStr == lRemoteBranchRevStr:
lIsLastBool = True
return lIsLastBool
def BranchRevLastGet(self, inBranchLocalStr: str, inBranchRemoteStr: str, inBranchRestoreBool: bool = True):
def BranchRevLastGetInterval(self, inBranchLocalStr: str, inBranchRemoteStr: str, inPreviousBranchRestoreBool: bool = True, inIntervalSecFloat: float = 60.0):
"""Periodically check if revision is last
:param inBranchLocalStr: _description_
:type inBranchLocalStr: str
:param inBranchRemoteStr: _description_
:type inBranchRemoteStr: str
:param inPreviousBranchRestoreBool: _description_, defaults to True
:type inPreviousBranchRestoreBool: bool, optional
:param inIntervalSecFloat: _description_, defaults to 60.0
:type inIntervalSecFloat: float, optional
"""
Orchestrator.OrchestratorScheduleGet().every(inIntervalSecFloat).seconds().do(self.BranchRevLastGet, inBranchLocalStr, inBranchRemoteStr, inPreviousBranchRestoreBool)
def BranchRevLastGet(self, inBranchLocalStr: str, inBranchRemoteStr: str, inPreviousBranchRestoreBool: bool = True):
"""Do some action to get the last revision
:param inBranchLocalStr: [description]
@ -108,8 +133,11 @@ class Git():
:param inBranchRemoteStr: [description]
:type inBranchRemoteStr: str
"""
Orchestrator.OrchestratorLoggerGet().debug(f"Managers.Git ({self.mAbsPathStr}): self.BranchRevLastGet has been init")
# check if the correct revision
lCMDResultStr = None
if self.BranchRevIsLast(inBranchLocalStr=inBranchLocalStr, inBranchRemoteStr=inBranchRemoteStr) == False:
Orchestrator.OrchestratorLoggerGet().debug(f"Managers.Git ({self.mAbsPathStr}): self.BranchRevLastGet, new revision has been detected - start to merge")
lBranchNameCurrentStr = self.BranchNameGet()
# reset all changes in local folder
self.Clear()
@ -118,17 +146,10 @@ class Git():
# merge
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git merge {inBranchRemoteStr}"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
if inBranchRestoreBool == True:
if inPreviousBranchRestoreBool == True:
# checkout to the source branch which was
self.BranchCheckout(inBranchNameStr=lBranchNameCurrentStr)
def BranchRevCheck(self, inBranchRemoteStr):
"""Check if branch is last. If not last -> do some actions to get last
:param inBranchRemoteStr: [description]
:type inBranchRemoteStr: [type]
"""
pass
return lCMDResultStr
def BranchNameGet(self) -> str:
"""Get the current local branch name
@ -141,10 +162,10 @@ class Git():
return lCMDResultStr
def BranchCheckout(self, inBranchNameStr):
pass
f"git clean -f -d" # Очистить от лишних файлов
f"git checkout {inBranchNameStr}"
self.Clear()
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git checkout {inBranchNameStr}"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
return lCMDResultStr
def Clear(self):
"""Clear the all changes in the local folder. Get up to the current revision
@ -155,6 +176,7 @@ class Git():
# f"git reset --hard" # Откатить файлы, которые отслеживаются Git и которые были изменены
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git reset --hard"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
return lCMDResultStr
def Fetch(self):
"""
@ -167,6 +189,7 @@ class Git():
"""
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git fetch"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
return lCMDResultStr
def GitExists(inAgentHostNameStr: str, inAgentUserNameStr: str, inGitPathStr: str) -> bool:
"""

@ -529,7 +529,7 @@ def OrchestratorRestart(inGSettings=None):
os.execl(sys.executable, os.path.abspath(__file__), *sys.argv)
sys.exit(0)
def OrchestratorLoggerGet():
def OrchestratorLoggerGet() -> logging.Logger:
"""
Get the logger from the Orchestrator
@ -537,6 +537,7 @@ def OrchestratorLoggerGet():
"""
return GSettingsGet().get("Logger",None)
def OrchestratorScheduleGet() -> schedule:
"""
Get the schedule (schedule.readthedocs.io) from the Orchestrator

Loading…
Cancel
Save