ebs-linuxnode-core 3.2.0__tar.gz → 3.2.1__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. {ebs-linuxnode-core-3.2.0/ebs_linuxnode_core.egg-info → ebs-linuxnode-core-3.2.1}/PKG-INFO +1 -1
  2. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/http.py +12 -10
  3. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/log.py +16 -0
  4. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1/ebs_linuxnode_core.egg-info}/PKG-INFO +1 -1
  5. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/.gitignore +0 -0
  6. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/__init__.py +0 -0
  7. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/__init__.py +0 -0
  8. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/__init__.py +0 -0
  9. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/background.py +0 -0
  10. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/basemixin.py +0 -0
  11. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/basenode.py +0 -0
  12. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/busy.py +0 -0
  13. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/config.py +0 -0
  14. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/constants.py +0 -0
  15. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/nodeid.py +0 -0
  16. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/resources.py +0 -0
  17. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/core/shell.py +0 -0
  18. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/db/__init__.py +0 -0
  19. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs/linuxnode/db/sequence.py +0 -0
  20. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs_linuxnode_core.egg-info/SOURCES.txt +0 -0
  21. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs_linuxnode_core.egg-info/dependency_links.txt +0 -0
  22. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs_linuxnode_core.egg-info/requires.txt +0 -0
  23. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/ebs_linuxnode_core.egg-info/top_level.txt +0 -0
  24. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/example.py +0 -0
  25. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/setup.cfg +0 -0
  26. {ebs-linuxnode-core-3.2.0 → ebs-linuxnode-core-3.2.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ebs-linuxnode-core
3
- Version: 3.2.0
3
+ Version: 3.2.1
4
4
  Summary: Twisted based linux application node core
5
5
  Home-page: https://github.com/ebs-universe/ebs-linuxnode-core
6
6
  Author: Chintalagiri Shashank
@@ -181,20 +181,22 @@ class HttpClientMixin(NodeBusyMixin, NodeLoggingMixin, BaseMixin):
181
181
  return url
182
182
 
183
183
  @staticmethod
184
- def _strip_auth(kwargs):
185
- if 'headers' not in kwargs.keys():
186
- return kwargs
187
- if b'Authorization' in kwargs['headers'].keys():
188
- rv = copy.deepcopy(kwargs)
189
- rv['headers'][b'Authorization'] = rv['headers'][b'Authorization'][:10] + b'...'
190
- return rv
191
- return kwargs
184
+ def _sanitize(kwargs):
185
+ response = {k: v for k, v in kwargs.items() if k not in {'_files'}}
186
+ if 'headers' not in response.keys():
187
+ return response
188
+ if b'Authorization' in response['headers'].keys():
189
+ new_headers = copy.deepcopy(response['headers'])
190
+ new_headers[b'Authorization'] = new_headers[b'Authorization'][:10] + b'...'
191
+ response['headers'] = new_headers
192
+ return response
193
+ return response
192
194
 
193
195
  def http_get(self, url, **kwargs):
194
196
  self.log.debug("Executing HTTP GET Request\n"
195
197
  " to URL {url}\n"
196
198
  " with kwargs {kwargs}",
197
- url=url, kwargs=self._strip_auth(kwargs))
199
+ url=url, kwargs=self._sanitize(kwargs))
198
200
  deferred_response = self.http_semaphore.run(
199
201
  self.http_client.get, url, **kwargs
200
202
  )
@@ -211,7 +213,7 @@ class HttpClientMixin(NodeBusyMixin, NodeLoggingMixin, BaseMixin):
211
213
  self.log.debug("Executing HTTP Post Request\n"
212
214
  " to URL {url}\n"
213
215
  " with kwargs {kwargs}",
214
- url=url, kwargs=self._strip_auth(kwargs))
216
+ url=url, kwargs=self._sanitize(kwargs))
215
217
  deferred_response = self.http_semaphore.run(
216
218
  self.http_client.post, url, **kwargs
217
219
  )
@@ -4,6 +4,7 @@ import os
4
4
  import io
5
5
  import sys
6
6
  import time
7
+ import zipfile
7
8
  from twisted import logger
8
9
  from twisted.logger import LogLevel
9
10
  from twisted.logger import LogLevelFilterPredicate
@@ -102,6 +103,21 @@ class NodeLoggingMixin(ConfigMixin, BaseMixin):
102
103
  os.makedirs(user_log_dir(self.appname), exist_ok=True)
103
104
  return user_log_dir(self.appname)
104
105
 
106
+ def log_build_package(self, out_path=None):
107
+ if not out_path:
108
+ ctime = datetime.now().strftime("%Y%m%d%H%M%S")
109
+ out_path = os.path.join('/tmp', f'{self.id}.{ctime}.logs.zip')
110
+
111
+ with zipfile.ZipFile(out_path, 'w', zipfile.ZIP_DEFLATED) as zip_file:
112
+ for root, dirs, files in os.walk(self.log_dir):
113
+ for file_or_dir in files + dirs:
114
+ zip_file.write(
115
+ os.path.join(root, file_or_dir),
116
+ os.path.relpath(os.path.join(root, file_or_dir), self.log_dir)
117
+ )
118
+
119
+ return out_path
120
+
105
121
  def exim_install(self):
106
122
  super(NodeLoggingMixin, self).exim_install()
107
123
  self.exim.register_export('logs', self.log_dir)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ebs-linuxnode-core
3
- Version: 3.2.0
3
+ Version: 3.2.1
4
4
  Summary: Twisted based linux application node core
5
5
  Home-page: https://github.com/ebs-universe/ebs-linuxnode-core
6
6
  Author: Chintalagiri Shashank