Clean up the logging to respect settings. Re-enable the use of SUDO when set.

This commit is contained in:
Keir Rice
2022-09-25 21:18:02 +13:00
parent d6be2b13d7
commit 7a445e0413

View File

@@ -1144,8 +1144,8 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP
try:
script = os.path.dirname(os.path.realpath(__file__)) + "/SHTC3.py"
cmd = [sys.executable, script, str(i2cbus), str(address)]
# if self._settings.get(["use_sudo"]):
# cmd.insert(0, "sudo")
if self._settings.get(["use_sudo"]):
cmd.insert(0, "sudo")
if self._settings.get(["debug_temperature_log"]) is True:
self._logger.debug("Temperature SHTC3 cmd: %s", " ".join(cmd))
@@ -1153,7 +1153,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP
stdout = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
output, errors = stdout.communicate()
if True or self._settings.get(["debug_temperature_log"]) is True:
if self._settings.get(["debug_temperature_log"]) is True:
if len(errors) > 0:
self._logger.error("SHTC3 error: %s", errors)
else: