wcp-library 1.1.3__tar.gz → 1.1.5__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.
Files changed (24) hide show
  1. {wcp_library-1.1.3 → wcp_library-1.1.5}/PKG-INFO +1 -1
  2. {wcp_library-1.1.3 → wcp_library-1.1.5}/pyproject.toml +1 -1
  3. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/ftp/ftp.py +4 -0
  4. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/ftp/sftp.py +14 -6
  5. {wcp_library-1.1.3 → wcp_library-1.1.5}/README.md +0 -0
  6. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/__init__.py +0 -0
  7. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/async_credentials/__init__.py +0 -0
  8. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/async_credentials/api.py +0 -0
  9. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/async_credentials/oracle.py +0 -0
  10. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/async_credentials/postgres.py +0 -0
  11. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/async_sql/__init__.py +0 -0
  12. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/async_sql/oracle.py +0 -0
  13. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/async_sql/postgres.py +0 -0
  14. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/credentials/__init__.py +0 -0
  15. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/credentials/ftp.py +0 -0
  16. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/credentials/oracle.py +0 -0
  17. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/credentials/postgres.py +0 -0
  18. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/emailing.py +0 -0
  19. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/ftp/__init__.py +0 -0
  20. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/informatica.py +0 -0
  21. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/logging.py +0 -0
  22. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/sql/__init__.py +0 -0
  23. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/sql/oracle.py +0 -0
  24. {wcp_library-1.1.3 → wcp_library-1.1.5}/wcp_library/sql/postgres.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wcp-library
3
- Version: 1.1.3
3
+ Version: 1.1.5
4
4
  Summary: Common utilites for internal development at WCP
5
5
  Home-page: https://github.com/Whitecap-DNA/WCP-Library
6
6
  Author: Mitch-Petersen
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "wcp-library"
3
- version = "1.1.3"
3
+ version = "1.1.5"
4
4
  description = "Common utilites for internal development at WCP"
5
5
  authors = ["Mitch-Petersen <mitch.petersen@wcap.ca>"]
6
6
  readme = "README.md"
@@ -44,6 +44,8 @@ class FTP:
44
44
  :return:
45
45
  """
46
46
 
47
+ local_file.parent.mkdir(parents=True, exist_ok=True)
48
+
47
49
  logger.debug(f"Downloading {remote_file} to {local_file}")
48
50
  self.ftp_connection.download(remote_file, local_file)
49
51
 
@@ -56,6 +58,8 @@ class FTP:
56
58
  :return:
57
59
  """
58
60
 
61
+ local_dir.mkdir(parents=True, exist_ok=True)
62
+
59
63
  logger.debug(f"Downloading files from FTP server matching {regex_pattern} to {local_dir}")
60
64
  files = self.list_files()
61
65
  for file in files:
@@ -10,17 +10,21 @@ logger = logging.getLogger(__name__)
10
10
 
11
11
 
12
12
  class SFTP:
13
- def __init__(self, host: str, port: int=22):
14
- self.host: str = host
15
- self.port: int = port
16
- self._username: Optional[str] = None
17
- self._password: Optional[str] = None
13
+ def __init__(self, host: Optional[str]=None, port: Optional[int]=21, password_vault_dict: Optional[dict]=None):
14
+ self.host: str = host if not password_vault_dict else password_vault_dict['Host']
15
+ self.port: int = port if not password_vault_dict else password_vault_dict['Port']
16
+ self._username: Optional[str] = None if not password_vault_dict else password_vault_dict['UserName']
17
+ self._password: Optional[str] = None if not password_vault_dict else password_vault_dict['Password']
18
18
 
19
19
  self.ssh = paramiko.SSHClient()
20
20
  # AutoAddPolicy automatically adds the hostname and new host key to the local HostKeys object
21
21
  self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
22
22
 
23
- self.sftp_connection: Optional[paramiko.SFTP] = None
23
+ if not (self._username and self._password):
24
+ self.sftp_connection: Optional[paramiko.SFTP] = None
25
+ else:
26
+ self.ssh.connect(self.host, self.port, self._username, self._password)
27
+ self.sftp_connection = self.ssh.open_sftp()
24
28
 
25
29
  def login(self, username: str, password: str) -> None:
26
30
  """
@@ -44,6 +48,8 @@ class SFTP:
44
48
  :return:
45
49
  """
46
50
 
51
+ local_file.parent.mkdir(parents=True, exist_ok=True)
52
+
47
53
  logger.debug(f"Downloading {remote_file} to {local_file}")
48
54
  self.sftp_connection.get(str(remote_file), local_file)
49
55
 
@@ -56,6 +62,8 @@ class SFTP:
56
62
  :return:
57
63
  """
58
64
 
65
+ local_dir.mkdir(parents=True, exist_ok=True)
66
+
59
67
  logger.debug(f"Downloading files from FTP server matching {regex_pattern} to {local_dir}")
60
68
  files = self.list_files()
61
69
  for file in files:
File without changes