Skip to content

Commit c04af55

Browse files
author
root
committed
Fix AttributeError when progress_bar not initialized in UI mode
The installer crashes with 'AttributeError: Installer object has no attribute progress_bar' when using kickstart with ui:true if an exception occurs before the progress_bar is created. Root cause: - When ui:true in kickstart, install_config['ui'] is True - execute() calls curses.wrapper(self._install) - Inside _install(), progress_bar is created only AFTER curses init - If exception occurs before progress_bar creation, exit_gracefully() is called which checks install_config['ui'] and tries to access progress_bar.hide() - this fails with AttributeError Fix (surgical - only modifies exit_gracefully): 1. Initialize self.progress_bar = None in __init__() 2. Initialize self.window = None in __init__() 3. In exit_gracefully(), check 'progress_bar is not None' before hide() 4. In exit_gracefully(), check 'window is not None' before addstr() This is a minimal fix that only affects error handling. Normal installer flow is unchanged - progress_bar gets created in _install() before any other code tries to use it. Signed-off-by: Daniel Casota <daniel.casota@gmail.com>
1 parent 8b63bb5 commit c04af55

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

photon_installer/installer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ def __init__(self, working_directory=Defaults.WORKING_DIRECTORY, rpm_path=None,
133133
self.ab_present = False
134134
self.mounts = []
135135
self.cwd = os.getcwd()
136+
self.progress_bar = None # Initialize to prevent AttributeError
137+
self.window = None # Initialize to prevent AttributeError
136138

137139
# some keys can have arch specific variations
138140
for key in ['packages', 'linux_flavor']:
@@ -831,8 +833,9 @@ def exit_gracefully(self, signal1=None, frame1=None):
831833
del frame1
832834
if not self.exiting and self.install_config:
833835
self.exiting = True
834-
if self.install_config['ui']:
836+
if self.install_config['ui'] and self.progress_bar is not None:
835837
self.progress_bar.hide()
838+
if self.install_config['ui'] and self.window is not None:
836839
self.window.addstr(0, 0, 'Oops, Installer got interrupted.\n\n' +
837840
'Press any key to get to the bash...')
838841
self.window.content_window().getch()

0 commit comments

Comments
 (0)