wcp-library 1.5.3__tar.gz → 1.5.7__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 (26) hide show
  1. {wcp_library-1.5.3 → wcp_library-1.5.7}/PKG-INFO +1 -1
  2. {wcp_library-1.5.3 → wcp_library-1.5.7}/pyproject.toml +1 -1
  3. wcp_library-1.5.7/wcp_library/sql/__init__.py +68 -0
  4. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/sql/postgres.py +4 -1
  5. wcp_library-1.5.3/wcp_library/sql/__init__.py +0 -63
  6. {wcp_library-1.5.3 → wcp_library-1.5.7}/README.md +0 -0
  7. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/__init__.py +0 -0
  8. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/credentials/__init__.py +0 -0
  9. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/credentials/_credential_manager_asynchronous.py +0 -0
  10. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/credentials/_credential_manager_synchronous.py +0 -0
  11. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/credentials/api.py +0 -0
  12. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/credentials/ftp.py +0 -0
  13. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/credentials/internet.py +0 -0
  14. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/credentials/oracle.py +0 -0
  15. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/credentials/postgres.py +0 -0
  16. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/emailing.py +0 -0
  17. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/ftp/__init__.py +0 -0
  18. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/ftp/ftp.py +0 -0
  19. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/ftp/sftp.py +0 -0
  20. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/informatica.py +0 -0
  21. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/logging.py +0 -0
  22. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/selenium/__init__.py +0 -0
  23. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/selenium/_selenium_driver.py +0 -0
  24. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/selenium/selenium_helper.py +0 -0
  25. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/sql/oracle.py +0 -0
  26. {wcp_library-1.5.3 → wcp_library-1.5.7}/wcp_library/time.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: wcp-library
3
- Version: 1.5.3
3
+ Version: 1.5.7
4
4
  Summary: Common utilites for internal development at WCP
5
5
  Author: Mitch-Petersen
6
6
  Author-email: mitch.petersen@wcap.ca
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "wcp-library"
3
- version = "1.5.3"
3
+ version = "1.5.7"
4
4
  description = "Common utilites for internal development at WCP"
5
5
  authors = [{name="Mitch-Petersen", email="mitch.petersen@wcap.ca"}]
6
6
  readme = "README.md"
@@ -0,0 +1,68 @@
1
+ import asyncio
2
+ import logging
3
+ from functools import wraps
4
+ from time import sleep
5
+
6
+ import oracledb
7
+ import psycopg
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+
12
+ def retry(f: callable) -> callable:
13
+ """
14
+ Decorator to retry a function
15
+
16
+ :param f: function
17
+ :return: function
18
+ """
19
+
20
+ @wraps(f)
21
+ def wrapper(self, *args, **kwargs):
22
+ self._retry_count = 0
23
+ while True:
24
+ try:
25
+ return f(self, *args, **kwargs)
26
+ except (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError) as e:
27
+ if isinstance(e, (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError, psycopg.DatabaseError)):
28
+ error_obj, = e.args
29
+ if error_obj.full_code in self.retry_error_codes and self._retry_count < self.retry_limit:
30
+ self._retry_count += 1
31
+ logger.debug("Oracle connection error")
32
+ logger.debug(error_obj.message)
33
+ logger.info("Waiting 5 minutes before retrying Oracle connection")
34
+ sleep(300)
35
+ else:
36
+ raise e
37
+ raise e
38
+ return wrapper
39
+
40
+
41
+ def async_retry(f: callable) -> callable:
42
+ """
43
+ Decorator to retry a function
44
+
45
+ :param f: function
46
+ :return: function
47
+ """
48
+
49
+ @wraps(f)
50
+ async def wrapper(self, *args, **kwargs):
51
+ self._retry_count = 0
52
+ while True:
53
+ try:
54
+ return await f(self, *args, **kwargs)
55
+ except (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError) as e:
56
+ if isinstance(e, (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError, psycopg.DatabaseError)):
57
+ error_obj, = e.args
58
+ if error_obj.full_code in self.retry_error_codes and self._retry_count < self.retry_limit:
59
+ self._retry_count += 1
60
+ logger.debug(f"{self._db_service} connection error")
61
+ logger.debug(error_obj.message)
62
+ logger.info("Waiting 5 minutes before retrying Oracle connection")
63
+ await asyncio.sleep(300)
64
+ else:
65
+ raise e
66
+ else:
67
+ raise e
68
+ return wrapper
@@ -34,6 +34,7 @@ def _connect_warehouse(username: str, password: str, hostname: str, port: int, d
34
34
  conninfo=conninfo,
35
35
  min_size=min_connections,
36
36
  max_size=max_connections,
37
+ kwargs={'options': '-c datestyle=ISO,YMD'},
37
38
  open=True
38
39
  )
39
40
  return session_pool
@@ -60,7 +61,9 @@ async def _async_connect_warehouse(username: str, password: str, hostname: str,
60
61
  session_pool = AsyncConnectionPool(
61
62
  conninfo=conninfo,
62
63
  min_size=min_connections,
63
- max_size=max_connections
64
+ max_size=max_connections,
65
+ kwargs={"options": "-c datestyle=ISO,YMD"},
66
+ open=False
64
67
  )
65
68
  return session_pool
66
69
 
@@ -1,63 +0,0 @@
1
- import asyncio
2
- import logging
3
- from functools import wraps
4
- from time import sleep
5
-
6
- import oracledb
7
- import psycopg
8
-
9
- logger = logging.getLogger(__name__)
10
-
11
-
12
- def retry(f: callable) -> callable:
13
- """
14
- Decorator to retry a function
15
-
16
- :param f: function
17
- :return: function
18
- """
19
-
20
- @wraps(f)
21
- def wrapper(self, *args, **kwargs):
22
- self._retry_count = 0
23
- while True:
24
- try:
25
- return f(self, *args, **kwargs)
26
- except (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError) as e:
27
- error_obj, = e.args
28
- if error_obj.full_code in self.retry_error_codes and self._retry_count < self.retry_limit:
29
- self._retry_count += 1
30
- logger.debug("Oracle connection error")
31
- logger.debug(error_obj.message)
32
- logger.info("Waiting 5 minutes before retrying Oracle connection")
33
- sleep(300)
34
- else:
35
- raise e
36
- return wrapper
37
-
38
-
39
- def async_retry(f: callable) -> callable:
40
- """
41
- Decorator to retry a function
42
-
43
- :param f: function
44
- :return: function
45
- """
46
-
47
- @wraps(f)
48
- async def wrapper(self, *args, **kwargs):
49
- self._retry_count = 0
50
- while True:
51
- try:
52
- return await f(self, *args, **kwargs)
53
- except (oracledb.OperationalError, oracledb.DatabaseError, psycopg.OperationalError) as e:
54
- error_obj, = e.args
55
- if error_obj.full_code in self.retry_error_codes and self._retry_count < self.retry_limit:
56
- self._retry_count += 1
57
- logger.debug(f"{self._db_service} connection error")
58
- logger.debug(error_obj.message)
59
- logger.info("Waiting 5 minutes before retrying Oracle connection")
60
- await asyncio.sleep(300)
61
- else:
62
- raise e
63
- return wrapper
File without changes