Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions polyapi/execute.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from typing import Dict, Optional
import requests
import os
import logging
from requests import Response
from polyapi.config import get_api_key_and_url, get_mtls_config
from polyapi.exceptions import PolyApiException

logger = logging.getLogger("poly")

def direct_execute(function_type, function_id, data) -> Response:
""" execute a specific function id/type
"""
Expand Down Expand Up @@ -46,7 +49,7 @@ def direct_execute(function_type, function_id, data) -> Response:
if (resp.status_code < 200 or resp.status_code >= 300):
error_content = resp.content.decode("utf-8", errors="ignore")
if function_type == 'api' and os.getenv("LOGS_ENABLED"):
raise PolyApiException(f"Error executing api function with id: {function_id}. Status code: {resp.status_code}. Request data: {data}, Response: {error_content}")
logger.error(f"Error executing api function with id: {function_id}. Status code: {resp.status_code}. Request data: {data}, Response: {error_content}")
elif function_type != 'api':
raise PolyApiException(f"{resp.status_code}: {error_content}")

Expand All @@ -70,7 +73,7 @@ def execute(function_type, function_id, data) -> Response:
if (resp.status_code < 200 or resp.status_code >= 300) and os.getenv("LOGS_ENABLED"):
error_content = resp.content.decode("utf-8", errors="ignore")
if function_type == 'api' and os.getenv("LOGS_ENABLED"):
raise PolyApiException(f"Error executing api function with id: {function_id}. Status code: {resp.status_code}. Request data: {data}, Response: {error_content}")
logger.error(f"Error executing api function with id: {function_id}. Status code: {resp.status_code}. Request data: {data}, Response: {error_content}")
elif function_type != 'api':
raise PolyApiException(f"{resp.status_code}: {error_content}")

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]

[project]
name = "polyapi-python"
version = "0.3.9.dev5"
version = "0.3.9.dev6"
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
dependencies = [
Expand Down