From 7af278e208d7c8d46dd312a607abba5599764c30 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Fri, 28 Oct 2022 08:32:59 +0300 Subject: [PATCH] cp demo: add buyer 01, improve cp hr, oper, implement one python configure cmd in scripts --- Orchestrator/Demo/BUYER_01/buyer_01.js | 29 +++++++ Orchestrator/Demo/BUYER_01/config.py | 42 ++++++++++ Orchestrator/Demo/BUYER_01/index.html | 82 ++++++++++++++++++++ Orchestrator/Demo/HR_01/config.py | 2 +- Orchestrator/Demo/HR_01/index.html | 2 +- Orchestrator/Demo/OPER_01/html_jinja2.xhtml | 2 +- Orchestrator/Demo/TREASURER_01/config.py | 2 +- Orchestrator/Demo/TREASURER_01/index.html | 2 +- Orchestrator/Template_Settings_AccessUser.py | 52 ------------- Orchestrator/config.py | 4 +- Orchestrator/init-python-env.cmd | 24 ------ Orchestrator/start-python-env.cmd | 4 - Orchestrator/start.cmd | 5 +- {Git => Scripts}/Branch_devIvan_master.cmd | 0 {Git => Scripts}/Clean.cmd | 0 {Git => Scripts}/Pull.cmd | 0 Scripts/PythonWinConfigure.cmd | 75 ++++++++++++++++++ Scripts/PythonWinInit.cmd | 24 ++++++ {Git => Scripts}/RevisionLastUpdate.cmd | 0 19 files changed, 262 insertions(+), 89 deletions(-) create mode 100644 Orchestrator/Demo/BUYER_01/buyer_01.js create mode 100644 Orchestrator/Demo/BUYER_01/config.py create mode 100644 Orchestrator/Demo/BUYER_01/index.html delete mode 100755 Orchestrator/Template_Settings_AccessUser.py delete mode 100644 Orchestrator/init-python-env.cmd delete mode 100644 Orchestrator/start-python-env.cmd rename {Git => Scripts}/Branch_devIvan_master.cmd (100%) rename {Git => Scripts}/Clean.cmd (100%) rename {Git => Scripts}/Pull.cmd (100%) create mode 100644 Scripts/PythonWinConfigure.cmd create mode 100644 Scripts/PythonWinInit.cmd rename {Git => Scripts}/RevisionLastUpdate.cmd (100%) diff --git a/Orchestrator/Demo/BUYER_01/buyer_01.js b/Orchestrator/Demo/BUYER_01/buyer_01.js new file mode 100644 index 00000000..5da84170 --- /dev/null +++ b/Orchestrator/Demo/BUYER_01/buyer_01.js @@ -0,0 +1,29 @@ +$('.ui.dropdown') + .dropdown('clear') +; + + + +var content = [ +]; + +let i = 1 +document.getElementById("buyNumber").innerHTML = i + + +$('.ui.search') + .search({ + source: content + }) +; + +function buy_confirm() { + j = String(i) + content.push({ title: j }) + $('.ui.search').search({source: content}) + i=i+1; + document.getElementById("buyNumber").innerHTML = i; + $('.ui.dropdown').dropdown('clear') +} + + \ No newline at end of file diff --git a/Orchestrator/Demo/BUYER_01/config.py b/Orchestrator/Demo/BUYER_01/config.py new file mode 100644 index 00000000..7934f891 --- /dev/null +++ b/Orchestrator/Demo/BUYER_01/config.py @@ -0,0 +1,42 @@ + +from pyOpenRPA import Orchestrator +from pyOpenRPA.Orchestrator.Managers import ControlPanel +import time +import os +import sys +import socket +import datetime +import urllib.parse +from pyOpenRPA.Orchestrator.Server import app +import threading +from fastapi import Depends +from fastapi.responses import PlainTextResponse +from fastapi.responses import FileResponse +time.sleep(1.5) + + + +g_cp_name_str = "BUYER_01" +g_repo_name_str = os.path.abspath(__file__).split("\\")[-5] +g_repo_package_cp_path_str = os.path.abspath("\\".join(os.path.abspath(__file__).split("\\")[:-1])) + +# Подключени файлов связанных с роботом-казначеем01 +@app.get(path="/BUYER_01/scripts",tags=["BUYER_01"]) +def get_file(): + return FileResponse("Demo\\BUYER_01\\buyer_01.js") + + +# User settings +g_host_str = socket.gethostname().upper() # Identify PC + +g_control_panel = ControlPanel(inControlPanelNameStr=g_cp_name_str, + inRefreshHTMLJinja2TemplatePathStr=os.path.join(g_repo_package_cp_path_str, "index.html"), + inJinja2TemplateRefreshBool=True,inRobotNameStr=g_repo_name_str) +g_jinja_context_dict = {"settings": sys.modules[__name__], + "urllib_parse_quote_plus": urllib.parse.quote_plus, "g_host_str": g_host_str, "g_repo_name_str": g_repo_name_str} +g_control_panel.Jinja2DataUpdateDictSet(inJinja2DataUpdateDict=g_jinja_context_dict) + + + + + diff --git a/Orchestrator/Demo/BUYER_01/index.html b/Orchestrator/Demo/BUYER_01/index.html new file mode 100644 index 00000000..237de8e9 --- /dev/null +++ b/Orchestrator/Demo/BUYER_01/index.html @@ -0,0 +1,82 @@ + + + + + + Treasurer + + + + + + +
+
+

