Discovered and added jc dependency

main
Paco Hope 2023-10-04 15:35:37 -04:00
parent b0bd102d44
commit 4b559fb57b
2 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -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()