mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 03:34:15 +02:00
fix: not accepting blank root passwords
This commit is contained in:
@@ -98,7 +98,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
self._available_cache = {}
|
||||
self.working_managers.clear()
|
||||
|
||||
def launch_timeshift(self, root_password: str, watcher: ProcessWatcher):
|
||||
def launch_timeshift(self, root_password: Optional[str], watcher: ProcessWatcher):
|
||||
if self._is_timeshift_launcher_available():
|
||||
try:
|
||||
Popen(['timeshift-launcher'], stderr=STDOUT)
|
||||
@@ -281,7 +281,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
self.logger.info(f'Took {tf - ti:.2f} seconds')
|
||||
return res
|
||||
|
||||
def downgrade(self, app: SoftwarePackage, root_password: str, handler: ProcessWatcher) -> bool:
|
||||
def downgrade(self, app: SoftwarePackage, root_password: Optional[str], handler: ProcessWatcher) -> bool:
|
||||
man = self._get_manager_for(app)
|
||||
|
||||
if man and app.can_be_downgraded():
|
||||
@@ -299,7 +299,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
if man:
|
||||
return man.clean_cache_for(app)
|
||||
|
||||
def upgrade(self, requirements: GenericUpgradeRequirements, root_password: str, handler: ProcessWatcher) -> bool:
|
||||
def upgrade(self, requirements: GenericUpgradeRequirements, root_password: Optional[str], handler: ProcessWatcher) -> bool:
|
||||
for man, man_reqs in requirements.sub_requirements.items():
|
||||
res = man.upgrade(man_reqs, root_password, handler)
|
||||
|
||||
@@ -324,7 +324,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
for p in res.removed:
|
||||
self._fill_post_transaction_status(p, False)
|
||||
|
||||
def uninstall(self, pkg: SoftwarePackage, root_password: str, handler: ProcessWatcher, disk_loader: DiskCacheLoader = None) -> TransactionResult:
|
||||
def uninstall(self, pkg: SoftwarePackage, root_password: Optional[str], handler: ProcessWatcher, disk_loader: DiskCacheLoader = None) -> TransactionResult:
|
||||
man = self._get_manager_for(pkg)
|
||||
|
||||
if man:
|
||||
@@ -345,7 +345,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
tf = time.time()
|
||||
self.logger.info(f'Uninstallation of {pkg} took {(tf - ti) / 60:.2f} minutes')
|
||||
|
||||
def install(self, app: SoftwarePackage, root_password: str, disk_loader: DiskCacheLoader, handler: ProcessWatcher) -> TransactionResult:
|
||||
def install(self, app: SoftwarePackage, root_password: Optional[str], disk_loader: DiskCacheLoader, handler: ProcessWatcher) -> TransactionResult:
|
||||
man = self._get_manager_for(app)
|
||||
|
||||
if man:
|
||||
@@ -418,7 +418,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
if man:
|
||||
return man.requires_root(action, app)
|
||||
|
||||
def prepare(self, task_manager: TaskManager, root_password: str, internet_available: bool):
|
||||
def prepare(self, task_manager: TaskManager, root_password: Optional[str], internet_available: bool):
|
||||
ti = time.time()
|
||||
self.logger.info("Initializing")
|
||||
taskman = task_manager if task_manager else TaskManager() # empty task manager to prevent null pointers
|
||||
@@ -516,7 +516,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
return suggestions
|
||||
return []
|
||||
|
||||
def execute_custom_action(self, action: CustomSoftwareAction, pkg: SoftwarePackage, root_password: str, watcher: ProcessWatcher):
|
||||
def execute_custom_action(self, action: CustomSoftwareAction, pkg: SoftwarePackage, root_password: Optional[str], watcher: ProcessWatcher):
|
||||
if action.requires_internet and not self.context.is_internet_available():
|
||||
raise NoInternetException()
|
||||
|
||||
@@ -582,7 +582,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
|
||||
return by_manager
|
||||
|
||||
def get_upgrade_requirements(self, pkgs: List[SoftwarePackage], root_password: str, watcher: ProcessWatcher) -> UpgradeRequirements:
|
||||
def get_upgrade_requirements(self, pkgs: List[SoftwarePackage], root_password: Optional[str], watcher: ProcessWatcher) -> UpgradeRequirements:
|
||||
by_manager = self._map_pkgs_by_manager(pkgs)
|
||||
res = GenericUpgradeRequirements([], [], [], [], {})
|
||||
|
||||
@@ -612,7 +612,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
|
||||
return res
|
||||
|
||||
def reset(self, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||
def reset(self, root_password: Optional[str], watcher: ProcessWatcher) -> bool:
|
||||
body = f"<p>{self.i18n['action.reset.body_1'].format(bold(self.context.app_name))}</p>" \
|
||||
f"<p>{self.i18n['action.reset.body_2']}</p>"
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from io import StringIO
|
||||
from math import floor
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
from typing import Iterable, List
|
||||
from typing import Iterable, List, Optional
|
||||
|
||||
from bauh.api.abstract.download import FileDownloader
|
||||
from bauh.api.abstract.handler import ProcessWatcher
|
||||
@@ -42,7 +42,7 @@ class AdaptableFileDownloader(FileDownloader):
|
||||
def is_wget_available() -> bool:
|
||||
return bool(shutil.which('wget'))
|
||||
|
||||
def _get_aria2c_process(self, url: str, output_path: str, cwd: str, root_password: str, threads: int) -> SimpleProcess:
|
||||
def _get_aria2c_process(self, url: str, output_path: str, cwd: str, root_password: Optional[str], threads: int) -> SimpleProcess:
|
||||
cmd = ['aria2c', url,
|
||||
'--no-conf',
|
||||
'-x', '16',
|
||||
@@ -71,7 +71,7 @@ class AdaptableFileDownloader(FileDownloader):
|
||||
|
||||
return SimpleProcess(cmd=cmd, root_password=root_password, cwd=cwd)
|
||||
|
||||
def _get_axel_process(self, url: str, output_path: str, cwd: str, root_password: str, threads: int) -> SimpleProcess:
|
||||
def _get_axel_process(self, url: str, output_path: str, cwd: str, root_password: Optional[str], threads: int) -> SimpleProcess:
|
||||
cmd = ['axel', url, '-n', str(threads), '-4', '-c', '-T', '5']
|
||||
|
||||
if output_path:
|
||||
@@ -79,7 +79,7 @@ class AdaptableFileDownloader(FileDownloader):
|
||||
|
||||
return SimpleProcess(cmd=cmd, cwd=cwd, root_password=root_password)
|
||||
|
||||
def _get_wget_process(self, url: str, output_path: str, cwd: str, root_password: str) -> SimpleProcess:
|
||||
def _get_wget_process(self, url: str, output_path: str, cwd: str, root_password: Optional[str]) -> SimpleProcess:
|
||||
cmd = ['wget', url, '-c', '--retry-connrefused', '-t', '10', '--no-config', '-nc']
|
||||
|
||||
if output_path:
|
||||
@@ -88,7 +88,7 @@ class AdaptableFileDownloader(FileDownloader):
|
||||
|
||||
return SimpleProcess(cmd=cmd, cwd=cwd, root_password=root_password)
|
||||
|
||||
def _rm_bad_file(self, file_name: str, output_path: str, cwd, handler: ProcessHandler, root_password: str):
|
||||
def _rm_bad_file(self, file_name: str, output_path: str, cwd, handler: ProcessHandler, root_password: Optional[str]):
|
||||
to_delete = output_path if output_path else f'{cwd}/{file_name}'
|
||||
|
||||
if to_delete and os.path.exists(to_delete):
|
||||
@@ -121,7 +121,7 @@ class AdaptableFileDownloader(FileDownloader):
|
||||
|
||||
return threads
|
||||
|
||||
def download(self, file_url: str, watcher: ProcessWatcher, output_path: str = None, cwd: str = None, root_password: str = None, substatus_prefix: str = None, display_file_size: bool = True, max_threads: int = None, known_size: int = None) -> bool:
|
||||
def download(self, file_url: str, watcher: ProcessWatcher, output_path: str = None, cwd: str = None, root_password: Optional[str] = None, substatus_prefix: str = None, display_file_size: bool = True, max_threads: int = None, known_size: int = None) -> bool:
|
||||
self.logger.info(f'Downloading {file_url}')
|
||||
handler = ProcessHandler(watcher)
|
||||
file_name = file_url.split('/')[-1]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import shutil
|
||||
from typing import Optional
|
||||
|
||||
from bauh.commons.system import SimpleProcess
|
||||
|
||||
@@ -7,9 +8,9 @@ def is_available() -> bool:
|
||||
return bool(shutil.which('timeshift'))
|
||||
|
||||
|
||||
def delete_all_snapshots(root_password: str) -> SimpleProcess:
|
||||
def delete_all_snapshots(root_password: Optional[str]) -> SimpleProcess:
|
||||
return SimpleProcess(['timeshift', '--delete-all', '--scripted'], root_password=root_password)
|
||||
|
||||
|
||||
def create_snapshot(root_password: str, mode: str) -> SimpleProcess:
|
||||
def create_snapshot(root_password: Optional[str], mode: str) -> SimpleProcess:
|
||||
return SimpleProcess(['timeshift', '--create', '--scripted', '--{}'.format(mode)], root_password=root_password)
|
||||
|
||||
Reference in New Issue
Block a user