brynq-sdk-projuice 1.0.0__tar.gz

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.
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 1.0
2
+ Name: brynq_sdk_projuice
3
+ Version: 1.0.0
4
+ Summary: Projuice wrapper from BrynQ
5
+ Home-page: UNKNOWN
6
+ Author: BrynQ
7
+ Author-email: support@brynq.com
8
+ License: BrynQ License
9
+ Description: Projuice wrapper from BrynQ
10
+ Platform: UNKNOWN
@@ -0,0 +1 @@
1
+ from .projuice import Projuice
@@ -0,0 +1,63 @@
1
+ import os
2
+ import requests
3
+ from brynq_sdk_brynq import BrynQ
4
+ from requests.auth import HTTPBasicAuth
5
+ from typing import Union, List, Optional,Literal
6
+
7
+
8
+ class Projuice(BrynQ):
9
+ """
10
+ ProJuice SDK integrated with BrynQ for secure file uploads.
11
+ """
12
+
13
+ def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug=False):
14
+ """
15
+ Initializes the ProJuice SDK by retrieving system credentials and setting up authentication.
16
+
17
+ :param label: The credential label(s) for ProJuice.
18
+ :param debug: Enables debug logging if set to True.
19
+ """
20
+ super().__init__()
21
+ credentials = self.interfaces.credentials.get(system="projuice", system_type=system_type)
22
+ credentials = credentials.get('data')
23
+ self.username = f"{credentials['identifier']}"
24
+ self.password = f"{credentials['api_key']}"
25
+ self.base_url = f"https://{credentials['base_url']}/webservice_v2.php"
26
+ self.debug = debug
27
+
28
+ def upload_file(self, file_path: str) -> Optional[requests.Response]:
29
+ """
30
+ Uploads a file to the ProJuice web service.
31
+
32
+ :param file_path: Path to the file to be uploaded.
33
+ :return: Response object from the server if any response was received, otherwise None.
34
+ """
35
+ try:
36
+ with open(file_path, "rb") as file:
37
+ files = {"file": (os.path.basename(file_path), file, "text/csv")}
38
+
39
+ # 20 seconds to connect, 30 minutes to wait for response
40
+ response = requests.post(self.base_url, files=files, auth=HTTPBasicAuth(self.username, self.password), timeout=(20, 1800))
41
+
42
+ # Do not raise_for_status — caller should decide how to handle HTTP errors
43
+ if self.debug:
44
+ print(f"[DEBUG] Upload complete - status code: {response.status_code}")
45
+ return response
46
+
47
+ except requests.exceptions.RequestException as err:
48
+ # Handle all network-related issues (connection, timeout, etc.)
49
+ if self.debug:
50
+ print(f"[DEBUG] Request exception occurred: {err}")
51
+
52
+ # If the exception contains a response, return it
53
+ if hasattr(err, "response") and err.response is not None:
54
+ if self.debug:
55
+ print(f"[DEBUG] Returning error response - status code: {err.response.status_code}")
56
+ return err.response
57
+
58
+ except Exception as e:
59
+ if self.debug:
60
+ print(f"[DEBUG] Unexpected error: {type(e).__name__} - {e}")
61
+
62
+ # Returns None when no response is ever received
63
+ return None
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 1.0
2
+ Name: brynq-sdk-projuice
3
+ Version: 1.0.0
4
+ Summary: Projuice wrapper from BrynQ
5
+ Home-page: UNKNOWN
6
+ Author: BrynQ
7
+ Author-email: support@brynq.com
8
+ License: BrynQ License
9
+ Description: Projuice wrapper from BrynQ
10
+ Platform: UNKNOWN
@@ -0,0 +1,9 @@
1
+ setup.py
2
+ brynq_sdk_projuice/__init__.py
3
+ brynq_sdk_projuice/projuice.py
4
+ brynq_sdk_projuice.egg-info/PKG-INFO
5
+ brynq_sdk_projuice.egg-info/SOURCES.txt
6
+ brynq_sdk_projuice.egg-info/dependency_links.txt
7
+ brynq_sdk_projuice.egg-info/not-zip-safe
8
+ brynq_sdk_projuice.egg-info/requires.txt
9
+ brynq_sdk_projuice.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ brynq-sdk-brynq<5,>=4
@@ -0,0 +1 @@
1
+ brynq_sdk_projuice
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,16 @@
1
+ from setuptools import setup, find_namespace_packages
2
+
3
+ setup(
4
+ name='brynq_sdk_projuice',
5
+ version='1.0.0',
6
+ description='Projuice wrapper from BrynQ',
7
+ long_description='Projuice wrapper from BrynQ',
8
+ author='BrynQ',
9
+ author_email='support@brynq.com',
10
+ packages=find_namespace_packages(include=['brynq_sdk*']),
11
+ license='BrynQ License',
12
+ install_requires=[
13
+ 'brynq-sdk-brynq>=4,<5',
14
+ ],
15
+ zip_safe=False,
16
+ )