Fix exceptino if upgrade_logs folder didn't exist

This commit is contained in:
Taylor Helsper 2021-10-27 20:42:12 -05:00
parent 84adfdf417
commit 159d2fa346

View File

@ -218,29 +218,34 @@ def get_all_upgrade_logs():
folder = "/home/admin/upgrade_logs/" folder = "/home/admin/upgrade_logs/"
log_id = 0 log_id = 0
# Add latest upgrade log try:
if os.path.isfile( os.path.join(folder, "upgrade_log_latest.txt") ): # Add latest upgrade log
log = {} if os.path.isfile( os.path.join(folder, "upgrade_log_latest.txt") ):
log["id"] = log_id
log["name"] = "Latest Upgrade"
modTimeSeconds = os.path.getmtime( os.path.join(folder, "upgrade_log_latest.txt") )
log["date"] = time.strftime('%Y-%m-%d', time.localtime(modTimeSeconds))
log["log"] = get_recent_upgrade_log()
log_list.append( log )
log_id += 1
# Add file logs
for f in os.listdir(folder):
fullpath = os.path.join(folder, f)
if os.path.isfile( fullpath ):
log = {} log = {}
log["id"] = log_id log["id"] = log_id
log["name"] = f log["name"] = "Latest Upgrade"
modTimeSeconds = os.path.getmtime(fullpath) modTimeSeconds = os.path.getmtime( os.path.join(folder, "upgrade_log_latest.txt") )
log["date"] = time.strftime('%Y-%m-%d', time.localtime(modTimeSeconds)) log["date"] = time.strftime('%Y-%m-%d', time.localtime(modTimeSeconds))
log["log"] = cleanup_log( get_file_contents(fullpath).decode("utf8") ) log["log"] = get_recent_upgrade_log()
log_list.append( log ) log_list.append( log )
log_id += 1 log_id += 1
# Add file logs
if os.path.isdir(folder):
for f in os.listdir(folder):
fullpath = os.path.join(folder, f)
if os.path.isfile( fullpath ):
log = {}
log["id"] = log_id
log["name"] = f
modTimeSeconds = os.path.getmtime(fullpath)
log["date"] = time.strftime('%Y-%m-%d', time.localtime(modTimeSeconds))
log["log"] = cleanup_log( get_file_contents(fullpath).decode("utf8") )
log_list.append( log )
log_id += 1
except Exception as e:
pass
return log_list return log_list
def has_checkin_error(): def has_checkin_error():