forked from usnistgov/corr-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address usnistgov#28
- Loading branch information
Showing
5 changed files
with
39 additions
and
40 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
corrcli/watchers/platform_watcher.py → corrcli/inspectors/platform_inspector.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
"""Gather data about the platform. | ||
""" | ||
import platform | ||
from .watcher import Watcher | ||
from .inspector import Inspector | ||
|
||
|
||
class PlatformWatcher(Watcher): | ||
class PlatformInspector(Inspector): | ||
"""Gather data about the platform | ||
>>> keys = list(PlatformWatcher(None).watch().keys()) | ||
>>> keys = list(PlatformInspector(None).inspect().keys()) | ||
>>> keys.sort() | ||
>>> print(keys) | ||
['node_name', 'platform'] | ||
Attributes: | ||
pid: the process ID to watch | ||
pid: the process ID to inspector | ||
schema_dict: mapping from the observed data to the output data | ||
watch_dict: the cached observed data | ||
inspector_dict: the cached observed data | ||
""" | ||
schema_dict = {'node_name' : 'node', | ||
'platform' : 'platform'} | ||
|
||
def __init__(self, pid): | ||
super(PlatformWatcher, self).__init__(pid) | ||
super(PlatformInspector, self).__init__(pid) | ||
self.observed_dict = {} | ||
for value in self.schema_dict.values(): | ||
self.observed_dict[value] = getattr(platform, value)() | ||
|
||
def get_observed_dict(self): | ||
return self.observed_dict | ||
|
||
def watch(self, data_dict=None): | ||
def inspect(self, data_dict=None): | ||
observed_dict = self.get_observed_dict() | ||
data_dict = self.ini_data_dict(data_dict) | ||
return self.update_data_dict(observed_dict, data_dict) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters