From 137d2d58d967e837bc86ae8f33ae81396afc1298 Mon Sep 17 00:00:00 2001 From: erg Date: Mon, 6 Mar 2023 09:40:53 +0100 Subject: Fix for os.getuser() fails in certain conditions, replace with getpass.getuser() --- py_relay.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py_relay.py b/py_relay.py index d492ab0..0c98d7f 100644 --- a/py_relay.py +++ b/py_relay.py @@ -8,7 +8,7 @@ Gets temperature from one wire sensor. Attempts to keep temperature between given min and max. Writes its own log as well as temperature data with timestamps to CSV file. """ -import os +import getpass import pigpio from math import isnan @@ -19,7 +19,7 @@ from csv import writer __author__ = "Franek Ɓazarewicz-Muradyan" __licence__ = "GPL" __version__ = "0.0.1" -__status__ = "Proof of concept" +__status__ = "Development" # One wire temperature sensor settings W1_SENSOR_ID = '28-0517c1b121ff' @@ -32,7 +32,7 @@ TEMPERATURE_MIN = 20 TEMPERATURE_MAX = 24 # TEMPERATURE_MIN = 28 # TEMPERATURE_MAX = 32 -USERNAME = os.getlogin() +USERNAME = getpass.getuser() LOGNAME = f'/var/log/{USERNAME}/shroombox.log' DATA_FILE = f'/var/log/{USERNAME}/shroombox.csv' -- cgit v1.2.3-65-gdbad