You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
8.4 KiB
174 lines
8.4 KiB
5 years ago
|
#Robot RDPActive settings
|
||
5 years ago
|
from pyOpenRPA.Robot import OrchestratorConnector
|
||
5 years ago
|
from pyOpenRPA.Tools import RobotRDPActive # For RobotRDPActive folder purposes
|
||
5 years ago
|
import os
|
||
|
import logging
|
||
|
import datetime
|
||
5 years ago
|
import sys
|
||
5 years ago
|
#Definitions
|
||
|
lOrchestratorHost="localhost"
|
||
|
lOrchestratorPort=8081
|
||
|
lOrchestratorProtocol="http"
|
||
|
lOrchestratorAuthToken="1992-04-03-0643-ru-b4ff-openrpa52zzz"
|
||
5 years ago
|
gRobotName="RobotRDPActive"
|
||
5 years ago
|
lRobotRDPActiveFolderPath = '\\'.join(RobotRDPActive.__file__.split('\\')[:-1])
|
||
5 years ago
|
#print(f"{os.path.join(lRobotRDPActiveFolderPath,'SessionDefs.py')}")
|
||
5 years ago
|
def Settings():
|
||
|
mDict = {
|
||
|
"RDPList":
|
||
|
[
|
||
|
{
|
||
|
"Host": "77.77.22.22", # Host address
|
||
|
"Port": "7777", # RDP Port
|
||
|
"Login": "test", # Login
|
||
|
"Password": "test", # Password
|
||
|
"Screen": {
|
||
|
"Width": 1680, #Width of the remote desktop in pixels
|
||
|
"Height": 1050, #Height of the remote desktop in pixels
|
||
|
# "640x480" or "1680x1050" or "FullScreen". If Resolution not exists set full screen
|
||
|
"FlagUseAllMonitors": False, # True or False
|
||
|
"DepthBit": "32" # "32" or "24" or "16" or "15"
|
||
|
},
|
||
5 years ago
|
"SharedDriveList":["c"], # List of the Root sesion hard drives
|
||
5 years ago
|
###### Will updated in program ############
|
||
5 years ago
|
"SessionHex":"", # Hex is created when robot runs
|
||
5 years ago
|
"SessionIsWindowExistBool": False , # Flag if the RDP window is exist, old name "FlagSessionIsActive". Check every n seconds
|
||
|
"SessionIsWindowResponsibleBool": False # Flag if RDP window is responsible (recieve commands). Check every nn seconds. If window is Responsible - window is Exist too
|
||
5 years ago
|
}
|
||
|
],
|
||
5 years ago
|
"ResponsibilityCheckIntervalSec": None, # Seconds interval when Robot check the RDP responsibility. if None - dont check
|
||
5 years ago
|
"FullScreenSessionIndex": None, #Index of the current session which is full screened, None is no session in fullscreen
|
||
5 years ago
|
"Logger": logging.getLogger(gRobotName),
|
||
5 years ago
|
"Logs": {
|
||
|
"FlagShowInConsole":True
|
||
|
},
|
||
5 years ago
|
"OrchestratorToRobotStorage": {
|
||
5 years ago
|
"FullScreenSessionIndex":None, #Index of the session which is full screen in GUI. None if no session in full screen
|
||
|
"IgnoreIndexList":[]
|
||
5 years ago
|
},
|
||
|
"OrchestratorToRobotResetStorage": {
|
||
5 years ago
|
"SafeTurnOff":False ,#Control from orchestrator to safety turn off robot
|
||
5 years ago
|
"ActivityList":[
|
||
5 years ago
|
#{
|
||
|
# "ModulePath": f"{os.path.join(lRobotRDPActiveFolderPath,'SessionDefs.py')}", # "Session\\SessionDefs.py"
|
||
|
# "DefName":"test", # Function name
|
||
|
# "ArgList":[1,2,3], # Args list
|
||
|
# "ArgDict":{"ttt":1,"222":2,"dsd":3} # Args dictionary
|
||
|
#}
|
||
5 years ago
|
]
|
||
5 years ago
|
},
|
||
|
"OrchestratorConnector": {
|
||
|
#Fill below
|
||
|
},
|
||
5 years ago
|
"OrchestratorConnectorTerminateAll":OrchestratorConnector.IntervalTerminateAll, #Call this function when program must be shutted down (to kill threads from OrchestratorConnector)
|
||
|
"Scheduler":None # !!! Will be filled below
|
||
|
}
|
||
|
###############
|
||
|
# Scheduler operations for RDP
|
||
|
###############
|
||
|
mDict["Scheduler"]={
|
||
|
"ActivityTimeCheckLoopSeconds":5, #Количество секунд, между циклами проверки действий
|
||
|
"ActivityTimeList": [
|
||
|
{
|
||
|
"TimeHH:MM": "22:23", #Time [HH:MM] to trigger activity
|
||
|
"WeekdayList": [1,2,3,4,5,6,7], #List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7]
|
||
|
"Activity":{
|
||
|
"ModulePath": f"{os.path.join(lRobotRDPActiveFolderPath,'GlobalDictSessionIndex_Defs.py')}", # "Session\\SessionDefs.py"
|
||
|
"DefName":"ProcessStop", # Function name
|
||
|
"ArgList":[], # Args list
|
||
|
"ArgDict":{"inGlobalDict": mDict, "inSessionIndex": 0, "inProcessName": "notepad.exe", "inFlagForceClose":True} # Args dictionary
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"TimeHH:MMStart": "12:40", #Time [HH:MM] to trigger activity
|
||
|
"TimeHH:MMStop": "17:10",
|
||
|
"ActivityIntervalSeconds": 5,
|
||
|
"WeekdayList": [1, 2, 3, 4, 5, 6, 7], #List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7]
|
||
|
"Activity":{
|
||
|
"ModulePath": f"{os.path.join(lRobotRDPActiveFolderPath,'GlobalDictSessionIndex_Defs.py')}", # "RobotRDPActive\\SessionDefs.py"
|
||
|
"DefName":"ProcessStartIfNotRunning", # Function name
|
||
|
"ArgList":[], # Args list
|
||
|
"ArgDict":{"inGlobalDict": mDict, "inSessionIndex": 0, "inProcessName": "notepad.exe", "inFilePath": "notepad"} # Args dictionary
|
||
|
}
|
||
|
}
|
||
|
]
|
||
5 years ago
|
}
|
||
|
######################
|
||
|
#OrchestratorConnector
|
||
|
######################
|
||
|
mDict["OrchestratorConnector"]={
|
||
|
"IntervalDataSendAsync": [
|
||
|
{
|
||
5 years ago
|
"Interval": 1.1,
|
||
5 years ago
|
"RobotStorage": mDict,
|
||
|
"RobotStorageKey": "RDPList",
|
||
5 years ago
|
"OrchestratorKeyList": ["Storage", gRobotName,"RobotToOrchestratorStorage","RDPList"],
|
||
5 years ago
|
"OrchestratorProtocol": lOrchestratorProtocol,
|
||
|
"OrchestratorHost": lOrchestratorHost,
|
||
|
"OrchestratorPort": lOrchestratorPort,
|
||
|
"OrchestratorAuthToken": lOrchestratorAuthToken
|
||
5 years ago
|
},
|
||
|
{
|
||
5 years ago
|
"Interval": 1,
|
||
5 years ago
|
"RobotStorage": mDict,
|
||
|
"RobotStorageKey": "RDPList",
|
||
5 years ago
|
"OrchestratorKeyList": ["Storage", gRobotName,"RobotToOrchestratorStorage","FullScreenSessionIndex"],
|
||
5 years ago
|
"OrchestratorProtocol": lOrchestratorProtocol,
|
||
|
"OrchestratorHost": lOrchestratorHost,
|
||
|
"OrchestratorPort": lOrchestratorPort,
|
||
|
"OrchestratorAuthToken": lOrchestratorAuthToken
|
||
5 years ago
|
}
|
||
|
],
|
||
|
"IntervalDataReceiveResetAsync": [
|
||
|
{
|
||
5 years ago
|
"Interval": 1.05,
|
||
5 years ago
|
"RobotStorage": mDict,
|
||
|
"RobotStorageKey": "OrchestratorToRobotResetStorage",
|
||
5 years ago
|
"RobotResetValue": mDict["OrchestratorToRobotResetStorage"],
|
||
5 years ago
|
"OrchestratorKeyList": ["Storage", gRobotName,"OrchestratorToRobotResetStorage"],
|
||
5 years ago
|
"OrchestratorProtocol": lOrchestratorProtocol,
|
||
|
"OrchestratorHost": lOrchestratorHost,
|
||
|
"OrchestratorPort": lOrchestratorPort,
|
||
|
"OrchestratorAuthToken": lOrchestratorAuthToken
|
||
|
}
|
||
|
],
|
||
|
"IntervalDataReceiveAsync": [
|
||
|
{
|
||
5 years ago
|
"Interval": 1.25,
|
||
5 years ago
|
"RobotStorage": mDict,
|
||
|
"RobotStorageKey": "OrchestratorToRobotStorage",
|
||
5 years ago
|
"OrchestratorKeyList": ["Storage", gRobotName,"OrchestratorToRobotStorage"],
|
||
5 years ago
|
"OrchestratorProtocol": lOrchestratorProtocol,
|
||
|
"OrchestratorHost": lOrchestratorHost,
|
||
|
"OrchestratorPort": lOrchestratorPort,
|
||
|
"OrchestratorAuthToken": lOrchestratorAuthToken
|
||
5 years ago
|
}
|
||
|
]
|
||
|
}
|
||
5 years ago
|
#Turn off many warnings from orchestrator connector logger
|
||
|
OrchestratorConnector.LoggerSetLevelError()
|
||
|
#Run OrchestratorConnector initialization
|
||
|
OrchestratorConnector.ConfigurationInit(mDict["OrchestratorConnector"])
|
||
|
#########################
|
||
|
#Создать файл логирования
|
||
|
# add filemode="w" to overwrite
|
||
|
if not os.path.exists("Reports"):
|
||
|
os.makedirs("Reports")
|
||
|
##########################
|
||
|
#Подготовка логгера Robot
|
||
|
#########################
|
||
|
mRobotLogger=mDict["Logger"]
|
||
5 years ago
|
mRobotLogger.setLevel(logging.INFO) #logging.DEBUG
|
||
5 years ago
|
# create the logging file handler
|
||
|
mRobotLoggerFH = logging.FileHandler("Reports\ReportRobotRDPActive_"+datetime.datetime.now().strftime("%Y_%m_%d")+".log")
|
||
|
mRobotLoggerFormatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||
|
mRobotLoggerFH.setFormatter(mRobotLoggerFormatter)
|
||
|
# add handler to logger object
|
||
|
mRobotLogger.addHandler(mRobotLoggerFH)
|
||
5 years ago
|
####################Add console output
|
||
|
if mDict["Logs"]["FlagShowInConsole"]:
|
||
|
handler = logging.StreamHandler(sys.stdout)
|
||
5 years ago
|
handler.setFormatter(mRobotLoggerFormatter)
|
||
5 years ago
|
mRobotLogger.addHandler(handler)
|
||
5 years ago
|
############################################
|
||
5 years ago
|
return mDict
|