brynq-sdk-ftp 2.0.6__tar.gz → 3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq_sdk_ftp
3
- Version: 2.0.6
3
+ Version: 3.0.0
4
4
  Summary: FTP wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -3,7 +3,7 @@ import os
3
3
  import ftplib
4
4
  import time
5
5
  from ftplib import FTP
6
- from typing import Union, List
6
+ from typing import Union, List, Optional, Literal
7
7
  from tenacity import retry, stop_after_attempt, wait_exponential_jitter, retry_if_exception
8
8
 
9
9
 
@@ -17,19 +17,25 @@ def is_ftp_exception(e: BaseException) -> bool:
17
17
 
18
18
 
19
19
  class FTPS(BrynQ):
20
- def __init__(self, label: Union[str, List] = None, debug=False):
20
+ def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug=False):
21
21
  super().__init__()
22
- if label is not None:
23
- credentials = self.get_system_credential(system='ftps', label=label)
22
+ try:
23
+ credentials = self.interfaces.credentials.get(system="ftps", system_type=system_type)
24
+ credentials = credentials.get('data')
24
25
  self.host = credentials['host']
25
26
  self.username = credentials['username']
26
27
  self.password = credentials['password']
27
- elif os.getenv("QLIK_HOST") is not None and os.getenv("QLIK_USER") is not None and os.getenv("QLIK_PASSWORD") is not None:
28
- self.host = os.getenv("QLIK_HOST")
29
- self.username = os.getenv("QLIK_USER")
30
- self.password = os.getenv("QLIK_PASSWORD")
31
- else:
32
- raise ValueError("Set the environment variables QLIK_HOST, QLIK_USER and QLIK_PASSWORD or provide the label parameter for a credential from BrynQ")
28
+ except ValueError:
29
+ print("No FTPS credentials found")
30
+ self.host = None
31
+ # if no credentials are retrieved from the platform, fallback to Qlik FTP (can only be target, never source)
32
+ if self.host is None:
33
+ if system_type == 'target' and os.getenv("QLIK_HOST") is not None and os.getenv("QLIK_USER") is not None and os.getenv("QLIK_PASSWORD") is not None:
34
+ self.host = os.getenv("QLIK_HOST")
35
+ self.username = os.getenv("QLIK_USER")
36
+ self.password = os.getenv("QLIK_PASSWORD")
37
+ else:
38
+ raise ValueError("Set the environment variables QLIK_HOST, QLIK_USER and QLIK_PASSWORD or connect an FTPS authorization to your interface in BrynQ")
33
39
  self.debug = debug
34
40
 
35
41
  @retry(stop=stop_after_attempt(5), wait=wait_exponential_jitter(initial=60, max=900), retry=retry_if_exception(is_ftp_exception), reraise=True)
@@ -4,20 +4,21 @@ from paramiko.client import SSHClient, AutoAddPolicy
4
4
  from paramiko import RSAKey
5
5
  from paramiko.sftp_attr import SFTPAttributes
6
6
  import pysftp
7
- from typing import Union, List
7
+ from typing import Union, List, Literal, Optional
8
8
  from stat import S_ISREG
9
9
  import os
10
10
 
11
11
 
12
12
  class SFTP(BrynQ):
13
- def __init__(self, interface_id:str ,system_type:str, debug=False):
13
+ def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug=False):
14
14
  """
15
15
  Init the SFTP class
16
16
  :param label: The label of the connector
17
17
  :param debug: If you want to see debug messages
18
18
  """
19
19
  super().__init__()
20
- credentials = self.interfaces.credentials.get(interface_id=interface_id, system= "sftp",system_type=system_type)
20
+ credentials = self.interfaces.credentials.get(system="sftp", system_type=system_type)
21
+ credentials = credentials.get('data')
21
22
  self.debug = debug
22
23
  if self.debug:
23
24
  print(credentials)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-ftp
3
- Version: 2.0.6
3
+ Version: 3.0.0
4
4
  Summary: FTP wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -1,4 +1,4 @@
1
- brynq-sdk-brynq>=2
1
+ brynq-sdk-brynq<5,>=4
2
2
  requests<=3,>=2
3
3
  paramiko<=4,>=2
4
4
  pysftp<1,>0.2
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name='brynq_sdk_ftp',
5
- version='2.0.6',
5
+ version='3.0.0',
6
6
  description='FTP wrapper from BrynQ',
7
7
  long_description='FTP wrapper from Brynq',
8
8
  author='BrynQ',
@@ -10,7 +10,7 @@ setup(
10
10
  packages=find_namespace_packages(include=['brynq_sdk*']),
11
11
  license='BrynQ License',
12
12
  install_requires=[
13
- 'brynq-sdk-brynq>=2',
13
+ 'brynq-sdk-brynq>=4,<5',
14
14
  'requests>=2,<=3',
15
15
  'paramiko>=2,<=4',
16
16
  'pysftp>0.2,<1',
File without changes