diff options
author | V3n3RiX <venerix@koprulu.sector> | 2023-04-09 14:31:14 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2023-04-09 14:31:14 +0100 |
commit | 5e2479c98551a88dc58a5fe2cbf4d025d92be26b (patch) | |
tree | e9d8dcaa8a5c60ccdef502eaada6bd54dc5dd197 | |
parent | 0d91cc6b22cebededd3bf66ad594ef0420933aff (diff) |
uninstall : simplify function arguments
-rw-r--r-- | src/backend/uninstall.py | 40 | ||||
-rwxr-xr-x | src/frontend/cli/sisyphus-cli.py | 6 | ||||
-rw-r--r-- | src/frontend/gui/sisyphus-gui.py | 2 |
3 files changed, 25 insertions, 23 deletions
diff --git a/src/backend/uninstall.py b/src/backend/uninstall.py index 3c5a280..e07c908 100644 --- a/src/backend/uninstall.py +++ b/src/backend/uninstall.py @@ -18,7 +18,7 @@ def sigint_handler(signal, frame): signal.signal(signal.SIGINT, sigint_handler) -def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): +def start(pkgname, gfx_ui=False, unmerge=False): args = ['--quiet', '--depclean'] if not sisyphus.checkenv.root() and (unmerge or depclean): @@ -39,26 +39,28 @@ def start(pkgname, depclean=False, gfx_ui=False, unmerge=False): except subprocess.TimeoutExpired: p_exe.kill() sys.exit() - elif gfx_ui: - p_exe = subprocess.Popen( - ['emerge'] + args + pkgname, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - # kill portage if the program dies or it's terminated by the user - atexit.register(sisyphus.killemerge.start, p_exe) + else: + if gfx_ui: + p_exe = subprocess.Popen( + ['emerge'] + args + pkgname, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + # kill portage if the program dies or it's terminated by the user + atexit.register(sisyphus.killemerge.start, p_exe) - for p_out in io.TextIOWrapper(p_exe.stdout, encoding="utf-8"): - print(p_out.rstrip()) + for p_out in io.TextIOWrapper(p_exe.stdout, encoding="utf-8"): + print(p_out.rstrip()) - p_exe.wait() - sisyphus.syncdb.lcl_tbl() - elif depclean: - p_exe = subprocess.Popen(['emerge'] + args + ['--ask'] + list(pkgname)) - try: p_exe.wait() sisyphus.syncdb.lcl_tbl() - except KeyboardInterrupt: - p_exe.terminate() + else: + p_exe = subprocess.Popen( + ['emerge'] + args + ['--ask'] + list(pkgname)) try: - p_exe.wait(1) - except subprocess.TimeoutExpired: - p_exe.kill() - sys.exit() + p_exe.wait() + sisyphus.syncdb.lcl_tbl() + except KeyboardInterrupt: + p_exe.terminate() + try: + p_exe.wait(1) + except subprocess.TimeoutExpired: + p_exe.kill() + sys.exit() diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py index 6ccf587..0d04e8d 100755 --- a/src/frontend/cli/sisyphus-cli.py +++ b/src/frontend/cli/sisyphus-cli.py @@ -167,10 +167,10 @@ def uninstall(pkgname: List[str], force: bool = typer.Option(False, "--force", " will succeed, but the system will be broken """ - if not force: - sisyphus.uninstall.start(pkgname, depclean=True, gfx_ui=False, unmerge=False) + if force: + sisyphus.uninstall.start(pkgname, gfx_ui=False, unmerge=True) else: - sisyphus.uninstall.start(pkgname, depclean=False, gfx_ui=False, unmerge=True) + sisyphus.uninstall.start(pkgname, gfx_ui=False, unmerge=False) @app.command("autoremove") def autoremove(): diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py index 9199510..271cad1 100644 --- a/src/frontend/gui/sisyphus-gui.py +++ b/src/frontend/gui/sisyphus-gui.py @@ -405,7 +405,7 @@ class MainWorker(QtCore.QObject): def startUninstall(self): self.started.emit() pkgname = Sisyphus.pkgname - sisyphus.uninstall.start(pkgname, depclean=False, gfx_ui=True, unmerge=False) + sisyphus.uninstall.start(pkgname, gfx_ui=True, unmerge=False) self.finished.emit() @QtCore.pyqtSlot() |