isrpa 1.1.2__py3-none-any.whl → 1.1.4__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
@@ -60,13 +60,17 @@ def get_ssh_path(user_name):
60
60
  port = data.get('port')
61
61
 
62
62
  def get_ws_url():
63
- url = f"http://localhost:{port}/json/version"
64
- r = requests.get(url, headers={"Connection": "close"}, stream=True)
65
- if r.status_code != 200:
66
- return "failure"
67
- url = r.json().get('webSocketDebuggerUrl')
68
- r.close()
69
- return url
63
+ for _ in range(3):
64
+ try:
65
+ url = f"http://localhost:{port}/json/version"
66
+ r = requests.get(url, headers={"Connection": "close"}, stream=True, timeout=5)
67
+ if r.status_code != 200:
68
+ return "failure"
69
+ url = r.json().get('webSocketDebuggerUrl')
70
+ r.close()
71
+ return url
72
+ except Exception as e:
73
+ pass
70
74
 
71
75
  ws_url = get_ws_url()
72
76
  return ws_url
@@ -86,11 +90,15 @@ def get_url(user_name):
86
90
  port = data.get('port')
87
91
 
88
92
  def get_json():
89
- url = f"http://localhost:{port}/json"
90
- response = requests.get(url, headers={"Connection": "close"}, stream=True)
91
- if response.status_code != 200:
92
- return "failure"
93
- return response.json()
93
+ for _ in range(3):
94
+ try:
95
+ url = f"http://localhost:{port}/json"
96
+ response = requests.get(url, headers={"Connection": "close"}, stream=True, timeout=5)
97
+ if response.status_code != 200:
98
+ return "failure"
99
+ return response.json()
100
+ except Exception as e:
101
+ pass
94
102
 
95
103
  pages = get_json()
96
104
  if pages:
@@ -121,13 +129,17 @@ def get_active_url(user_name):
121
129
  port = data.get('port')
122
130
 
123
131
  def get_json():
124
- url = f"http://localhost:{port}/json"
125
- r = requests.get(url, headers={"Connection": "close"}, stream=True)
126
- if r.status_code != 200:
127
- return "failure"
128
- json_data = r.json()
129
- r.close()
130
- return json_data
132
+ for _ in range(3):
133
+ try:
134
+ url = f"http://localhost:{port}/json"
135
+ r = requests.get(url, headers={"Connection": "close"}, stream=True, timeout=5)
136
+ if r.status_code != 200:
137
+ return "failure"
138
+ json_data = r.json()
139
+ r.close()
140
+ return json_data
141
+ except Exception as e:
142
+ pass
131
143
 
132
144
  pages = get_json()
133
145
  if pages:
@@ -146,7 +158,9 @@ def get_active_page(browser, active_page_id):
146
158
  """
147
159
  获取当前激活page对象
148
160
  """
149
- for page in browser.contexts[0].pages:
161
+ context = browser.contexts[0]
162
+ context.add_init_script('''localStorage.setItem('devtool', 'open');''')
163
+ for page in context.pages:
150
164
  client = page.context.new_cdp_session(page)
151
165
  target_info = client.send("Target.getTargetInfo")
152
166
  if target_info.get('targetInfo').get('targetId') == active_page_id:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: isrpa
3
- Version: 1.1.2
3
+ Version: 1.1.4
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=Kuz1PvfRJfOx3_Ylu4QavmHhYD89cMHT1odlCaa4-gs,6562
9
- isrpa-1.1.2.dist-info/METADATA,sha256=UAQhwoyM6_Zdjs3TrZv7F-TkCykAXD_4YM6pull074o,511
10
- isrpa-1.1.2.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
11
- isrpa-1.1.2.dist-info/top_level.txt,sha256=J5HJbtR2WAeKnW1rrpkiuapwnlswv3RgM-riyZD87o0,6
12
- isrpa-1.1.2.dist-info/RECORD,,
8
+ isrpa/utils.py,sha256=xYjjgzYtkV2j7XapcYlMrfUckzpcbLtJaWs3JhlMH8k,7159
9
+ isrpa-1.1.4.dist-info/METADATA,sha256=-uQt5S0VUcROTcIZ_7A4G5C6L90k-qHw5NlgjqEkXtg,511
10
+ isrpa-1.1.4.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
11
+ isrpa-1.1.4.dist-info/top_level.txt,sha256=J5HJbtR2WAeKnW1rrpkiuapwnlswv3RgM-riyZD87o0,6
12
+ isrpa-1.1.4.dist-info/RECORD,,
File without changes