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 return lJSCheckVersion
def test():
#Orchestrator.WebRequestGet()
Orchestrator.WebRequestResponseSend("Hello my friend!")
#Orchestrator settings #Orchestrator settings
def SettingsUpdate(inGSettings): def SettingsUpdate(inGSettings):
# New way to add CP defs in orchestrator - no gSettings.. # New way to add CP defs in orchestrator - no gSettings..
Orchestrator.WebCPUpdate(inGSettings=inGSettings, inCPKeyStr="TEST", inHTMLRenderDef=CPRender, inJSONGeneratorDef=JSONGenerator, inJSInitGeneratorDef=JSInitGenerator) 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 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 # Config settings
lPyOpenRPASourceFolderPathStr = r"..\Sources" # Path for test pyOpenRPA package lPyOpenRPASourceFolderPathStr = r"..\Sources" # Path for test pyOpenRPA package
@ -16,7 +18,8 @@ if not Orchestrator.OrchestratorIsAdmin():
else: else:
gSettings = Orchestrator.GSettingsGet() 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 #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 # TEST Add User ND - Add Login ND to superuser of the Orchestrator
lUACClientDict = SettingsTemplate.__UACClientAdminCreate__() lUACClientDict = SettingsTemplate.__UACClientAdminCreate__()
Orchestrator.UACUpdate(inGSettings=gSettings, inADLoginStr="ND", inADStr="", inADIsDefaultBool=True, inURLList=[], inRoleHierarchyAllowedDict=lUACClientDict) Orchestrator.UACUpdate(inGSettings=gSettings, inADLoginStr="ND", inADStr="", inADIsDefaultBool=True, inURLList=[], inRoleHierarchyAllowedDict=lUACClientDict)
@ -33,3 +36,4 @@ else:
# Call the orchestrator def # Call the orchestrator def
Orchestrator.Orchestrator(inGSettings=gSettings, inDumpRestoreBool=False) Orchestrator.Orchestrator(inGSettings=gSettings, inDumpRestoreBool=False)

@ -6,6 +6,8 @@ from . import Process
from typing import List from typing import List
from pyOpenRPA import Orchestrator
class Git(): class Git():
mAgentHostNameStr = None mAgentHostNameStr = None
@ -60,7 +62,6 @@ class Git():
for lProcessItem in self.mProcessList: for lProcessItem in self.mProcessList:
lProcessItem.StatusRestore() lProcessItem.StatusRestore()
def __OSCMDShell__(self, inCMDStr): def __OSCMDShell__(self, inCMDStr):
""" """
Detect the way of use and send the cmd. Wait for command execution! Detect the way of use and send the cmd. Wait for command execution!
@ -92,15 +93,39 @@ class Git():
return lCMDResultStr return lCMDResultStr
def BranchRevIsLast(self, inBranchLocalStr: str, inBranchRemoteStr: str) -> bool: 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 lIsLastBool = False
self.Fetch()
lLocalBranchRevStr = self.BranchRevGet(inBranchNameStr=inBranchLocalStr) lLocalBranchRevStr = self.BranchRevGet(inBranchNameStr=inBranchLocalStr)
lRemoteBranchRevStr = self.BranchRevGet(inBranchNameStr=inBranchRemoteStr) lRemoteBranchRevStr = self.BranchRevGet(inBranchNameStr=inBranchRemoteStr)
if lLocalBranchRevStr == lRemoteBranchRevStr: if lLocalBranchRevStr == lRemoteBranchRevStr:
lIsLastBool = True lIsLastBool = True
return lIsLastBool 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 """Do some action to get the last revision
:param inBranchLocalStr: [description] :param inBranchLocalStr: [description]
@ -108,8 +133,11 @@ class Git():
:param inBranchRemoteStr: [description] :param inBranchRemoteStr: [description]
:type inBranchRemoteStr: str :type inBranchRemoteStr: str
""" """
Orchestrator.OrchestratorLoggerGet().debug(f"Managers.Git ({self.mAbsPathStr}): self.BranchRevLastGet has been init")
# check if the correct revision # check if the correct revision
lCMDResultStr = None
if self.BranchRevIsLast(inBranchLocalStr=inBranchLocalStr, inBranchRemoteStr=inBranchRemoteStr) == False: 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() lBranchNameCurrentStr = self.BranchNameGet()
# reset all changes in local folder # reset all changes in local folder
self.Clear() self.Clear()
@ -118,17 +146,10 @@ class Git():
# merge # merge
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git merge {inBranchRemoteStr}" lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git merge {inBranchRemoteStr}"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr) lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
if inBranchRestoreBool == True: if inPreviousBranchRestoreBool == True:
# checkout to the source branch which was # checkout to the source branch which was
self.BranchCheckout(inBranchNameStr=lBranchNameCurrentStr) self.BranchCheckout(inBranchNameStr=lBranchNameCurrentStr)
return lCMDResultStr
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
def BranchNameGet(self) -> str: def BranchNameGet(self) -> str:
"""Get the current local branch name """Get the current local branch name
@ -141,10 +162,10 @@ class Git():
return lCMDResultStr return lCMDResultStr
def BranchCheckout(self, inBranchNameStr): def BranchCheckout(self, inBranchNameStr):
pass self.Clear()
f"git clean -f -d" # Очистить от лишних файлов lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git checkout {inBranchNameStr}"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
f"git checkout {inBranchNameStr}" return lCMDResultStr
def Clear(self): def Clear(self):
"""Clear the all changes in the local folder. Get up to the current revision """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 и которые были изменены # f"git reset --hard" # Откатить файлы, которые отслеживаются Git и которые были изменены
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git reset --hard" lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git reset --hard"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr) lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
return lCMDResultStr
def Fetch(self): def Fetch(self):
""" """
@ -167,6 +189,7 @@ class Git():
""" """
lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git fetch" lCMDStr = f"cd \"{self.mAbsPathUpperStr}\" && git fetch"
lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr) lCMDResultStr = self.__OSCMDShell__(inCMDStr=lCMDStr)
return lCMDResultStr
def GitExists(inAgentHostNameStr: str, inAgentUserNameStr: str, inGitPathStr: str) -> bool: 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) os.execl(sys.executable, os.path.abspath(__file__), *sys.argv)
sys.exit(0) sys.exit(0)
def OrchestratorLoggerGet(): def OrchestratorLoggerGet() -> logging.Logger:
""" """
Get the logger from the Orchestrator Get the logger from the Orchestrator
@ -537,6 +537,7 @@ def OrchestratorLoggerGet():
""" """
return GSettingsGet().get("Logger",None) return GSettingsGet().get("Logger",None)
def OrchestratorScheduleGet() -> schedule: def OrchestratorScheduleGet() -> schedule:
""" """
Get the schedule (schedule.readthedocs.io) from the Orchestrator Get the schedule (schedule.readthedocs.io) from the Orchestrator

Loading…
Cancel
Save