add some utils

prd
Ivan Maslov 2 years ago
parent 1078c8ee2c
commit 6bfa44d291

@ -0,0 +1,11 @@
import os
import shutil
def CheckFile(inDstPathStr, inTmplPathStr):
if os.path.exists(inDstPathStr) == False:
shutil.copy(inTmplPathStr, inDstPathStr)
def CheckFolder(inDstPathStr):
# проверка наличия всех файлов/каталогов
if not os.path.exists(os.path.abspath(inDstPathStr)):
os.mkdir(inDstPathStr)

@ -0,0 +1,17 @@
import requests
def RequestPrettyPrint(inRequest):
"""
At this point it is completely built and ready
to be fired; it is "prepared".
However pay attention at the formatting used in
this function because it is programmed to be pretty
printed and may differ from the actual request.
"""
prepared = inRequest.prepare()
print('{}\n{}\r\n{}\r\n\r\n{}'.format(
'-----------START-----------',
prepared.method + ' ' + prepared.url,
'\r\n'.join('{}: {}'.format(k, v) for k, v in prepared.headers.items()),
prepared.body,
))

@ -17,6 +17,7 @@
"import sys\n",
"import os\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\Sources\"))\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\..\\\\KPI_Effect\\\\packages\"))\n",
"import time\n",
"from pyOpenRPA.Robot import Keyboard\n",
"\n",
@ -28,11 +29,14 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"Screen.BoxDraw(inBox = lBoxList)"
"#ИМПОРТ ДИРЕКТОРИИ\n",
"import sys\n",
"import os\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\..\\\\KPI_Effect\\\\packages\"))"
]
},
{
@ -119,6 +123,275 @@
"Screen.ImageLocateAll(inImgPathStr=\"emptytray.PNG\",inConfidenceFloat=0.9)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import importlib"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"123\n"
]
},
{
"data": {
"text/plain": [
"<module 'pak.test' from 'C:\\\\Abs\\\\Archive\\\\scopeSrcUL\\\\pyOpenRPA\\\\Tools\\\\Jupyter-notebooks\\\\pak\\\\test.py'>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"importlib.import_module(\".test\",\"pak\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import sys"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<module 'pak' (namespace)>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sys.modules[\"pak\"]"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import datetime"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.datetime(2022, 9, 26, 20, 58, 26, 931399)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datetime.datetime.now()+datetime.timedelta(hours=3)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.timedelta(seconds=10800)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datetime.timedelta(hours=3)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'2022-09-26 17:59:17'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"g_datetime_format_str = '%Y-%m-%d %H:%M:%S'\n",
"(datetime.datetime.now()).strftime(g_datetime_format_str)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"import time"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.datetime(2022, 9, 26, 18, 1, 58, 924492)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datetime.datetime.fromtimestamp(time.time())"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"\".endswith(\"/\")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"ename": "ImportError",
"evalue": "cannot import name 'kpi_client' from '__main__' (unknown location)",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-15-2f86ae4ce68c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[1;33m.\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mkpi_client\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mImportError\u001b[0m: cannot import name 'kpi_client' from '__main__' (unknown location)"
]
}
],
"source": [
"from . import kpi_client"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"#ИМПОРТ ДИРЕКТОРИИ\n",
"import sys\n",
"import os\n",
"sys.path.insert(0, os.path.abspath(\"..\\\\..\\\\..\\\\KPI_Effect\\\\packages\"))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"import kpi_client\n",
"kpi_client.init(\"http://localhost:1024\", \"1992-04-03-0643-ru-b4ff-openrpa52zzz\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-----------START-----------\n",
"POST http://localhost:1024/orpa/api/activity-list-execute\r\n",
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n",
"Cookie: AuthToken=1992-04-03-0643-ru-b4ff-openrpa52zzz\r\n",
"Content-Length: 466\r\n",
"\r\n",
"b'[{\"Def\": \"kpi_control_panel.actions.log\", \"ArgList\": [], \"ArgDict\": {\"in_code_str\": \"asd\", \"in_group_str\": \"\\\\u041f\\\\u0440\\\\u0438\\\\u0432\\\\u0435\\\\u0442!\", \"in_manual_operation_float\": 190, \"in_auto_operation_float\": 88, \"in_start_time_float\": 123124, \"in_comment_str\": \"-\", \"in_count_int\": 1, \"in_sla_percent_float\": 1.0, \"in_dev_next_mvp_float\": 1.0, \"in_revenue_float\": 0.0, \"in_fine_float\": 0.0, \"in_reputation_str\": \"-\"}, \"ArgGSettingsStr\": null, \"ArgLoggerStr\": null}]'\n"
]
}
],
"source": [
"kpi_client.log(in_code_str=\"asd\",in_group_str=\"Привет!\",in_manual_operation_float=190, in_auto_operation_float=88, in_start_time_float=123124)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"print(\"\")"
]
},
{
"cell_type": "code",
"execution_count": null,

@ -17,6 +17,9 @@ AGT - AGENT
- - Появился модуль захвата звука с микрофонов и с приложений (pyOpenRPA.Robot.Audio)
- ОБЩЕЕ
- - Jupyter: запуск из других дисков, отличных от C://
- - Utils: Функции подготовки файлов/ директорий
[1.3.0]
- ПОРТИРОВАНО НА LINUX (Ubuntu, Debian, Astra), адаптация функций

Loading…
Cancel
Save