isrpa 1.0.4__py3-none-any.whl → 1.0.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
isrpa/utils.py
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
import os
|
2
2
|
|
3
|
+
import redis
|
3
4
|
import requests
|
4
5
|
import tldextract
|
5
6
|
from dotenv import load_dotenv
|
6
7
|
|
7
8
|
load_dotenv("/isearch/aiAgent/.env", override=True)
|
8
9
|
address = os.getenv("address")
|
10
|
+
client = redis.Redis(host=os.getenv("REDIS_HOST"), port=os.getenv("REDIS_PORT"), db=os.getenv("REDIS_DB"),
|
11
|
+
password=os.getenv("REDIS_PASSWORD"))
|
9
12
|
|
10
13
|
|
11
14
|
def getPath(user_name):
|
@@ -20,13 +23,44 @@ def getPath(user_name):
|
|
20
23
|
:param port:
|
21
24
|
:return:
|
22
25
|
"""
|
26
|
+
|
27
|
+
# address = os.environ.get("address", "192.168.12.249")
|
28
|
+
|
29
|
+
url = f"{address}/client/getPath"
|
30
|
+
headers = {
|
31
|
+
'Content-Type': 'application/json', # 说明请求体是 JSON 格式
|
32
|
+
}
|
33
|
+
# 请求体的数据
|
34
|
+
data = {
|
35
|
+
'user_name': user_name
|
36
|
+
}
|
37
|
+
response = requests.post(url, headers=headers, json=data)
|
38
|
+
if response.status_code != 200:
|
39
|
+
return "failure"
|
40
|
+
data = response.json()
|
41
|
+
return f"ws://{data.get('ip_address')}:{data.get('port')}"
|
42
|
+
|
43
|
+
|
44
|
+
def get_ssh_path(user_name):
|
45
|
+
"""
|
46
|
+
环境变量设置
|
47
|
+
windows
|
48
|
+
setx address "192.168.12.249"
|
49
|
+
|
50
|
+
linux
|
51
|
+
export address = "192.168.12.249"
|
52
|
+
source /etc/profile
|
53
|
+
:param port:
|
54
|
+
:return:
|
55
|
+
"""
|
23
56
|
url = f"{address}/client/getPath"
|
24
57
|
headers = {'Content-Type': 'application/json'}
|
25
58
|
data = {'user_name': user_name}
|
26
59
|
response = requests.post(url, headers=headers, json=data)
|
27
60
|
if response.status_code != 200:
|
28
61
|
return "failure"
|
29
|
-
|
62
|
+
data = response.json()
|
63
|
+
port = data.get('port')
|
30
64
|
|
31
65
|
def get_ws_url():
|
32
66
|
url = f"http://localhost:{port}/json/version"
|
@@ -49,7 +83,8 @@ def get_active_url(user_name):
|
|
49
83
|
response = requests.post(url, headers=headers, json=data)
|
50
84
|
if response.status_code != 200:
|
51
85
|
return "failure"
|
52
|
-
|
86
|
+
data = response.json()
|
87
|
+
port = data.get('port')
|
53
88
|
|
54
89
|
def get_json():
|
55
90
|
url = f"http://localhost:{port}/json"
|
@@ -74,6 +109,10 @@ def get_active_page(browser, active_url):
|
|
74
109
|
return page
|
75
110
|
|
76
111
|
|
112
|
+
def set_playwright_file_path(key, value):
|
113
|
+
client.set(key, value, ex=30)
|
114
|
+
|
115
|
+
|
77
116
|
def upload_file(file_path, dest_file, user_name):
|
78
117
|
"""
|
79
118
|
通知客户端上传文件
|
@@ -5,8 +5,8 @@ isrpa/__init__.py,sha256=pG-YPVG0gJIJ6s4xcAz9S_CnUxpUcz33wl9eNUSgxGk,20
|
|
5
5
|
isrpa/credentials.py,sha256=5paT4rxtZIUPqADmi1bLkoSKEYoosgS7rIjrJsgMNIs,3350
|
6
6
|
isrpa/llm_chat.py,sha256=jTuK9wcm3X36V9lXuGuTCdNup_zi2NeG2GuYHzO7gm4,1541
|
7
7
|
isrpa/message.py,sha256=N0s6hMaC5S-Pi4EhwcSp-ngfBTBQyW6ymU9sI9dUSeE,11329
|
8
|
-
isrpa/utils.py,sha256=
|
9
|
-
isrpa-1.0.
|
10
|
-
isrpa-1.0.
|
11
|
-
isrpa-1.0.
|
12
|
-
isrpa-1.0.
|
8
|
+
isrpa/utils.py,sha256=KjZbsSnypJT5OhfBPPogUef7Q831g2cAYFyD5BmWDKs,5079
|
9
|
+
isrpa-1.0.6.dist-info/METADATA,sha256=kuCJISHQM1RTf3MIOl-RV7oyq2cDtvj0YHbGlQTqi5o,511
|
10
|
+
isrpa-1.0.6.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
11
|
+
isrpa-1.0.6.dist-info/top_level.txt,sha256=J5HJbtR2WAeKnW1rrpkiuapwnlswv3RgM-riyZD87o0,6
|
12
|
+
isrpa-1.0.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|