- Robot: Logger to GlobalDict - Robot: Exclude Robot.py - Studio: Add Settings.py - All: Remove print garbage Signed-off-by: Ivan Maslov <Ivan.Maslov@UnicodeLabs.ru>dev-linux
parent
4f6b4a8e75
commit
98f22ddb58
Binary file not shown.
@ -0,0 +1,34 @@
|
|||||||
|
import logging
|
||||||
|
import datetime
|
||||||
|
#Robot settings
|
||||||
|
def Settings():
|
||||||
|
import os
|
||||||
|
mDict = {
|
||||||
|
"Logger": logging.getLogger("Robot"),
|
||||||
|
"Storage": {
|
||||||
|
"Robot_R01_help": "Robot data storage in orchestrator env",
|
||||||
|
"Robot_R01": {}
|
||||||
|
},
|
||||||
|
"ProcessBitness": {
|
||||||
|
"Python32FullPath": None, #Set from user: "..\\Resources\\WPy32-3720\\python-3.7.2\\OpenRPARobotGUIx32.exe"
|
||||||
|
"Python64FullPath": None, #Set from user
|
||||||
|
"Python32ProcessName": "OpenRPAUIDesktopX32.exe", #Config set once
|
||||||
|
"Python64ProcessName": "OpenRPAUIDesktopX64.exe" #Config set once
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#Создать файл логирования
|
||||||
|
# add filemode="w" to overwrite
|
||||||
|
if not os.path.exists("Reports"):
|
||||||
|
os.makedirs("Reports")
|
||||||
|
##########################
|
||||||
|
#Подготовка логгера Robot
|
||||||
|
#########################
|
||||||
|
mRobotLogger=mDict["Logger"]
|
||||||
|
mRobotLogger.setLevel(logging.INFO)
|
||||||
|
# create the logging file handler
|
||||||
|
mRobotLoggerFH = logging.FileHandler("Reports\ReportRobot_"+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)
|
||||||
|
############################################
|
@ -0,0 +1,34 @@
|
|||||||
|
import logging
|
||||||
|
import datetime
|
||||||
|
#Robot settings
|
||||||
|
def Settings():
|
||||||
|
import os
|
||||||
|
mDict = {
|
||||||
|
"Logger": logging.getLogger("Robot"),
|
||||||
|
"Storage": {
|
||||||
|
"Robot_R01_help": "Robot data storage in orchestrator env",
|
||||||
|
"Robot_R01": {}
|
||||||
|
},
|
||||||
|
"ProcessBitness": {
|
||||||
|
"Python32FullPath": None, #Set from user: "..\\Resources\\WPy32-3720\\python-3.7.2\\OpenRPARobotGUIx32.exe"
|
||||||
|
"Python64FullPath": None, #Set from user
|
||||||
|
"Python32ProcessName": "OpenRPAUIDesktopX32.exe", #Config set once
|
||||||
|
"Python64ProcessName": "OpenRPAUIDesktopX64.exe" #Config set once
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#Создать файл логирования
|
||||||
|
# add filemode="w" to overwrite
|
||||||
|
if not os.path.exists("Reports"):
|
||||||
|
os.makedirs("Reports")
|
||||||
|
##########################
|
||||||
|
#Подготовка логгера Robot
|
||||||
|
#########################
|
||||||
|
mRobotLogger=mDict["Logger"]
|
||||||
|
mRobotLogger.setLevel(logging.INFO)
|
||||||
|
# create the logging file handler
|
||||||
|
mRobotLoggerFH = logging.FileHandler("Reports\ReportRobot_"+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)
|
||||||
|
############################################
|
@ -0,0 +1,108 @@
|
|||||||
|
import pdb
|
||||||
|
import json
|
||||||
|
import subprocess
|
||||||
|
import zlib
|
||||||
|
import os
|
||||||
|
from . import ProcessCommunicator
|
||||||
|
import importlib
|
||||||
|
import traceback
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
import datetime
|
||||||
|
import struct
|
||||||
|
import shutil
|
||||||
|
from pyOpenRPA.Robot import UIDesktop
|
||||||
|
global mGlobalDict
|
||||||
|
####################################
|
||||||
|
#Info: Main module of the Robot app (OpenRPA - Robot)
|
||||||
|
####################################
|
||||||
|
|
||||||
|
#Usage:
|
||||||
|
#Here you can run some activity or list of activities
|
||||||
|
|
||||||
|
#After import this module you can use the folowing functions:
|
||||||
|
#ActivityRun(inActivitySpecificationDict): outActivityResultDict - function - run activity (function or procedure)
|
||||||
|
#ActivityRunJSON(inActivitySpecificationDictJSON): outActivityResultDictJSON
|
||||||
|
#ActivityListRun(inActivitySpecificationDictList): outActivityResultDictList - function - run list of activities (function or procedure)
|
||||||
|
#ActivityListRunJSON(inActivitySpecificationDictListJSON): outActivityResultDictListJSON
|
||||||
|
|
||||||
|
#Naming:
|
||||||
|
#Activity - some action/list of actions
|
||||||
|
#Module - Any *.py file, which consist of area specific functions
|
||||||
|
#Argument
|
||||||
|
|
||||||
|
#inActivitySpecificationDict:
|
||||||
|
#{
|
||||||
|
# ModuleName: <"GUI"|..., str>,
|
||||||
|
# ActivityName: <Function or procedure name in module, str>,
|
||||||
|
# ArgumentList: [<Argument 1, any type>, ...] - optional,
|
||||||
|
# ArgumentDict: {<Argument 1 name, str>:<Argument 1 value, any type>, ...} - optional
|
||||||
|
#}
|
||||||
|
|
||||||
|
#outActivityResultDict:
|
||||||
|
#{
|
||||||
|
# ActivitySpecificationDict: {
|
||||||
|
# ModuleName: <"GUI"|..., str>,
|
||||||
|
# ActivityName: <Function or procedure name in module, str>,
|
||||||
|
# ArgumentList: [<Argument 1, any type>, ...] - optional,
|
||||||
|
# ArgumentDict: {<Argument 1 name, str>: <Argument 1 value, any type>, ...} - optional
|
||||||
|
# },
|
||||||
|
# ErrorFlag: <Boolean flag - Activity result has error (true) or not (false), boolean>,
|
||||||
|
# ErrorMessage: <Error message, str> - required if ErrorFlag is true,
|
||||||
|
# ErrorTraceback: <Error traceback log, str> - required if ErrorFlag is true,
|
||||||
|
# Result: <Result, returned from the Activity, int, str, boolean, list, dict> - required if ErrorFlag is false
|
||||||
|
#}
|
||||||
|
|
||||||
|
####################
|
||||||
|
#Section: Activity
|
||||||
|
####################
|
||||||
|
def ActivityRun(inActivitySpecificationDict):
|
||||||
|
lResponseObject = {}
|
||||||
|
#Выполнить отправку в модуль UIDesktop, если ModuleName == "UIDesktop"
|
||||||
|
if inActivitySpecificationDict["ModuleName"] == "UIDesktop":
|
||||||
|
if "ArgumentList" not in inActivitySpecificationDict:
|
||||||
|
inActivitySpecificationDict["ArgumentList"]=[]
|
||||||
|
if "ArgumentDict" not in inActivitySpecificationDict:
|
||||||
|
inActivitySpecificationDict["ArgumentDict"]={}
|
||||||
|
#Run the activity
|
||||||
|
try:
|
||||||
|
#Найти функцию
|
||||||
|
lFunction=getattr(UIDesktop,inActivitySpecificationDict["ActivityName"])
|
||||||
|
#Выполнить вызов и записать результат
|
||||||
|
lResponseObject["Result"]=lFunction(*inActivitySpecificationDict["ArgumentList"],**inActivitySpecificationDict["ArgumentDict"])
|
||||||
|
except Exception as e:
|
||||||
|
#Установить флаг ошибки и передать тело ошибки
|
||||||
|
lResponseObject["ErrorFlag"]=True
|
||||||
|
lResponseObject["ErrorMessage"]=str(e)
|
||||||
|
lResponseObject["ErrorTraceback"]=traceback.format_exc()
|
||||||
|
#Остальные модули подключать и выполнять здесь
|
||||||
|
else:
|
||||||
|
lArgumentList=[]
|
||||||
|
if "ArgumentList" in inActivitySpecificationDict:
|
||||||
|
lArgumentList=inActivitySpecificationDict["ArgumentList"]
|
||||||
|
lArgumentDict={}
|
||||||
|
if "ArgumentDict" in inActivitySpecificationDict:
|
||||||
|
lArgumentDict=inActivitySpecificationDict["ArgumentDict"]
|
||||||
|
#Подготовить результирующую структуру
|
||||||
|
lResponseObject={"ActivitySpecificationDict":inActivitySpecificationDict,"ErrorFlag":False}
|
||||||
|
try:
|
||||||
|
#Подключить модуль для вызова
|
||||||
|
lModule=importlib.import_module(inActivitySpecificationDict["ModuleName"])
|
||||||
|
#Найти функцию
|
||||||
|
lFunction=getattr(lModule,inActivitySpecificationDict["ActivityName"])
|
||||||
|
#Выполнить вызов и записать результат
|
||||||
|
lResponseObject["Result"]=lFunction(*lArgumentList,**lArgumentDict)
|
||||||
|
except Exception as e:
|
||||||
|
#Установить флаг ошибки и передать тело ошибки
|
||||||
|
lResponseObject["ErrorFlag"]=True
|
||||||
|
lResponseObject["ErrorMessage"]=str(e)
|
||||||
|
lResponseObject["ErrorTraceback"]=traceback.format_exc()
|
||||||
|
return lResponseObject
|
||||||
|
#########################################################
|
||||||
|
#Run list of activities
|
||||||
|
#########################################################
|
||||||
|
def ActivityListRun(inActivitySpecificationDictList):
|
||||||
|
lResult=[]
|
||||||
|
for lItem in inActivitySpecificationDictList:
|
||||||
|
lResult.append(ActivityRun(lItem))
|
||||||
|
return lResult
|
@ -0,0 +1,48 @@
|
|||||||
|
import psutil
|
||||||
|
import datetime
|
||||||
|
import logging
|
||||||
|
|
||||||
|
#Studio settings
|
||||||
|
def Settings():
|
||||||
|
import os
|
||||||
|
mDict = {
|
||||||
|
"Server": {
|
||||||
|
"ListenPort_": "Порт, по которому можно подключиться к демону",
|
||||||
|
"ListenPort": 8081,
|
||||||
|
"ListenURLList": [
|
||||||
|
{
|
||||||
|
"Description": "Local machine test",
|
||||||
|
"URL_": "Сетевое расположение сервера демона",
|
||||||
|
"URL": "http://127.0.0.1:8081"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"Logger": logging.getLogger("Studio"),
|
||||||
|
"Storage": {
|
||||||
|
"Robot_R01_help": "Robot data storage in orchestrator env",
|
||||||
|
"Robot_R01": {}
|
||||||
|
},
|
||||||
|
"ProcessBitness": { #Section for robot init
|
||||||
|
"Python32FullPath": "..\\Resources\\WPy32-3720\\python-3.7.2\\python.exe", #Set from user: "..\\Resources\\WPy32-3720\\python-3.7.2\\OpenRPARobotGUIx32.exe"
|
||||||
|
"Python64FullPath": "..\\Resources\\WPy64-3720\\python-3.7.2.amd64\\python.exe", #Set from user
|
||||||
|
"Python32ProcessName": "OpenRPAUIDesktopX32.exe", #Config set once
|
||||||
|
"Python64ProcessName": "OpenRPAUIDesktopX64.exe" #Config set once
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#Создать файл логирования
|
||||||
|
# add filemode="w" to overwrite
|
||||||
|
if not os.path.exists("Reports"):
|
||||||
|
os.makedirs("Reports")
|
||||||
|
##########################
|
||||||
|
#Подготовка логгера Robot
|
||||||
|
#########################
|
||||||
|
mRobotLogger=mDict["Logger"]
|
||||||
|
mRobotLogger.setLevel(logging.INFO)
|
||||||
|
# create the logging file handler
|
||||||
|
mRobotLoggerFH = logging.FileHandler("Reports\ReportStudio_"+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)
|
||||||
|
############################################
|
||||||
|
return mDict
|
@ -1,4 +1,4 @@
|
|||||||
cd %~dp0\..\Sources
|
cd %~dp0\..\Sources
|
||||||
copy /Y ..\Resources\WPy64-3720\python-3.7.2.amd64\python.exe ..\Resources\WPy64-3720\python-3.7.2.amd64\OpenRPA_Studio.exe
|
copy /Y ..\Resources\WPy64-3720\python-3.7.2.amd64\python.exe ..\Resources\WPy64-3720\python-3.7.2.amd64\OpenRPA_Studio.exe
|
||||||
.\..\Resources\WPy64-3720\python-3.7.2.amd64\OpenRPA_Studio.exe -m pyOpenRPA.Studio
|
.\..\Resources\WPy64-3720\python-3.7.2.amd64\OpenRPA_Studio.exe -m pyOpenRPA.Studio "..\Studio\Settings.py"
|
||||||
pause >nul
|
pause >nul
|
Loading…
Reference in new issue