views: use getter to access PART_TYPE_CODES and FS_CODES

otherwise KeyError is raised on access to undefine value in the dictionary.
master 1.1.3-16
OpenGnSys Support Team 2024-02-21 09:41:53 +01:00
parent 8fa2d07134
commit ca1af1776d
1 changed files with 8 additions and 8 deletions

View File

@ -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))