wcp-library 1.6.4__py3-none-any.whl → 1.6.6__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.
wcp_library/__init__.py CHANGED
@@ -42,24 +42,21 @@ def divide_chunks(list_obj: list, size: int) -> Generator:
42
42
 
43
43
 
44
44
  def retry(
45
- exception: Type[Exception],
45
+ exceptions: tuple[Type[Exception]],
46
46
  max_attempts: Optional[int] = MAX_ATTEMPTS,
47
47
  delay: Optional[int] = DELAY,
48
48
  backoff: Optional[int] = BACKOFF,
49
49
  jitter: Optional[int] = JITTER,
50
50
  ) -> Callable:
51
- """Decorator to retry a synchronous function on a specified exception with
52
- exponential backoff and jitter.
53
-
54
- Args:
55
- exception (Type[Exception]): The exception type to catch and retry on.
56
- max_attempts (int): Maximum number of retry attempts.
57
- delay (int): Initial delay between retries (in seconds).
58
- backoff (int): Multiplier to increase delay after each failure.
59
- jitter (int): Maximum number of seconds to add randomly to each delay.
60
-
61
- Returns:
62
- Callable: The decorated function with retry logic.
51
+ """
52
+ Decorator to retry a synchronous function on a specified exception with exponential backoff and jitter.
53
+
54
+ :param exceptions: Tuple of exception types to catch and retry on.
55
+ :param max_attempts: Maximum number of retry attempts.
56
+ :param delay: Initial delay between retries (in seconds).
57
+ :param backoff: Multiplier to increase delay after each failure.
58
+ :param jitter: Maximum number of seconds to add randomly to each delay.
59
+ :return: The decorated function with retry logic.
63
60
  """
64
61
 
65
62
  def decorator(func: Callable) -> Callable:
@@ -70,7 +67,7 @@ def retry(
70
67
  for attempt in range(0, max_attempts):
71
68
  try:
72
69
  return func(*args, **kwargs)
73
- except exception as error:
70
+ except exceptions as error:
74
71
  if attempt == max_attempts:
75
72
  logger.error("Retry failed after %d attempts.", max_attempts)
76
73
  raise
@@ -90,24 +87,21 @@ def retry(
90
87
 
91
88
 
92
89
  def async_retry(
93
- exception: Type[Exception],
90
+ exceptions: tuple[Type[Exception]],
94
91
  max_attempts: Optional[int] = MAX_ATTEMPTS,
95
92
  delay: Optional[int] = DELAY,
96
93
  backoff: Optional[int] = BACKOFF,
97
94
  jitter: Optional[int] = JITTER,
98
95
  ) -> Callable:
99
- """Decorator to retry an async function on a specified exception
100
- with exponential backoff and jitter.
101
-
102
- Args:
103
- exception (Type[Exception]): The exception type to catch and retry on.
104
- max_attempts (int): Maximum number of retry attempts.
105
- delay (int): Initial delay between retries (in seconds).
106
- backoff (int): Multiplier to increase delay after each failure.
107
- jitter (int): Maximum number of seconds to add randomly to each delay.
108
-
109
- Returns:
110
- Callable: The decorated async function with retry logic.
96
+ """
97
+ Decorator to retry an async function on a specified exception with exponential backoff and jitter.
98
+
99
+ :param exceptions: Tuple of exception types to catch and retry on.
100
+ :param max_attempts: Maximum number of retry attempts.
101
+ :param delay: Initial delay between retries (in seconds).
102
+ :param backoff: Multiplier to increase delay after each failure.
103
+ :param jitter: Maximum number of seconds to add randomly to each delay.
104
+ :return: The decorated async function with retry logic.
111
105
  """
112
106
 
113
107
  def decorator(func: Callable) -> Callable:
