ebs-linuxnode-core 3.2.1__tar.gz → 3.2.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 (27) hide show
  1. {ebs-linuxnode-core-3.2.1/ebs_linuxnode_core.egg-info → ebs_linuxnode_core-3.2.2}/PKG-INFO +13 -1
  2. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/basenode.py +2 -0
  3. ebs_linuxnode_core-3.2.2/ebs/linuxnode/core/tempfs.py +69 -0
  4. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2/ebs_linuxnode_core.egg-info}/PKG-INFO +13 -1
  5. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs_linuxnode_core.egg-info/SOURCES.txt +1 -0
  6. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs_linuxnode_core.egg-info/requires.txt +1 -0
  7. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/setup.py +1 -0
  8. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/.gitignore +0 -0
  9. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/__init__.py +0 -0
  10. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/__init__.py +0 -0
  11. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/__init__.py +0 -0
  12. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/background.py +0 -0
  13. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/basemixin.py +0 -0
  14. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/busy.py +0 -0
  15. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/config.py +0 -0
  16. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/constants.py +0 -0
  17. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/http.py +0 -0
  18. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/log.py +0 -0
  19. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/nodeid.py +0 -0
  20. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/resources.py +0 -0
  21. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/core/shell.py +0 -0
  22. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/db/__init__.py +0 -0
  23. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs/linuxnode/db/sequence.py +0 -0
  24. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs_linuxnode_core.egg-info/dependency_links.txt +0 -0
  25. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/ebs_linuxnode_core.egg-info/top_level.txt +0 -0
  26. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/example.py +0 -0
  27. {ebs-linuxnode-core-3.2.1 → ebs_linuxnode_core-3.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ebs-linuxnode-core
3
- Version: 3.2.1
3
+ Version: 3.2.2
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
@@ -12,3 +12,15 @@ Classifier: Programming Language :: Python
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.6
14
14
  Classifier: Operating System :: POSIX :: Linux
15
+ Requires-Dist: six
16
+ Requires-Dist: setuptools-scm
17
+ Requires-Dist: appdirs
18
+ Requires-Dist: twisted[tls]
19
+ Requires-Dist: SQLAlchemy
20
+ Requires-Dist: arrow
21
+ Requires-Dist: raspi_system
22
+ Requires-Dist: netifaces
23
+ Requires-Dist: ifcfg
24
+ Requires-Dist: psutil
25
+ Requires-Dist: memory_tempfile
26
+ Requires-Dist: treq
@@ -10,6 +10,7 @@ from .shell import BaseShellMixin
10
10
  from .http import HttpClientMixin
11
11
  from .resources import ResourceManagerMixin
12
12
  from .background import BackgroundCoreMixin
13
+ from .tempfs import TempFSMixin
13
14
 
14
15
 
15
16
  class BaseIoTNode(BackgroundCoreMixin,
@@ -17,6 +18,7 @@ class BaseIoTNode(BackgroundCoreMixin,
17
18
  HttpClientMixin,
18
19
  BaseShellMixin,
19
20
  NodeBusyMixin,
21
+ TempFSMixin,
20
22
  NodeLoggingMixin,
21
23
  NodeIDMixin):
22
24
  _has_gui = False
@@ -0,0 +1,69 @@
1
+
2
+
3
+ import shutil
4
+ import tempfile
5
+ from memory_tempfile import MemoryTempfile
6
+
7
+ from .basemixin import BaseMixin
8
+ from .log import NodeLoggingMixin
9
+ from .config import ElementSpec
10
+ from .config import ItemSpec
11
+
12
+
13
+ class TempFSMixin(NodeLoggingMixin, BaseMixin):
14
+ def __init__(self, *args, **kwargs):
15
+ super(TempFSMixin, self).__init__(*args, **kwargs)
16
+ self._tempfile = None
17
+ self._tempdir = None
18
+
19
+ def install(self):
20
+ super(TempFSMixin, self).install()
21
+ _elements = {
22
+ 'tmpfs_prefer_memory': ElementSpec('tmpfs', 'memory_prefer', ItemSpec(bool, fallback=True)),
23
+ 'tmpfs_force_memory': ElementSpec('tmpfs', 'memory_force', ItemSpec(bool, fallback=False)),
24
+ 'tmpfs_clean_on_exit': ElementSpec('tmpfs', 'clean_on_exit', ItemSpec(bool, fallback=True)),
25
+ }
26
+ for name, spec in _elements.items():
27
+ self.config.register_element(name, spec)
28
+
29
+ def _tempfile_init(self):
30
+ if self.config.tmpfs_force_memory:
31
+ # TODO This should use MemoryTempfile to find a tmpfs or ramfs path,
32
+ # and fail (throw exception) if a suitable path does not exist.
33
+ # - The assumption is going to be that it will be upto the deployment
34
+ # to ensure a suitable path exists.
35
+ # - Mounting here is not viable due to permission issues
36
+ # - Using pyfilesystem2 is not viable since all users will also need
37
+ # to treat it as a pyfilesystem2 object, and external processes
38
+ # cannot be handed this path.
39
+ raise NotImplementedError
40
+ elif self.config.tmpfs_prefer_memory:
41
+ self._tempfile = MemoryTempfile()
42
+ else:
43
+ self._tempfile = tempfile
44
+
45
+ @property
46
+ def tempfile(self):
47
+ if not self._tempfile:
48
+ self._tempfile_init()
49
+ return self._tempfile
50
+
51
+ @property
52
+ def tempdir(self):
53
+ if not self._tempdir:
54
+ self._tempdir = self.tempfile.mkdtemp()
55
+ return self._tempdir
56
+
57
+ def start(self):
58
+ super().start()
59
+ self.log.debug(f"Using tempfs: {self.tempfile.gettempdir()}")
60
+ self.log.info(f"Using tempdir: {self.tempdir}")
61
+
62
+ def stop(self):
63
+ if self.tempdir:
64
+ if self.config.tmpfs_clean_on_exit:
65
+ self.log.info(f"Cleaning up tempdir: {self.tempdir}")
66
+ shutil.rmtree(self.tempdir)
67
+ else:
68
+ self.log.info(f"Not cleaning up tempdir: {self.tempdir}")
69
+ super().stop()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ebs-linuxnode-core
3
- Version: 3.2.1
3
+ Version: 3.2.2
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
@@ -12,3 +12,15 @@ Classifier: Programming Language :: Python
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.6
14
14
  Classifier: Operating System :: POSIX :: Linux
15
+ Requires-Dist: six
16
+ Requires-Dist: setuptools-scm
17
+ Requires-Dist: appdirs
18
+ Requires-Dist: twisted[tls]
19
+ Requires-Dist: SQLAlchemy
20
+ Requires-Dist: arrow
21
+ Requires-Dist: raspi_system
22
+ Requires-Dist: netifaces
23
+ Requires-Dist: ifcfg
24
+ Requires-Dist: psutil
25
+ Requires-Dist: memory_tempfile
26
+ Requires-Dist: treq
@@ -15,6 +15,7 @@ ebs/linuxnode/core/log.py
15
15
  ebs/linuxnode/core/nodeid.py
16
16
  ebs/linuxnode/core/resources.py
17
17
  ebs/linuxnode/core/shell.py
18
+ ebs/linuxnode/core/tempfs.py
18
19
  ebs/linuxnode/db/__init__.py
19
20
  ebs/linuxnode/db/sequence.py
20
21
  ebs_linuxnode_core.egg-info/PKG-INFO
@@ -8,4 +8,5 @@ raspi_system
8
8
  netifaces
9
9
  ifcfg
10
10
  psutil
11
+ memory_tempfile
11
12
  treq
@@ -15,6 +15,7 @@ _requires = [
15
15
  # System
16
16
  'ifcfg',
17
17
  'psutil',
18
+ 'memory_tempfile',
18
19
 
19
20
  # HTTP Client
20
21
  'treq',