diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-02-21 09:41:53 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-02-21 10:09:15 +0100 |
commit | ca1af1776db2046f5339720bf3036ab31f0685e0 (patch) | |
tree | 00f191a67bfca572d8754f3ff864b3553c86d849 /ogcp/views.py | |
parent | 8fa2d071344675200e15b23343cc92dace0e7d65 (diff) |
views: use getter to access PART_TYPE_CODES and FS_CODES1.1.3-16
otherwise KeyError is raised on access to undefine value in the dictionary.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 16 |
1 files 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)) |