simplex 1.2.15__py3-none-any.whl → 1.2.17__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.

Potentially problematic release.


This version of simplex might be problematic. Click here for more details.

simplex/simplex.py CHANGED
@@ -20,7 +20,10 @@ class Simplex:
20
20
  data={'session_id': self.session_id}
21
21
  )
22
22
  self.session_id = None
23
- return response.json()
23
+ if response["succeeded"]:
24
+ return
25
+ else:
26
+ raise ValueError(f"Failed to close session: {response['error']}")
24
27
 
25
28
  def create_session(self, show_in_console: bool = True):
26
29
  response = requests.post(
@@ -29,8 +32,9 @@ class Simplex:
29
32
  'x-api-key': self.api_key
30
33
  }
31
34
  )
32
-
33
35
  response_json = response.json()
36
+ if 'session_id' not in response_json:
37
+ raise ValueError(f"It looks like the session wasn't created successfully. Did you set your api_key when creating the Simplex class?")
34
38
  self.session_id = response_json['session_id']
35
39
  livestream_url = response_json['livestream_url']
36
40
 
@@ -60,7 +64,10 @@ class Simplex:
60
64
  },
61
65
  data=data
62
66
  )
63
- return response.json()
67
+ if response.json()["succeeded"]:
68
+ return
69
+ else:
70
+ raise ValueError(f"Failed to goto url: {response.json()['error']}")
64
71
 
65
72
  def click(self, element_description: str, cdp_url: str = None, use_vision: bool = False):
66
73
  if not cdp_url and not self.session_id:
@@ -83,7 +90,10 @@ class Simplex:
83
90
  },
84
91
  data=data
85
92
  )
86
- return response.json()
93
+ if response.json()["succeeded"]:
94
+ return response.json()["element_clicked"]
95
+ else:
96
+ raise ValueError(f"Failed to click element: {response.json()['error']}")
87
97
 
88
98
  def type(self, text: str, cdp_url: str = None):
89
99
  if not cdp_url and not self.session_id:
@@ -103,7 +113,10 @@ class Simplex:
103
113
  },
104
114
  data=data
105
115
  )
106
- return response.json()
116
+ if response.json()["succeeded"]:
117
+ return
118
+ else:
119
+ raise ValueError(f"Failed to type text: {response.json()['error']}")
107
120
 
108
121
  def press_enter(self, cdp_url: str = None):
109
122
  if not cdp_url and not self.session_id:
@@ -123,7 +136,10 @@ class Simplex:
123
136
  },
124
137
  data=data
125
138
  )
126
- return response.json()
139
+ if response.json()["succeeded"]:
140
+ return
141
+ else:
142
+ raise ValueError(f"Failed to press enter: {response.json()['error']}")
127
143
 
128
144
  def extract_bbox(self, element_description: str, cdp_url: str = None):
129
145
  if not cdp_url and not self.session_id:
@@ -143,8 +159,10 @@ class Simplex:
143
159
  },
144
160
  params=data
145
161
  )
146
-
147
- return response.json()
162
+ if response.json()["succeeded"]:
163
+ return response.json()["bbox"]
164
+ else:
165
+ raise ValueError(f"Failed to extract bbox: {response.json()['error']}")
148
166
 
149
167
  def extract_text(self, element_description: str, cdp_url: str = None, use_vision: bool = False):
150
168
  if not cdp_url and not self.session_id:
@@ -167,7 +185,10 @@ class Simplex:
167
185
  },
168
186
  params=data
169
187
  )
170
- return response.json()
188
+ if response.json()["succeeded"]:
189
+ return response.json()["text"]
190
+ else:
191
+ raise ValueError(f"Failed to extract text: {response.json()['error']}")
171
192
 
172
193
  def extract_image(self, element_description: str, cdp_url: str = None):
173
194
  if not cdp_url and not self.session_id:
@@ -187,7 +208,10 @@ class Simplex:
187
208
  },
188
209
  params=data
189
210
  )
190
- return response.json()
211
+ if response.json()["succeeded"]:
212
+ return response.json()["image"]
213
+ else:
214
+ raise ValueError(f"Failed to extract image: {response.json()['error']}")
191
215
 
192
216
  def scroll(self, pixels: float, cdp_url: str = None):
193
217
  if not cdp_url and not self.session_id:
@@ -207,7 +231,10 @@ class Simplex:
207
231
  },
208
232
  data=data
209
233
  )
210
- return response.json()
234
+ if response.json()["succeeded"]:
235
+ return
236
+ else:
237
+ raise ValueError(f"Failed to scroll: {response.json()['error']}")
211
238
 
212
239
  def wait(self, milliseconds: int, cdp_url: str = None):
