diff --git a/src/rpi-cpu2mqtt.py b/src/rpi-cpu2mqtt.py index 144fb0c..c577eb2 100644 --- a/src/rpi-cpu2mqtt.py +++ b/src/rpi-cpu2mqtt.py @@ -145,8 +145,12 @@ def get_manufacturer(): def check_git_update(): script_dir = os.path.dirname(os.path.realpath(__file__)) full_cmd = "git -C {} remote update && git -C {} status -uno".format(script_dir, script_dir) - git_update = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].decode("utf-8") - if 'Your branch is up to date' in git_update: + try: + git_update = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].decode("utf-8") + except subprocess.CalledProcessError as e: + print("Error updating git repository:", e.output) + + if any(s in git_update for s in ('Your branch is up to date', 'Your branch is up-to-date')): git_update = 'off' else: git_update = 'on'