Fixed installer.py

Fixed Update issue added missing function update_components() to installer.py

Signed-off-by: Mithun Gowda B <mithungowda.b7411@gmail.com>
This commit is contained in:
Mithun Gowda B
2025-07-23 17:36:15 +05:30
committed by GitHub
parent 1ae2c57726
commit f7a9e19a9a

View File

@@ -9,10 +9,13 @@ import tempfile
from datetime import datetime
from .component import Component
class Installer:
"""Main installer orchestrator"""
def __init__(self, install_dir: Optional[Path] = None, dry_run: bool = False):
def __init__(self,
install_dir: Optional[Path] = None,
dry_run: bool = False):
"""
Initialize installer
@@ -25,6 +28,8 @@ class Installer:
self.dry_run = dry_run
self.components: Dict[str, Component] = {}
self.installed_components: Set[str] = set()
self.updated_components: Set[str] = set()
self.failed_components: Set[str] = set()
self.skipped_components: Set[str] = set()
self.backup_path: Optional[Path] = None
@@ -70,7 +75,8 @@ class Installer:
return
if name in resolving:
raise ValueError(f"Circular dependency detected involving {name}")
raise ValueError(
f"Circular dependency detected involving {name}")
if name not in self.components:
raise ValueError(f"Unknown component: {name}")
@@ -104,7 +110,9 @@ class Installer:
stat = shutil.disk_usage(self.install_dir.parent)
free_mb = stat.free / (1024 * 1024)
if free_mb < 500:
errors.append(f"Insufficient disk space: {free_mb:.1f}MB free (500MB required)")
errors.append(
f"Insufficient disk space: {free_mb:.1f}MB free (500MB required)"
)
except Exception as e:
errors.append(f"Could not check disk space: {e}")
@@ -162,21 +170,20 @@ class Installer:
# Create archive only if there are files to backup
if any(temp_backup.iterdir()):
shutil.make_archive(
backup_path.with_suffix(''),
'gztar',
temp_dir,
backup_name
)
shutil.make_archive(backup_path.with_suffix(''), 'gztar',
temp_dir, backup_name)
else:
# Create empty backup file to indicate backup was attempted
backup_path.touch()
print(f"Warning: No files to backup, created empty backup marker: {backup_path.name}")
print(
f"Warning: No files to backup, created empty backup marker: {backup_path.name}"
)
self.backup_path = backup_path
return backup_path
def install_component(self, component_name: str, config: Dict[str, Any]) -> bool:
def install_component(self, component_name: str,
config: Dict[str, Any]) -> bool:
"""
Install a single component
@@ -215,6 +222,7 @@ class Installer:
if success:
self.installed_components.add(component_name)
self.updated_components.add(component_name)
else:
self.failed_components.add(component_name)
@@ -225,7 +233,9 @@ class Installer:
self.failed_components.add(component_name)
return False
def install_components(self, component_names: List[str], config: Optional[Dict[str, Any]] = None) -> bool:
def install_components(self,
component_names: List[str],
config: Optional[Dict[str, Any]] = None) -> bool:
"""
Install multiple components in dependency order
@@ -292,6 +302,10 @@ class Installer:
print("\nAll components validated successfully!")
else:
print("\nSome components failed validation. Check errors above.")
def update_components(self, component_names: List[str], config: Dict[str, Any]) -> bool:
"""Alias for update operation (uses install logic)"""
return self.install_components(component_names, config)
def get_installation_summary(self) -> Dict[str, Any]:
"""
@@ -308,3 +322,10 @@ class Installer:
'install_dir': str(self.install_dir),
'dry_run': self.dry_run
}
def get_update_summary(self) -> Dict[str, Any]:
return {
'updated': list(self.updated_components),
'failed': list(self.failed_components),
'backup_path': str(self.backup_path) if self.backup_path else None
}