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.
74 lines
2.8 KiB
74 lines
2.8 KiB
2 years ago
|
from pyOpenRPA.Tools import CrossOS
|
||
|
import os
|
||
|
import sys
|
||
|
import time
|
||
|
import json
|
||
|
from pyOpenRPA import Orchestrator
|
||
|
from datetime import date
|
||
|
from pyOpenRPA.Orchestrator.Server import app
|
||
|
import threading
|
||
|
from fastapi import Depends, Body
|
||
|
from fastapi.responses import PlainTextResponse
|
||
|
from fastapi.responses import FileResponse
|
||
|
time.sleep(1.5) # Определить очередность в панели управления
|
||
|
from fastapi.staticfiles import StaticFiles
|
||
|
# путь к папке, в которой расположена панель управления (используется для формирования других путей)
|
||
|
cp_path_str = CrossOS.PathJoinList(CrossOS.PathSplitList(__file__)[:-1])
|
||
|
|
||
|
#AGENT SETTINGS
|
||
|
agent_hostname_str = ""
|
||
|
agent_username_str = ""
|
||
|
|
||
|
# ROBOT SETTINGS
|
||
|
robot_logs_path_str = f"{cp_path_str}"
|
||
|
|
||
|
|
||
|
gSettings = Orchestrator.GSettingsGet()
|
||
|
|
||
|
|
||
|
# календарь
|
||
|
robot_key_str = "SIMPLE_01"
|
||
|
|
||
|
# Подключить папку
|
||
|
#app.mount(f"/{robot_key_str}/calendar", StaticFiles(directory=os.path.join(os.path.abspath(cpPathStr), "calendar")), name=f"{robot_key_str}_calendar")
|
||
|
|
||
|
|
||
|
# пути для ...
|
||
|
htmlPath = os.path.join(cp_path_str, "index.html")
|
||
|
scriptPath = os.path.join(cp_path_str, f"scripts.js")
|
||
|
|
||
|
# вывод папки логов
|
||
|
def check_folder(folder):
|
||
|
files = os.listdir(folder)
|
||
|
return files[::-1]
|
||
|
app.mount(f"/{robot_key_str}/logs", StaticFiles(directory=robot_logs_path_str), name=f"{robot_key_str}-logs")
|
||
|
|
||
|
@app.get(path=f"/{robot_key_str}/scripts.js",tags=[f"{robot_key_str}"])
|
||
|
def get_file2():
|
||
|
return FileResponse(os.path.abspath(scriptPath))
|
||
|
|
||
|
# сторонние файлы
|
||
|
infoPath = os.path.join(cp_path_str, "how_to.docx")
|
||
|
@app.get(path=f"/{robot_key_str}/how_to.docx",tags=[f"{robot_key_str}"])
|
||
|
def get_file():
|
||
|
return FileResponse(os.path.abspath(infoPath))
|
||
|
|
||
|
#проверка процесса
|
||
|
def process_is_started():
|
||
|
return Orchestrator.ProcessIsStarted(inProcessNameWOExeStr = robot_key_str)
|
||
|
|
||
|
# функции для запуска процессов
|
||
|
buildPathStr = CrossOS.PathJoinList(CrossOS.PathSplitList(__file__)[:-3]+["builds"])
|
||
|
startHandPathStr = os.path.join(buildPathStr, "startHand.cmd")
|
||
|
def startHand():
|
||
|
Orchestrator.AgentOSCMD(inHostNameStr=agent_hostname_str, inUserStr=agent_username_str, inCMDStr=startHandPathStr, inRunAsyncBool=True, inSendOutputToOrchestratorLogsBool=False, inCaptureBool=False)
|
||
|
@app.get(path=f"/{robot_key_str}/startHand",tags=[f"{robot_key_str}"])
|
||
|
def start_app():
|
||
|
startHand()
|
||
|
|
||
|
# инициализация панели
|
||
|
lCPManager = Orchestrator.Managers.ControlPanel(inControlPanelNameStr=robot_key_str,
|
||
|
inRefreshHTMLJinja2TemplatePathStr=htmlPath, inJinja2TemplateRefreshBool = True)
|
||
|
contextDict = {"config": sys.modules[__name__]}
|
||
|
lCPManager.Jinja2DataUpdateDictSet(inJinja2DataUpdateDict=contextDict)
|