simplex 1.2.54__py3-none-any.whl → 1.2.57__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 +34 -17
- {simplex-1.2.54.dist-info → simplex-1.2.57.dist-info}/METADATA +1 -1
- simplex-1.2.57.dist-info/RECORD +11 -0
- simplex-1.2.54.dist-info/RECORD +0 -11
- {simplex-1.2.54.dist-info → simplex-1.2.57.dist-info}/LICENSE +0 -0
- {simplex-1.2.54.dist-info → simplex-1.2.57.dist-info}/WHEEL +0 -0
- {simplex-1.2.54.dist-info → simplex-1.2.57.dist-info}/entry_points.txt +0 -0
- {simplex-1.2.54.dist-info → simplex-1.2.57.dist-info}/top_level.txt +0 -0
simplex/simplex.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import requests
|
|
2
2
|
import atexit
|
|
3
|
-
from typing import Optional
|
|
3
|
+
from typing import Optional, Union
|
|
4
4
|
import os
|
|
5
5
|
import json
|
|
6
6
|
import warnings
|
|
@@ -110,7 +110,10 @@ class Simplex:
|
|
|
110
110
|
else:
|
|
111
111
|
raise ValueError(f"Failed to close session: {response.json()['error']}")
|
|
112
112
|
|
|
113
|
-
def create_session(self, show_in_console: Optional[bool] = True, proxies: Optional[bool] = True, session_data: Optional[dict | str] = None):
|
|
113
|
+
def create_session(self, show_in_console: Optional[bool] = True, proxies: Optional[bool] = True, workflow_name: Optional[str] = None, session_data: Optional[dict | str] = None):
|
|
114
|
+
if self.session_id:
|
|
115
|
+
raise ValueError("A session is already active. Please close the current session before creating a new one.")
|
|
116
|
+
|
|
114
117
|
if session_data:
|
|
115
118
|
if isinstance(session_data, dict):
|
|
116
119
|
session_data_dict = session_data
|
|
@@ -130,7 +133,7 @@ class Simplex:
|
|
|
130
133
|
headers={
|
|
131
134
|
'x-api-key': self.api_key
|
|
132
135
|
},
|
|
133
|
-
data={'proxies': proxies, 'session_data': json.dumps(session_data_dict)}
|
|
136
|
+
data={'proxies': proxies, 'session_data': json.dumps(session_data_dict), 'workflow_name': workflow_name}
|
|
134
137
|
)
|
|
135
138
|
else:
|
|
136
139
|
response = requests.post(
|
|
@@ -138,7 +141,7 @@ class Simplex:
|
|
|
138
141
|
headers={
|
|
139
142
|
'x-api-key': self.api_key
|
|
140
143
|
},
|
|
141
|
-
data={'proxies': proxies}
|
|
144
|
+
data={'proxies': proxies, "workflow_name": workflow_name}
|
|
142
145
|
)
|
|
143
146
|
# Check for non-200 status code
|
|
144
147
|
if response.status_code != 200:
|
|
@@ -356,12 +359,13 @@ class Simplex:
|
|
|
356
359
|
},
|
|
357
360
|
data=data
|
|
358
361
|
)
|
|
359
|
-
|
|
362
|
+
response_json = response.json()
|
|
363
|
+
if 'succeeded' not in response_json:
|
|
360
364
|
raise ValueError(f"It looks like the extract_text action failed to return a response. Did you set your api_key when creating the Simplex class?")
|
|
361
|
-
if
|
|
362
|
-
return
|
|
365
|
+
if response_json["succeeded"]:
|
|
366
|
+
return response_json["text"]
|
|
363
367
|
else:
|
|
364
|
-
raise ValueError(f"Failed to extract text: {
|
|
368
|
+
raise ValueError(f"Failed to extract text: {response_json['error']}")
|
|
365
369
|
|
|
366
370
|
def extract_image(self, element_description: str, cdp_url: str = None):
|
|
367
371
|
if not cdp_url and not self.session_id:
|
|
@@ -555,20 +559,33 @@ class Simplex:
|
|
|
555
559
|
else:
|
|
556
560
|
raise ValueError(f"Failed to restore login session: {response.json()['error']}")
|
|
557
561
|
|
|
558
|
-
def click_and_upload(self, element_description: str,
|
|
562
|
+
def click_and_upload(self, element_description: str, file_path_or_callable: Union[str, callable]):
|
|
563
|
+
"""
|
|
564
|
+
Args:
|
|
565
|
+
element_description: Description of the element to click and upload to
|
|
566
|
+
file_path_or_callable: Either a path to the file to be uploaded or a callable that returns a file-like object in 'rb' mode
|
|
567
|
+
"""
|
|
559
568
|
if not self.session_id:
|
|
560
569
|
raise ValueError(f"Must call create_session before calling action click_and_upload with element_description='{element_description}'")
|
|
561
|
-
|
|
562
|
-
files = {
|
|
563
|
-
'file': open(file_path, 'rb')
|
|
564
|
-
}
|
|
565
570
|
|
|
571
|
+
if not isinstance(file_path_or_callable, str) and not callable(file_path_or_callable):
|
|
572
|
+
raise TypeError("file_path_or_callable must be either a string or a callable, not a " + type(file_path_or_callable).__name__)
|
|
573
|
+
|
|
574
|
+
if isinstance(file_path_or_callable, str):
|
|
575
|
+
files = {
|
|
576
|
+
'file': open(file_path_or_callable, 'rb')
|
|
577
|
+
}
|
|
578
|
+
elif callable(file_path_or_callable):
|
|
579
|
+
files = {
|
|
580
|
+
'file': file_path_or_callable()
|
|
581
|
+
}
|
|
582
|
+
else:
|
|
583
|
+
raise ValueError("You must provide either a valid file path or a callable that returns a file-like object.")
|
|
566
584
|
data = {
|
|
567
|
-
'element_description': element_description
|
|
585
|
+
'element_description': element_description,
|
|
586
|
+
'session_id': self.session_id
|
|
568
587
|
}
|
|
569
588
|
|
|
570
|
-
data['session_id'] = self.session_id
|
|
571
|
-
|
|
572
589
|
response = requests.post(
|
|
573
590
|
f"{BASE_URL}/click_and_upload",
|
|
574
591
|
headers={
|
|
@@ -583,7 +600,7 @@ class Simplex:
|
|
|
583
600
|
return
|
|
584
601
|
else:
|
|
585
602
|
raise ValueError(f"Failed to click and upload: {response.json()['error']}")
|
|
586
|
-
|
|
603
|
+
|
|
587
604
|
def click_and_download(self, element_description: str):
|
|
588
605
|
if not self.session_id:
|
|
589
606
|
raise ValueError(f"Must call create_session before calling action click_and_download with element_description='{element_description}'")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
|
|
2
|
+
simplex/cli.py,sha256=0K_pzoVdF7vfTJPUONhFzzTvjZk2M7FZPpEONjZWJC8,2268
|
|
3
|
+
simplex/simplex.py,sha256=qz9vUcp0HVIN_weBxv_sBCY1pw8LTObR3fcHcU_0gZQ,25413
|
|
4
|
+
simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
|
|
5
|
+
simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
|
|
6
|
+
simplex-1.2.57.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
|
|
7
|
+
simplex-1.2.57.dist-info/METADATA,sha256=actbMwYSlAmBFJC9spU_A845aGqUEd3VhUhYJWV42os,1045
|
|
8
|
+
simplex-1.2.57.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
+
simplex-1.2.57.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
|
|
10
|
+
simplex-1.2.57.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
|
|
11
|
+
simplex-1.2.57.dist-info/RECORD,,
|
simplex-1.2.54.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
simplex/__init__.py,sha256=L_5i__xt_ZDkr6e-Wx9cr84t9sXpioOT7j01NJYJCTE,75
|
|
2
|
-
simplex/cli.py,sha256=0K_pzoVdF7vfTJPUONhFzzTvjZk2M7FZPpEONjZWJC8,2268
|
|
3
|
-
simplex/simplex.py,sha256=TMZspmze_PUnNyiEb14qFlgDvFFosNNB0JFPIaILrXU,24264
|
|
4
|
-
simplex/deploy/__init__.py,sha256=_JQ81F_Nu7hSAfMA691gzs6a4-8oZ-buJ9h3Au12BKw,96
|
|
5
|
-
simplex/deploy/push.py,sha256=hRAbtFZaECKnBljaOLQ5nzJ6hk7tZgc1c7QdgxKQFoY,6123
|
|
6
|
-
simplex-1.2.54.dist-info/LICENSE,sha256=Xh0SJjYZfNI71pCNMB40aKlBLLuOB0blx5xkTtufFNQ,1075
|
|
7
|
-
simplex-1.2.54.dist-info/METADATA,sha256=njSwU48H0CXrNBjTYVvj8fWS2AQ959ScE06gnUqhpYU,1045
|
|
8
|
-
simplex-1.2.54.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
-
simplex-1.2.54.dist-info/entry_points.txt,sha256=3veL2w3c5vxb3dm8I_M8Fs-370n1ZnvD8uu1nSsL7z8,45
|
|
10
|
-
simplex-1.2.54.dist-info/top_level.txt,sha256=cbMH1bYpN0A3gP-ecibPRHasHoqB-01T_2BUFS8p0CE,8
|
|
11
|
-
simplex-1.2.54.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|