polyapi-python 0.2.4.dev11__py3-none-any.whl → 0.2.4.dev13__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.
polyapi/__init__.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import sys
3
3
  import truststore
4
+ from typing import Dict, Any
4
5
  truststore.inject_into_ssl()
5
6
  from .cli import CLI_COMMANDS
6
7
 
@@ -11,4 +12,12 @@ if len(sys.argv) > 1 and sys.argv[1] not in CLI_COMMANDS:
11
12
  currdir = os.path.dirname(os.path.abspath(__file__))
12
13
  if not os.path.isdir(os.path.join(currdir, "poly")):
13
14
  print("No 'poly' found. Please run 'python3 -m polyapi generate' to generate the 'poly' library for your tenant.")
14
- sys.exit(1)
15
+ sys.exit(1)
16
+
17
+
18
+ polyCustom: Dict[str, Any] = {
19
+ "executionId": None,
20
+ "executionApiKey": None,
21
+ "responseStatusCode": 200,
22
+ "responseContentType": None,
23
+ }
polyapi/client.py CHANGED
@@ -10,6 +10,22 @@ from typing import List, Dict, Any, TypedDict
10
10
  """
11
11
 
12
12
 
13
+ def _wrap_code_in_try_except(code: str) -> str:
14
+ """ this is necessary because client functions with imports will blow up ALL server functions,
15
+ even if they don't use them.
16
+ because the server function will try to load all client functions when loading the library
17
+ """
18
+ prefix = """logger = logging.getLogger("poly")
19
+ try:
20
+ """
21
+ suffix = """except ImportError as e:
22
+ logger.debug(e)"""
23
+
24
+ lines = code.split("\n")
25
+ code = "\n ".join(lines)
26
+ return "".join([prefix, code, "\n", suffix])
27
+
28
+
13
29
  def render_client_function(
14
30
  function_name: str,
15
31
  code: str,
@@ -22,4 +38,7 @@ def render_client_function(
22
38
  args_def=args_def,
23
39
  return_type_def=return_type_def,
24
40
  )
41
+
42
+ code = _wrap_code_in_try_except(code)
43
+
25
44
  return code + "\n\n", func_type_defs
polyapi/utils.py CHANGED
@@ -10,7 +10,7 @@ from polyapi.schema import generate_schema_types, clean_title, map_primitive_typ
10
10
 
11
11
  # this string should be in every __init__ file.
12
12
  # it contains all the imports needed for the function or variable code to run
13
- CODE_IMPORTS = "from typing import List, Dict, Any, TypedDict, Optional\nimport requests\nimport socketio # type: ignore\nfrom polyapi.config import get_api_key_and_url\nfrom polyapi.execute import execute, execute_post, variable_get, variable_update\n\n"
13
+ CODE_IMPORTS = "from typing import List, Dict, Any, TypedDict, Optional\nimport logging\nimport requests\nimport socketio # type: ignore\nfrom polyapi.config import get_api_key_and_url\nfrom polyapi.execute import execute, execute_post, variable_get, variable_update\n\n"
14
14
 
15
15
 
16
16
  def init_the_init(full_path: str) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.2.4.dev11
3
+ Version: 0.2.4.dev13
4
4
  Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
5
5
  Author-email: Dan Fellin <dan@polyapi.io>
6
6
  License: MIT License
@@ -1,9 +1,9 @@
1
- polyapi/__init__.py,sha256=VRAaN5WZPDmj7AnprtJ3szHXWlqWInKXBfEmfpyXTK8,434
1
+ polyapi/__init__.py,sha256=5iujRodfgRyLxT-zY0L3xax3rKRvfSt4NZlZYKOz03w,608
2
2
  polyapi/__main__.py,sha256=V4zhAh_YGxno5f_KSrlkELxcuDh9bR3WSd0n-2r-qQQ,93
3
3
  polyapi/api.py,sha256=Pq_OT8egmtlzMjovN5GGZXWnF5oWMkrgR0rmrzJ6ifM,1861
4
4
  polyapi/auth.py,sha256=p2KSLt6q52t9gnqPmgXTOQ2_lmdFilZkIoGmQrRTPLQ,5330
5
5
  polyapi/cli.py,sha256=xlKH4cSmSo7eXbyXCLWyL4rXM1QFsltC_MxoxMPgt6I,2187
6
- polyapi/client.py,sha256=8k50Vwg9HnmHHTyfKH1vfMJqF0jnnVMsWuWI9AfASkM,761
6
+ polyapi/client.py,sha256=w15XOABkwdL4V4r2iWY_nypzLjvoKVuux8jUKbA16pQ,1329
7
7
  polyapi/config.py,sha256=S8TU10upy5OW1_vX-CqQTJD-ZOB6329aMjiUCmukfUI,2292
8
8
  polyapi/constants.py,sha256=NGjso6K5rGnE8TGdrXmdEfvvr-HI3DTVGwOYiWO68LM,511
9
9
  polyapi/error_handler.py,sha256=I_e0iz6VM23FLVQWJljxs2NGcl_OODbi43OcbnqBlp8,2398
@@ -11,16 +11,15 @@ polyapi/exceptions.py,sha256=Zh7i7eCUhDuXEdUYjatkLFTeZkrx1BJ1P5ePgbJ9eIY,89
11
11
  polyapi/execute.py,sha256=kXnvlNQ7nz9cRlV2_5gXH09UCmyiDP5zi3wiAw0uDuk,1943
12
12
  polyapi/function_cli.py,sha256=F0cb5MGcmFvspgwxptWq_2e50X5NNno0B0p8Vgu_oNI,9129
13
13
  polyapi/generate.py,sha256=fNEBy3ALEu4m1GEEcly-5u-Y1i3G6EWMKKgCyBBJsqc,8568
14
- polyapi/poly_custom.py,sha256=IQRZIMGs0CXotbn71_wyHMinSkoBwKdFdgv90VLYV90,173
15
14
  polyapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
15
  polyapi/schema.py,sha256=1a7nIO867Xy3bagmPUNdYMxtS5OoCAv8oKIbYgj55dk,2957
17
16
  polyapi/server.py,sha256=iXUR1Kd5TnWK-V5qHhvFvQuHx-3IcTv8WChXVY5Mbog,1882
18
17
  polyapi/typedefs.py,sha256=a5WfHaAvjeql3y1iA3_SkpUztTbKvS5bPqkVxkCvr9E,1459
19
- polyapi/utils.py,sha256=86OSrkXlaB0HZppkItT9Xp3m2LBfIT4nPIhyBkIJ0OU,6164
18
+ polyapi/utils.py,sha256=9dFboLurZwBBtFZxXBDNri4QvSJAyZhkNUWK5LZh6ME,6180
20
19
  polyapi/variables.py,sha256=d36-trnfTL_8m2NkorMiImb4O3UrJbiFV38CHxV5i0A,4200
21
20
  polyapi/webhook.py,sha256=KidW6J1R4pWsgJ9duPiG-kzO8S28zfVyPhSn8ypD30Y,4325
22
- polyapi_python-0.2.4.dev11.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
23
- polyapi_python-0.2.4.dev11.dist-info/METADATA,sha256=KJOGzn80kG4RbClDfAeVKfnbMkrLt2W3St9-EuSixxA,4868
24
- polyapi_python-0.2.4.dev11.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
25
- polyapi_python-0.2.4.dev11.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
26
- polyapi_python-0.2.4.dev11.dist-info/RECORD,,
21
+ polyapi_python-0.2.4.dev13.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
22
+ polyapi_python-0.2.4.dev13.dist-info/METADATA,sha256=_1h4w9445uvZ3l6IOAXOUsblQc2QjfmaIoGy_uSFdvQ,4868
23
+ polyapi_python-0.2.4.dev13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
24
+ polyapi_python-0.2.4.dev13.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
25
+ polyapi_python-0.2.4.dev13.dist-info/RECORD,,
polyapi/poly_custom.py DELETED
@@ -1,9 +0,0 @@
1
- from typing import Dict, Any
2
-
3
-
4
- polyCustom: Dict[str, Any] = {
5
- "executionId": None,
6
- "executionApiKey": None,
7
- "responseStatusCode": 200,
8
- "responseContentType": None,
9
- }