changed error handling

This commit is contained in:
Eric Lay 2023-12-18 06:49:53 -06:00
parent be62ddb4bf
commit bacde53401
1 changed files with 23 additions and 16 deletions

View File

@ -21,7 +21,7 @@ else:
try: try:
f = open(config) f = open(config)
except FileNotFoundError: except FileNotFoundError:
print("No config file found\n") print("Error: No config file found\n")
sys.exit(1) sys.exit(1)
conf = yaml.load(f,yaml.FullLoader) conf = yaml.load(f,yaml.FullLoader)
term = str(conf['terminal']) term = str(conf['terminal'])
@ -56,6 +56,7 @@ match icn:
# Sets the menu options, list and count in proper spots # Sets the menu options, list and count in proper spots
def count(): def count():
cmd = ['checkupdates'] cmd = ['checkupdates']
try:
p1 = subprocess.Popen(cmd,stdout=subprocess.PIPE) p1 = subprocess.Popen(cmd,stdout=subprocess.PIPE)
outputList = ((p1.communicate()[0]).decode()).rstrip('\n') outputList = ((p1.communicate()[0]).decode()).rstrip('\n')
outputCount = len(outputList.splitlines()) outputCount = len(outputList.splitlines())
@ -71,6 +72,12 @@ def count():
avail = str(outputCount)+" Updates" avail = str(outputCount)+" Updates"
tray.setToolTip(avail) tray.setToolTip(avail)
tray.setVisible(True) tray.setVisible(True)
except subprocess.CalledProcessError:
tray.setVisible(False)
wait = 1800000
updateTimer.killTimer
updateTimer.start(wait)
print("Error: \'checkupdates\' command unable to retrieve updates\nSetting timer to 30mins\n")
# Read the News # Read the News
def news(): def news():