dtPyAppFramework 1.4__tar.gz → 1.4.2__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 (36) hide show
  1. {dtpyappframework-1.4/src/dtPyAppFramework.egg-info → dtpyappframework-1.4.2}/PKG-INFO +1 -1
  2. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/settings/__init__.py +45 -0
  3. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/settings/secrets/__init__.py +7 -3
  4. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/settings/secrets/local_secret_store.py +4 -2
  5. dtpyappframework-1.4.2/src/dtPyAppFramework/version.dat +1 -0
  6. {dtpyappframework-1.4 → dtpyappframework-1.4.2/src/dtPyAppFramework.egg-info}/PKG-INFO +1 -1
  7. dtpyappframework-1.4/src/dtPyAppFramework/version.dat +0 -1
  8. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/LICENCE.txt +0 -0
  9. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/MANIFEST.in +0 -0
  10. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/README.md +0 -0
  11. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/pyproject.toml +0 -0
  12. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/requirements.txt +0 -0
  13. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/setup.cfg +0 -0
  14. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/setup.py +0 -0
  15. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/__init__.py +0 -0
  16. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/application.py +0 -0
  17. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/cloud/__init__.py +0 -0
  18. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/cloud/aws.py +0 -0
  19. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/cloud/azure.py +0 -0
  20. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/cloud/cloud_session.py +0 -0
  21. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/decorators/__init__.py +0 -0
  22. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/logging/__init__.py +0 -0
  23. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/logging/default_logging.py +0 -0
  24. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/misc/__init__.py +0 -0
  25. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/paths/__init__.py +0 -0
  26. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/process/__init__.py +0 -0
  27. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/process/multiprocessing.py +0 -0
  28. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/resources/__init__.py +0 -0
  29. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/settings/secrets/aws_secret_store.py +0 -0
  30. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/settings/secrets/azure_secret_store.py +0 -0
  31. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/settings/secrets/secret_store.py +0 -0
  32. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework/settings/settings_reader.py +0 -0
  33. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework.egg-info/SOURCES.txt +0 -0
  34. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework.egg-info/dependency_links.txt +0 -0
  35. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework.egg-info/requires.txt +0 -0
  36. {dtpyappframework-1.4 → dtpyappframework-1.4.2}/src/dtPyAppFramework.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dtPyAppFramework
3
- Version: 1.4
3
+ Version: 1.4.2
4
4
  Summary: A Python library for common features in application development.
5
5
  Author-email: Digital-Thought <dev@digital-thought.org>
6
6
  Maintainer-email: Digital-Thought <dev@digital-thought.org>
@@ -1,3 +1,5 @@
1
+ import logging
2
+
1
3
  from ..paths import ApplicationPaths
2
4
  from ..decorators import singleton
3
5
  from .settings_reader import SettingsReader
@@ -53,6 +55,49 @@ class Settings(dict):
53
55
  self.secret_manager = SecretsManager(application_paths=self.application_paths, application_settings=self,
54
56
  cloud_session_manager=self.cloud_session_manager)
55
57
 
58
+ def persist_settings(self, settings, scope):
59
+ if scope == 'app':
60
+ p = os.path.join(os.getcwd(), "config")
61
+ elif scope == 'all_user':
62
+ p = self.application_paths.app_data_root_path
63
+ elif scope == 'current_user':
64
+ p = self.application_paths.usr_data_root_path
65
+ else:
66
+ raise Exception(f'The Settings Scope "{scope}" is not recognised.')
67
+
68
+ p = os.path.join(p, 'config.yaml')
69
+ with open(p, 'w') as i_set:
70
+ i_set.write(settings)
71
+
72
+ def get_raw_settings(self):
73
+ raw_settings = {}
74
+
75
+ for key in ['app', 'all_user', 'current_user']:
76
+ raw_settings[key] = {'read_only': False, 'raw_data': ''}
77
+
78
+ p = None
79
+ if key == 'app':
80
+ p = os.path.join(os.getcwd(), "config")
81
+ elif key == 'all_user':
82
+ p = self.application_paths.app_data_root_path
83
+ elif key == 'current_user':
84
+ p = self.application_paths.usr_data_root_path
85
+
86
+ p = os.path.join(p, 'config.yaml')
87
+ if os.path.exists(p):
88
+ with open(p, 'r') as i_set:
89
+ raw_settings[key]['raw_data'] = i_set.read()
90
+
91
+ try:
92
+ with open(p, 'w') as o_set:
93
+ o_set.write(raw_settings[key]['raw_data'])
94
+ raw_settings[key]['read_only'] = False
95
+ except Exception as ex:
96
+ logging.exception(str(ex))
97
+ raw_settings[key]['read_only'] = True
98
+
99
+ return raw_settings
100
+
56
101
  def get_requests_tor_proxy(self) -> dict:
57
102
  """
58
103
  Gets TOR Proxy configuration in a format compatible with Requests.
@@ -59,9 +59,13 @@ class SecretsManager(object):
59
59
  _index = {"User_Local_Store": {}, "App_Local_Store": {}}
60
60
  for key in _index:
61
61
  store: LocalSecretStore = self.get_store(key)
62
- _index[key]['available'] = store.store_available
63
- _index[key]['index'] = store.get_index()
64
- _index[key]['read_only'] = store.store_read_only
62
+ try:
63
+ _index[key]['available'] = store.store_available
64
+ _index[key]['index'] = store.get_index()
65
+ _index[key]['read_only'] = store.store_read_only
66
+ except Exception as ex:
67
+ logging.error(str(ex))
68
+ _index[key]['available'] = False
65
69
 
66
70
  return _index
67
71
 
@@ -148,7 +148,8 @@ class LocalSecretStore(AbstractSecretStore):
148
148
  self.store.setPassword(account=key, password=value)
149
149
  self.__save()
150
150
  index = self.get_index()
151
- index.append(key)
151
+ if key not in index:
152
+ index.append(key)
152
153
  self.__set_index(index)
153
154
 
154
155
  def delete_secret(self, key):
@@ -161,7 +162,8 @@ class LocalSecretStore(AbstractSecretStore):
161
162
  entry = self.store.setPassword(account=key, password='NONE')
162
163
  self.__save()
163
164
  index = self.get_index()
164
- index.remove(key)
165
+ while key in index:
166
+ index.remove(key)
165
167
  self.__set_index(index)
166
168
 
167
169
  def __set_index(self, index: list):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dtPyAppFramework
3
- Version: 1.4
3
+ Version: 1.4.2
4
4
  Summary: A Python library for common features in application development.
5
5
  Author-email: Digital-Thought <dev@digital-thought.org>
6
6
  Maintainer-email: Digital-Thought <dev@digital-thought.org>