@@ -118,7 +112,7 @@ def async_retry(
118
112
  for attempt in range(0, max_attempts):
119
113
  try:
120
114
  return await func(*args, **kwargs)
121
- except exception as error:
115
+ except exceptions as error:
122
116
  if attempt == max_attempts:
123
117
  logger.error("Retry failed after %d attempts.", max_attempts)
124
118
  raise
wcp_library/ftp/ftp.py CHANGED
@@ -17,7 +17,7 @@ class FTP:
17
17
 
18
18
  self._ftp_factory: ftputil.session.session_factory = ftputil.session.session_factory(port=self.port)
19
19
  self.ftp_connection: Optional[ftputil.FTPHost] = None if not (self._username and self._password) \
20
- else ftputil.FTPHost(self.host, self._username, self._password, session_factory=self._ftp_factory)
20
+ else ftputil.FTPHost(self.host, self._username, self._password) #, session_factory=self._ftp_factory)
21
21
 
22
22
  def login(self, username: str, password: str) -> None:
23
23
  """
wcp_library/sql/oracle.py CHANGED
@@ -9,6 +9,7 @@ from oracledb import ConnectionPool, AsyncConnectionPool, Connection, AsyncConne
9
9
  from wcp_library.sql import retry, async_retry
10
10
 
11
11
  logger = logging.getLogger(__name__)
12
+ oracledb.defaults.fetch_lobs = False
12
13
 
13
14
 
14
15
  def _connect_warehouse(username: str, password: str, hostname: str, port: int, database: str, min_connections: int,
@@ -44,7 +45,7 @@ def _connect_warehouse(username: str, password: str, hostname: str, port: int, d
44
45
  connection = oracledb.connect(
45
46
  user=username,
46
47
  password=password,
47
- dsn=oracledb.makedsn(hostname, port, sid=database)
48
+ dsn=oracledb.makedsn(hostname, port, service_name=database)
48
49
  )
49
50
  return connection
50
51
 
@@ -82,7 +83,7 @@ async def _async_connect_warehouse(username: str, password: str, hostname: str,
82
83
  connection = await oracledb.connect_async(
83
84
  user=username,
84
85
  password=password,
85
- dsn=oracledb.makedsn(hostname, port, sid=database)
86
+ dsn=oracledb.makedsn(hostname, port, service_name=database)
86
87
  )
87
88
  return connection
88
89
 
@@ -113,7 +114,7 @@ class OracleConnection(object):
113
114
 
114
115
  self._retry_count = 0
115
116
  self.retry_limit = 50
116
- self.retry_error_codes = ['ORA-01033', 'DPY-6005', 'DPY-4011', 'ORA-08103']
117
+ self.retry_error_codes = ['ORA-01033', 'DPY-6005', 'DPY-4011', 'ORA-08103', 'ORA-04021']
117
118
 
118
119
  @retry
119
120
  def _connect(self) -> None:
@@ -392,7 +393,7 @@ class AsyncOracleConnection(object):
392
393
 
393
394
  self._retry_count = 0
394
395
  self.retry_limit = 50
395
- self.retry_error_codes = ['ORA-01033', 'DPY-6005', 'DPY-4011', 'ORA-08103']
396
+ self.retry_error_codes = ['ORA-01033', 'DPY-6005', 'DPY-4011', 'ORA-08103', 'ORA-04021']
396
397
 
397
398
  @async_retry
398
399
  async def _connect(self) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: wcp-library
3
- Version: 1.6.4
3
+ Version: 1.6.6
4
4
  Summary: Common utilites for internal development at WCP
5
5
  Author: Mitch-Petersen
6
6
  Author-email: mitch.petersen@wcap.ca
@@ -1,4 +1,4 @@
1
- wcp_library/__init__.py,sha256=LYRBTbKUbnqHJooAKL2pzJykJ1wFwZfvqUM4LT0gCFo,4328
1
+ wcp_library/__init__.py,sha256=kfv5jNFXKn_iHjGUOp_UDtqAFiogpVRcn4Tpmkho52o,4242
2
2
  wcp_library/browser_automation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  wcp_library/browser_automation/browser.py,sha256=06xKu_lLifRzfj1TBlpZmKUeBoMqa7ye8kj0Aoy27uI,14551
4
4
  wcp_library/browser_automation/interactions.py,sha256=YTYyII81M9qoVU_iYXoF5vHCc1PSj60hStPU-nT-qyA,28941
@@ -12,7 +12,7 @@ wcp_library/credentials/oracle.py,sha256=OV02op95LNUT21cNDM4zDbD63C1ldiq--vYofDp
12
12
  wcp_library/credentials/postgres.py,sha256=B5qNPKYzuzOJZ5S4M3MCN4xUelvZ6AgyR6QJc4z0Cgo,2573
13
13
  wcp_library/emailing.py,sha256=g6g9ZHIMBq6fzUFEjhB54WnJOj0cZFVbjLsB29zAVlY,3135
14
14
  wcp_library/ftp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- wcp_library/ftp/ftp.py,sha256=Zg8WMYfzUGnpqimLjtCuKyrtNGtv0Syupgi-rh_al00,3985
15
+ wcp_library/ftp/ftp.py,sha256=_G_AGyhFAUFdO0idkIDZj2cCApF9dJSXGEHqGyvCHdg,3988
16
16
  wcp_library/ftp/sftp.py,sha256=hykXGLGdxe7DYAxFdTwjPjTEOYuIpSMyK3NOiTQNUK0,4176
17
17
  wcp_library/informatica.py,sha256=_g9lzSd-JLsY4e5_g6YcxQtOxP6fkg4sGfvNJaAN7jY,8123
18
18
  wcp_library/logging.py,sha256=e6gG7HFgUrMajUZs4Gs0atFfOJJmdmxN0GerfynNWlY,2061
@@ -20,9 +20,9 @@ wcp_library/selenium/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
20
20
  wcp_library/selenium/_selenium_driver.py,sha256=Es83ISNryOVhYGDo_xrr8nCLsbnVBeXsaz1sRiz7kLI,2961
21
21
  wcp_library/selenium/selenium_helper.py,sha256=OJvC0RlblfMWhmjNxiY582yuzkDgjzFZMuRz_8to3PY,2000
22
22
  wcp_library/sql/__init__.py,sha256=f0JyVyFyUjueQ1XdVmCgmRjzkFENmFKl3BOzrvv3i1I,2422
23
- wcp_library/sql/oracle.py,sha256=GpqUn7srm4mGxeJAU06tHaMR37zxASSdMZJ3h8KTC-U,19240
23
+ wcp_library/sql/oracle.py,sha256=hsZbnuCxEZuUdZ8Z4FVRjxAcIjkMNkHMzLEAiT51nQY,19321
24
24
  wcp_library/sql/postgres.py,sha256=cLOurfmad3WqJcE7FiSxUyzo_0patpfMcTfQAoiteuU,18525
25
25
  wcp_library/time.py,sha256=ktSzhK7SZnGPNXobFexnhFGQAcriLCJQKxnO0fed8fQ,1740
26
- wcp_library-1.6.4.dist-info/METADATA,sha256=AH0_KH7Y4RIA41vVgAtr897soW-s0UmaUYDV_g408mA,1393
27
- wcp_library-1.6.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
28
- wcp_library-1.6.4.dist-info/RECORD,,
26
+ wcp_library-1.6.6.dist-info/METADATA,sha256=it5SD45PMZplcIY5Zmh6EAR7dPmY74L7DF9Q4AupgUI,1393
27
+ wcp_library-1.6.6.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
28
+ wcp_library-1.6.6.dist-info/RECORD,,