From bacde53401852a5e8ff9176c54442fe9c94956ad Mon Sep 17 00:00:00 2001 From: Eric Lay Date: Mon, 18 Dec 2023 06:49:53 -0600 Subject: [PATCH] changed error handling --- systray-updater | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/systray-updater b/systray-updater index d6013c6..5abc916 100755 --- a/systray-updater +++ b/systray-updater @@ -21,7 +21,7 @@ else: try: f = open(config) except FileNotFoundError: - print("No config file found\n") + print("Error: No config file found\n") sys.exit(1) conf = yaml.load(f,yaml.FullLoader) term = str(conf['terminal']) @@ -56,22 +56,29 @@ match icn: # Sets the menu options, list and count in proper spots def count(): cmd = ['checkupdates'] - p1 = subprocess.Popen(cmd,stdout=subprocess.PIPE) - outputList = ((p1.communicate()[0]).decode()).rstrip('\n') - outputCount = len(outputList.splitlines()) - if outputCount == 0: + try: + p1 = subprocess.Popen(cmd,stdout=subprocess.PIPE) + outputList = ((p1.communicate()[0]).decode()).rstrip('\n') + outputCount = len(outputList.splitlines()) + if outputCount == 0: + tray.setVisible(False) + else: + menu.clear() + menu.addAction(readNews) + menu.addAction(runUpdate) + menu.addAction(quit) + for i in outputList.splitlines(): + menu.addAction(i, partial(infos, i)) + avail = str(outputCount)+" Updates" + tray.setToolTip(avail) + tray.setVisible(True) + except subprocess.CalledProcessError: tray.setVisible(False) - else: - menu.clear() - menu.addAction(readNews) - menu.addAction(runUpdate) - menu.addAction(quit) - for i in outputList.splitlines(): - menu.addAction(i, partial(infos, i)) - avail = str(outputCount)+" Updates" - tray.setToolTip(avail) - tray.setVisible(True) - + wait = 1800000 + updateTimer.killTimer + updateTimer.start(wait) + print("Error: \'checkupdates\' command unable to retrieve updates\nSetting timer to 30mins\n") + # Read the News def news(): url = 'https://archlinux.org/news/'