213
240
  if not cdp_url and not self.session_id:
@@ -227,7 +254,10 @@ class Simplex:
227
254
  },
228
255
  data=data
229
256
  )
230
- return response.json()
257
+ if response.json()["succeeded"]:
258
+ return
259
+ else:
260
+ raise ValueError(f"Failed to wait: {response.json()['error']}")
231
261
 
232
262
  def create_login_session(self, url: str):
233
263
  response = requests.post(
@@ -237,7 +267,10 @@ class Simplex:
237
267
  },
238
268
  data={'url': url}
239
269
  )
240
- return response.json()
270
+ if response.json()["succeeded"]:
271
+ return response.json()["login_session_url"]
272
+ else:
273
+ raise ValueError(f"Failed to create login session: {response.json()['error']}")
241
274
 
242
275
  def restore_login_session(self, session_data_filepath: str, cdp_url: str = None):
243
276
  filename = session_data_filepath
@@ -261,7 +294,10 @@ class Simplex:
261
294
  },
262
295
  data=data
263
296
  )
264
- return response.json()
297
+ if response.json()["succeeded"]:
298
+ return
299
+ else:
300
+ raise ValueError(f"Failed to restore login session: {response.json()['error']}")
265
301
 
266
302
  def click_and_upload(self, element_description: str, file_path: str):
267
303
  if not self.session_id:
@@ -285,7 +321,10 @@ class Simplex:
285
321
  files=files,
286
322
  data=data
287
323
  )
288
- return response.json()
324
+ if response.json()["succeeded"]:
325
+ return
326
+ else:
327
+ raise ValueError(f"Failed to click and upload: {response.json()['error']}")
289
328
 
290
329
  def click_and_download(self, element_description: str):
291
330
  if not self.session_id:
@@ -304,8 +343,10 @@ class Simplex:
304
343
  },
305
344
  data=data
306
345
  )
307
-
308
- return response.json()
346
+ if response.json()["succeeded"]:
347
+ return response.json()["b64"], response.json()["filename"]
348
+ else:
349
+ raise ValueError(f"Failed to click and download: {response.json()['error']}")
309
350
 
310
351
  def exists(self, element_description: str, cdp_url: str = None):
311
352
  if not cdp_url and not self.session_id:
@@ -327,6 +368,6 @@ class Simplex:
327
368
  )
328
369
  response_json = response.json()
329
370
  if response_json['succeeded']:
330
- return True, response_json['reasoning']
371
+ return response_json['reasoning']
331
372
  else:
332
- return False, response_json['error']
373
+ raise ValueError(f"Failed to check if element exists: {response_json['error']}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: simplex
3
- Version: 1.2.15
3
+ Version: 1.2.17
4
4
  Summary: Official Python SDK for Simplex API
5
5
  Home-page: https://simplex.sh
6
6
  Author: Simplex Labs, Inc.
@@ -0,0 +1,11 @@
1
+ simplex/__init__.py,sha256=1mbM4XUk0FNW161WOkM4ayC1s_QSsaBEls6PZ0iBScY,74
2
+ simplex/cli.py,sha256=qzhrD9vMOZUImjWG9rF7NIkEtugEW959esQDdscNKZk,2642
3
+ simplex/simplex.py,sha256=3jwwgk7Olg62BkVJI0BvlsFN2UM8kRqARCAWTbaNSj4,12208
4
+ simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
5
+ simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
6
+ simplex-1.2.17.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
7
+ simplex-1.2.17.dist-info/METADATA,sha256=mmiDAVtCS6-hh1OrboTjTXk7t6vclvBxyQlFdYmBTLg,1350
8
+ simplex-1.2.17.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
9
+ simplex-1.2.17.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
10
+ simplex-1.2.17.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
11
+ simplex-1.2.17.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- simplex/__init__.py,sha256=1mbM4XUk0FNW161WOkM4ayC1s_QSsaBEls6PZ0iBScY,74
2
- simplex/cli.py,sha256=qzhrD9vMOZUImjWG9rF7NIkEtugEW959esQDdscNKZk,2642
3
- simplex/simplex.py,sha256=nyuenKd2XZfxwJdMcSkZic3K75Qx_s4O-MEWud2KoWg,10028
4
- simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
5
- simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
6
- simplex-1.2.15.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
7
- simplex-1.2.15.dist-info/METADATA,sha256=kVwqK6UsDUpdOadxW5urH0OIQzMqNqud-s6_vCKKjnA,1350
8
- simplex-1.2.15.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
9
- simplex-1.2.15.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
10
- simplex-1.2.15.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
11
- simplex-1.2.15.dist-info/RECORD,,