From ca1af1776db2046f5339720bf3036ab31f0685e0 Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Wed, 21 Feb 2024 09:41:53 +0100 Subject: views: use getter to access PART_TYPE_CODES and FS_CODES otherwise KeyError is raised on access to undefine value in the dictionary. --- ogcp/views.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index 42dd160..1ce6749 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -831,8 +831,8 @@ def action_image_restore(): form.partition.choices = [ (f"{disk_id} {part_id}", f"Disk {disk_id} | Partition {part_id} " - f"| {PART_TYPE_CODES[part_code]} " - f"{FS_CODES[filesystem]}") + f"| {PART_CODES.get(part_code, 'UNKNOWN')} " + f"{FS_CODES.get(filesystem, 'UNKNOWN')}") for disk_id, part_id, part_code, filesystem in part_choices ] scopes, clients = get_scopes(set(ips)) selected_clients = list(get_selected_clients(scopes['scope']).items()) @@ -926,8 +926,8 @@ def action_software(): form.os.choices.append( (f"{part.get('disk')} {part.get('partition')}", f"Disk {part.get('disk')} | Partition {part.get('partition')} " - f"| {PART_TYPE_CODES[part.get('code')]} " - f"{FS_CODES[part.get('filesystem')]}") + f"| {PART_TYPE_CODES.get(part.get('code'), 'UNKNOWN')} " + f"{FS_CODES.get(part.get('filesystem'), 'UNKNOWN')}") ) return render_template('actions/software.html', form=form, scopes=scopes) @@ -1715,8 +1715,8 @@ def action_image_create(): form.os.choices.append( (f"{part.get('disk')} {part.get('partition')} {part.get('code')}", f"Disk {part.get('disk')} | Partition {part.get('partition')} " - f"| {PART_TYPE_CODES[part.get('code')]} " - f"{FS_CODES[part.get('filesystem')]}") + f"| {PART_TYPE_CODES.get(part.get('code'), 'UNKNOWN')]} " + f"{FS_CODES.get(part.get('filesystem'), 'UNKNOWN')}") ) r = server.get('/client/info', payload={'client': list(ips)}) if not r: @@ -1822,8 +1822,8 @@ def action_image_update(): form.os.choices.append( (f"{part.get('disk')} {part.get('partition')} {part.get('code')}", f"Disk {part.get('disk')} | Partition {part.get('partition')} " - f"| {PART_TYPE_CODES[part.get('code')]} " - f"{FS_CODES[part.get('filesystem')]}") + f"| {PART_TYPE_CODES.get(part.get('code'), 'UNKNOWN')]} " + f"{FS_CODES.get(part.get('filesystem'), 'UNKNOWN')}") ) scopes, _clients = get_scopes(set(ips)) -- cgit v1.2.3-18-g5258