Discovered and added jc dependency
parent
b0bd102d44
commit
4b559fb57b
|
@ -49,7 +49,7 @@ python_requires = >=3.9
|
|||
# For more information, check out https://semver.org/.
|
||||
install_requires =
|
||||
importlib-metadata; python_version<"3.9"
|
||||
|
||||
jc
|
||||
|
||||
[options.packages.find]
|
||||
where = src
|
||||
|
|
|
@ -11,6 +11,7 @@ import sys
|
|||
import subprocess
|
||||
import base64
|
||||
import json
|
||||
import jc # holy crap: takes well known utils and produces json!
|
||||
|
||||
from hetrixtools_freebsd import __version__
|
||||
|
||||
|
@ -67,6 +68,14 @@ class Update:
|
|||
self.rps2 = ""
|
||||
self.logger = logger
|
||||
|
||||
def getSysCtlAll(self):
|
||||
""" Calls sysctl -a and parses all of it into a dictionary. Rather than calling
|
||||
it 20 times and parsing each one, we just call it once, and then parse the
|
||||
various keys that it produces
|
||||
"""
|
||||
rawtext = subprocess.run(['sysctl', '-a'], subprocess.PIPE)
|
||||
self.sysctl = jc.parse('sysctl', cmd_output)
|
||||
|
||||
def callCommand(self, command=[]):
|
||||
"""Given a command and args in a list, run the command and return its
|
||||
output as a UTF-8 string"""
|
||||
|
@ -144,6 +153,9 @@ def go():
|
|||
"""Run the command."""
|
||||
update = Update(_logger)
|
||||
_logger.info(f"Starting to fetch results")
|
||||
update.getSysCtlAll()
|
||||
if( update.sysctl is not None ):
|
||||
_logger.info(f"{update.sysctl}")
|
||||
update.getCPUInfo()
|
||||
_logger.info(f"Done fetching results")
|
||||
output = update.toJsonString()
|
||||
|
|
Loading…
Reference in New Issue