ЗАКУПЩИК


+
+
Применение:
+

Робот-закупщик осуществляет закупку товаров по выбранным параметрам

+
+ +

Оформление закупки

+
+
Номер закупки -
+
+

+ +
Выбор товара
+

+ + + +

+ +
Выбор адреса доставки
+

+ + + +

+ +
Номер счета для оплаты
+

+ + +

+ + +
+
+ + + + + + + \ No newline at end of file diff --git a/Orchestrator/Demo/HR_01/config.py b/Orchestrator/Demo/HR_01/config.py index c11f379b..73167374 100644 --- a/Orchestrator/Demo/HR_01/config.py +++ b/Orchestrator/Demo/HR_01/config.py @@ -56,7 +56,7 @@ html = f''' -
+

{title}


diff --git a/Orchestrator/Demo/HR_01/index.html b/Orchestrator/Demo/HR_01/index.html index 3cbd542f..673fba2e 100644 --- a/Orchestrator/Demo/HR_01/index.html +++ b/Orchestrator/Demo/HR_01/index.html @@ -11,7 +11,7 @@ -
+

КАДРОВИК


diff --git a/Orchestrator/Demo/OPER_01/html_jinja2.xhtml b/Orchestrator/Demo/OPER_01/html_jinja2.xhtml index 0525c66c..5e5b442c 100644 --- a/Orchestrator/Demo/OPER_01/html_jinja2.xhtml +++ b/Orchestrator/Demo/OPER_01/html_jinja2.xhtml @@ -1,4 +1,4 @@ -
+
OPER_00 diff --git a/Orchestrator/Demo/TREASURER_01/config.py b/Orchestrator/Demo/TREASURER_01/config.py index d2975eb3..1b15d9ee 100644 --- a/Orchestrator/Demo/TREASURER_01/config.py +++ b/Orchestrator/Demo/TREASURER_01/config.py @@ -60,7 +60,7 @@ html = f''' -
+

{title}


diff --git a/Orchestrator/Demo/TREASURER_01/index.html b/Orchestrator/Demo/TREASURER_01/index.html index c429188b..0f49c598 100644 --- a/Orchestrator/Demo/TREASURER_01/index.html +++ b/Orchestrator/Demo/TREASURER_01/index.html @@ -10,7 +10,7 @@ -
+

КАЗНАЧЕЙ


diff --git a/Orchestrator/Template_Settings_AccessUser.py b/Orchestrator/Template_Settings_AccessUser.py deleted file mode 100755 index f8b8b4ae..00000000 --- a/Orchestrator/Template_Settings_AccessUser.py +++ /dev/null @@ -1,52 +0,0 @@ -# Role model - if len of keys in dict is 0 - all access. If at least len is 1 - only this access -# "Orchestrator":{ -# "Controls": { -# "RestartOrchestrator": {}, # Feature to restart orchestrator on virtual machine -# "LookMachineScreenshots": {} # Feature to look machina screenshots -# }, -# "RDPActive": { # Robot RDP active module -# "ListRead": {} # Access to read RDP session list -# "RestartPC": {} # Restart PC -# "GITRestartOrchestrator": {} # Update GIT + restart orchestrator -# } -# } -# } - -# USAGE in .py -# inRequest. -# inRequest.OpenRPA["DefUserRoleAccessAsk"](["Orchestrator","RDPActive","Controls"]) - return True or False -# inRequest.OpenRPA["DefUserRoleHierarchyGet"]() - Return dict of the role hierarchy or {} - -# Init Section -gUserNameStr = "Login" # User name without domain name -gDomainNameStr = "" # DOMAIN or EMPTY str if no domain -gDomainIsDefaultBool = True # If domain is exist and is default (default = you can type login without domain name) - -def SettingsUpdate(inDict): - lRuleDomainUserDict = { - "MethodMatchURLBeforeList": [ - { - "Method":"GET", - "MatchType":"Beginwith", - "URL":"/", - #"FlagAccessDefRequestGlobalAuthenticate": TestDef - "FlagAccess": True - }, - { - "Method":"POST", - "MatchType":"Beginwith", - "URL":"/", - #"FlagAccessDefRequestGlobalAuthenticate": TestDef - "FlagAccess": True - } - ], - "ControlPanelKeyAllowedList": ["TestControlPanel", "RobotRDPActive","RobotScreenActive", "ControlPanel_Template"], # If empty - all is allowed - "RoleHierarchyAllowedDict": {"Key1":"Test"} - } - # Case add domain + user - inDict["Server"]["AccessUsers"]["RuleDomainUserDict"].update({(gDomainNameStr.upper(),gUserNameStr.upper()):lRuleDomainUserDict}) - if gDomainIsDefaultBool: - # Case add default domain + user - inDict["Server"]["AccessUsers"]["RuleDomainUserDict"].update({("",gUserNameStr.upper()):lRuleDomainUserDict}) - #Return current dict - return inDict \ No newline at end of file diff --git a/Orchestrator/config.py b/Orchestrator/config.py index 67651dea..fd6f85f3 100755 --- a/Orchestrator/config.py +++ b/Orchestrator/config.py @@ -60,7 +60,9 @@ else: Orchestrator.OrchestratorSessionRestore(inGSettings=gSettings) # Autoinit control panels starts with CP_ lPyModules = Orchestrator.OrchestratorPySearchInit(inGlobPatternStr="Demo\\*\\config.py", inAsyncInitBool=True) - # Call the orchestrator def + lPyModules2 = Orchestrator.OrchestratorPySearchInit(inGlobPatternStr="..\\..\\KPI_Effect\\packages\\*_control_panel\\config.py", inAsyncInitBool=True, inPackageLevelInt=1) + + # Call the orchestrator def Orchestrator.Orchestrator(inGSettings=gSettings, inDumpRestoreBool=False) diff --git a/Orchestrator/init-python-env.cmd b/Orchestrator/init-python-env.cmd deleted file mode 100644 index aae57995..00000000 --- a/Orchestrator/init-python-env.cmd +++ /dev/null @@ -1,24 +0,0 @@ -chcp 65001 -@echo off -echo Формат использования init-python-env.cmd [имя запускаемого процесса.exe] [имя убиваемого процесса.exe] -echo Пример использования init-python-env.cmd orpa-rbt.exe orpa-rbt.exe - -if [%1]==[] goto :python-env -goto create-exe -:create-exe -copy /Y "%~dp0..\Resources\WPy64-3720\python-3.7.2.amd64\python.exe" "%~dp0..\Resources\WPy64-3720\python-3.7.2.amd64\%1" -if [%2]==[] goto :python-env -goto taskkill -:taskkill -taskkill /im "%2" /F /fi "username eq %username%" -goto :python-env -:python-env -set CD_PREV=%cd% -cd /d "%~dp0..\Resources\WPy64-3720\python-3.7.2.amd64" -set PATH=%cd%;%cd%\Scripts;%PATH% -cd /d "%~dp0..\Sources" -set PYTHONPATH=%cd%;%PYTHONPATH% -cd %CD_PREV% -:eof -echo Инициализация Python окружения прошла успешно! -@echo on \ No newline at end of file diff --git a/Orchestrator/start-python-env.cmd b/Orchestrator/start-python-env.cmd deleted file mode 100644 index 652bdcbf..00000000 --- a/Orchestrator/start-python-env.cmd +++ /dev/null @@ -1,4 +0,0 @@ -chcp 65001 -cd /d "%~dp0" -call init-python-env.cmd orpa-rbt.exe orpa-rbt.exe -cmd \ No newline at end of file diff --git a/Orchestrator/start.cmd b/Orchestrator/start.cmd index 6d5c46da..0a516c5d 100755 --- a/Orchestrator/start.cmd +++ b/Orchestrator/start.cmd @@ -1,5 +1,4 @@ chcp 65001 cd /d "%~dp0" -call init-python-env.cmd orpa-orc.exe orpa-orc.exe -orpa-orc.exe "config.py" -pause>nul \ No newline at end of file +call .\..\Scripts\PythonWinInit.cmd script orpa-orc.exe orpa-orc.exe +orpa-orc.exe "config.py" \ No newline at end of file diff --git a/Git/Branch_devIvan_master.cmd b/Scripts/Branch_devIvan_master.cmd similarity index 100% rename from Git/Branch_devIvan_master.cmd rename to Scripts/Branch_devIvan_master.cmd diff --git a/Git/Clean.cmd b/Scripts/Clean.cmd similarity index 100% rename from Git/Clean.cmd rename to Scripts/Clean.cmd diff --git a/Git/Pull.cmd b/Scripts/Pull.cmd similarity index 100% rename from Git/Pull.cmd rename to Scripts/Pull.cmd diff --git a/Scripts/PythonWinConfigure.cmd b/Scripts/PythonWinConfigure.cmd new file mode 100644 index 00000000..79b90cc6 --- /dev/null +++ b/Scripts/PythonWinConfigure.cmd @@ -0,0 +1,75 @@ +chcp 65001 +if [%1]==[echo_on] goto :program +:echo_no +set TEMP_ECHO_NO=TRUE +@echo off +:program +if NOT "%PYTHON_CONFIGURE%"=="" goto :echo_check +set PYTHON_CONFIGURE=%~f0 +set CD_PREV=%cd% +rem "%~dp0..\Resources" - УСТАНОВКА ПУТИ ОТ РАСПОЛОЖЕНИЯ ФАЙЛА, В КОТОРОМ НАПИСАН ЭТОТ ТЕКСТ. ВНИМАНИЕ! ПОСЛЕ %~dp0 СИМВОЛ \ СТАВИТЬ НЕ ТРЕБУЕТСЯ +rem "%cd%\..\Resources" - УСТАНОВКА ПУТИ ОТ РАБОЧЕЙ ДИРЕКТОРИИ, В КОТОРОЙ БЫЛ ВЫЗВАН ЭТОТ СКРИПТ. ВНИМАНИЕ! ПОСЛЕ %cd% СИМВОЛ \ СТАВИТЬ ТРЕБУЕТСЯ ОБЯЗАТЕЛЬНО +rem Пример использования python-win-configure.cmd python - выполнить команду python в настроенном окружении + +goto comment_set_path +rem ПРИМЕР КОНСТРУКЦИИ ДЛЯ ДОБАВЛЕНИЯ ДИРЕКТОРИИ В ПЕРЕМЕННУЮ ОКРУЖЕНИЯ PATH +set TEMP_LOCATION="%~dp0..\Resources\WPy64-3720\python-3.7.2.amd64" +cd /d %TEMP_LOCATION% +set PATH=%cd%;%PATH% +rem ВНИМАНИЕ! ЗНАК = ДОЛЖЕН БЫТЬ УСТАНОВЛЕН ВПРИТЫК С ПЕРЕМЕННОЙ ОКРУЖЕНИЯ И ЗНАЧЕНИЕМ - ИНАЧЕ УСТАНОВКА ЗНАЧЕНИЯ БУДЕТ ПРОИЗВЕДЕНА НЕКОРРЕКТНО +:comment_set_path + +goto comment_set_pythonpath +rem ПРИМЕР КОНСТРУКЦИИ ДЛЯ ДОБАВЛЕНИЯ ДИРЕКТОРИИ В ПЕРЕМЕННУЮ ОКРУЖЕНИЯ PYTHONPATH +set TEMP_LOCATION="%~dp0..\Sources" +cd /d %TEMP_LOCATION% +set PYTHONPATH=%cd%;%PYTHONPATH% +rem ВНИМАНИЕ! ЗНАК = ДОЛЖЕН БЫТЬ УСТАНОВЛЕН ВПРИТЫК С ПЕРЕМЕННОЙ ОКРУЖЕНИЯ И ЗНАЧЕНИЕМ - ИНАЧЕ УСТАНОВКА ЗНАЧЕНИЯ БУДЕТ ПРОИЗВЕДЕНА НЕКОРРЕКТНО +:comment_set_pythonpath + +rem ЗОНА УСТАНОВКИ ПЕРЕМЕННЫХ ОКРУЖЕНИЯ! +:configure +set TEMP_LOCATION="%~dp0..\Resources\WPy64-3720\python-3.7.2.amd64\Scripts" +cd /d %TEMP_LOCATION% +set PATH=%cd%;%PATH% + +set TEMP_LOCATION="%~dp0..\Resources\WPy64-3720\python-3.7.2.amd64" +cd /d %TEMP_LOCATION% +set PATH=%cd%;%PATH% + +set TEMP_LOCATION="%~dp0..\Sources" +cd /d %TEMP_LOCATION% +set PYTHONPATH=%cd%;%PYTHONPATH% + +rem восстановление каталога рабочей директории программы +cd %CD_PREV% + +rem выполнить вызов, если есть параметры, начиная с %2+ +if "%1"=="" goto :echo_check +set ORPA_ARGV= +rem один shift - все параметры, начиная с %2 (или с %1, если не echo_on) +if "%1"=="echo_on" shift +:loop1 +if "%1"=="" goto after_loop +if "%ORPA_ARGV%"=="" goto :no_param +set ORPA_ARGV=%ORPA_ARGV% %1 +goto :loop1_next +:no_param +set ORPA_ARGV=%1 +:loop1_next +shift +goto loop1 +:after_loop +echo PYTHON-CONFIGURE: ОБНАРУЖЕНЫ ПАРАМЕТРЫ ИНИЦИАЛИЗАЦИИ ПРОГРАММЫ: %ORPA_ARGV% + +:echo_check +rem включить Echo, если он был принудительно выключен +if NOT [%TEMP_ECHO_NO%]==[] goto :echo_on +goto :eof +:echo_on +@echo on +:eof +if "%ORPA_ARGV%"=="" goto :eof2 +%ORPA_ARGV% +pause>nul +:eof2 \ No newline at end of file diff --git a/Scripts/PythonWinInit.cmd b/Scripts/PythonWinInit.cmd new file mode 100644 index 00000000..89840a9c --- /dev/null +++ b/Scripts/PythonWinInit.cmd @@ -0,0 +1,24 @@ +@echo off +chcp 65001 +echo Формат использования PythonWinInit.cmd [console,script] [имя запускаемого процесса.exe] [имя убиваемого процесса.exe] +echo Пример использования PythonWinInit.cmd script orpa-rbt.exe orpa-rbt.exe + +if [%2]==[] goto :python-env +goto create-exe +:create-exe +copy /Y "%~dp0..\Resources\WPy64-3720\python-3.7.2.amd64\python.exe" "%~dp0..\Resources\WPy64-3720\python-3.7.2.amd64\%2" +if [%3]==[] goto :python-env +goto taskkill +:taskkill +taskkill /im "%3" /F /fi "username eq %username%" +goto :python-env +:python-env +call "%~dp0PythonWinConfigure.cmd" +echo Инициализация Python окружения прошла успешно! +if [%1]==[] goto :console +if [%1]==[console] goto :console +goto :eof +:console +cmd +:eof +@echo on \ No newline at end of file diff --git a/Git/RevisionLastUpdate.cmd b/Scripts/RevisionLastUpdate.cmd similarity index 100% rename from Git/RevisionLastUpdate.cmd rename to Scripts/RevisionLastUpdate.cmd