isrpa 1.0.3__py3-none-any.whl → 1.0.5__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
@@ -20,13 +20,44 @@ def getPath(user_name):
20
20
  :param port:
21
21
  :return:
22
22
  """
23
+
24
+ # address = os.environ.get("address", "192.168.12.249")
25
+
26
+ url = f"{address}/client/getPath"
27
+ headers = {
28
+ 'Content-Type': 'application/json', # 说明请求体是 JSON 格式
29
+ }
30
+ # 请求体的数据
31
+ data = {
32
+ 'user_name': user_name
33
+ }
34
+ response = requests.post(url, headers=headers, json=data)
35
+ if response.status_code != 200:
36
+ return "failure"
37
+ data = response.json()
38
+ return f"ws://{data.get('ip_address')}:{data.get('port')}"
39
+
40
+
41
+ def get_ssh_path(user_name):
42
+ """
43
+ 环境变量设置
44
+ windows
45
+ setx address "192.168.12.249"
46
+
47
+ linux
48
+ export address = "192.168.12.249"
49
+ source /etc/profile
50
+ :param port:
51
+ :return:
52
+ """
23
53
  url = f"{address}/client/getPath"
24
54
  headers = {'Content-Type': 'application/json'}
25
55
  data = {'user_name': user_name}
26
56
  response = requests.post(url, headers=headers, json=data)
27
57
  if response.status_code != 200:
28
58
  return "failure"
29
- port = response.json()
59
+ data = response.json()
60
+ port = data.get('port')
30
61
 
31
62
  def get_ws_url():
32
63
  url = f"http://localhost:{port}/json/version"
@@ -39,7 +70,7 @@ def getPath(user_name):
39
70
  return ws_url
40
71
 
41
72
 
42
- def get_active_page(browser, user_name):
73
+ def get_active_url(user_name):
43
74
  """
44
75
  获取当前激活page对象
45
76
  """
@@ -49,7 +80,8 @@ def get_active_page(browser, user_name):
49
80
  response = requests.post(url, headers=headers, json=data)
50
81
  if response.status_code != 200:
51
82
  return "failure"
52
- port = response.json()
83
+ data = response.json()
84
+ port = data.get('port')
53
85
 
54
86
  def get_json():
55
87
  url = f"http://localhost:{port}/json"
@@ -59,14 +91,19 @@ def get_active_page(browser, user_name):
59
91
  return response.json()
60
92
 
61
93
  data = get_json()
94
+ if data:
95
+ return data[0].get("url")
96
+ return None
97
+
62
98
 
63
- for t in data:
64
- if t.get("type") == "page":
65
- active_url = t.get("url")
66
- for page in browser.contexts[0].pages:
67
- if page.url == active_url:
68
- page.bring_to_front()
69
- return page
99
+ def get_active_page(browser, active_url):
100
+ """
101
+ 获取当前激活page对象
102
+ """
103
+ for page in browser.contexts[0].pages:
104
+ if page.url == active_url:
105
+ page.bring_to_front()
106
+ return page
70
107
 
71
108
 
72
109
  def upload_file(file_path, dest_file, user_name):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: isrpa
3
- Version: 1.0.3
3
+ Version: 1.0.5
4
4
  Summary: isrpa package
5
5
  Home-page: https://github.com/yourusername/mypackage
6
6
  Author: ysq
@@ -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=N2reQBnyLAfnWzvtFrH0pybF7x6HvPvs3gsVVyqbLNA,3971
9
- isrpa-1.0.3.dist-info/METADATA,sha256=bfZ55Csi8oRoVEQhlHO_cMFxpSc5vnfa2w-9NY6VV0Q,511
10
- isrpa-1.0.3.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
11
- isrpa-1.0.3.dist-info/top_level.txt,sha256=J5HJbtR2WAeKnW1rrpkiuapwnlswv3RgM-riyZD87o0,6
12
- isrpa-1.0.3.dist-info/RECORD,,
8
+ isrpa/utils.py,sha256=7gtqQhWaQezuOO9WcS03TN6meqNYD8bAgn4NK7yqxDc,4815
9
+ isrpa-1.0.5.dist-info/METADATA,sha256=Isa7hR1IkpzD9lCotUpEC0ORXxK_N2NIf0tp6BVmesU,511
10
+ isrpa-1.0.5.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
11
+ isrpa-1.0.5.dist-info/top_level.txt,sha256=J5HJbtR2WAeKnW1rrpkiuapwnlswv3RgM-riyZD87o0,6
12
+ isrpa-1.0.5.dist-info/RECORD,,
File without changes