mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
[snap] fix -> some environment variables are not available during the common operations
This commit is contained in:
@@ -76,6 +76,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
<img src="https://raw.githubusercontent.com/vinifmor/bauh-files/master/pictures/releases/0.9.7/flatpak_refs.png">
|
||||
</p>
|
||||
- some environment variables are not available during the common operations (install, upgrade, downgrade, uninstall)
|
||||
- Snap
|
||||
- some environment variables are not available during the common operations (install, upgrade, downgrade, uninstall, launch)
|
||||
- UI
|
||||
- crashing when nothing can be upgraded
|
||||
- random C++ wrapper errors with some forms due to missing references
|
||||
|
||||
@@ -138,13 +138,13 @@ class SnapManager(SoftwareManager):
|
||||
return SearchResult([], None, 0)
|
||||
|
||||
def downgrade(self, pkg: SnapApplication, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||
return ProcessHandler(watcher).handle(SystemProcess(subproc=snap.downgrade_and_stream(pkg.name, root_password), wrong_error_phrase=None))
|
||||
return ProcessHandler(watcher).handle_simple(snap.downgrade_and_stream(pkg.name, root_password))[0]
|
||||
|
||||
def upgrade(self, requirements: UpgradeRequirements, root_password: str, watcher: ProcessWatcher) -> SystemProcess:
|
||||
raise Exception("'upgrade' is not supported by {}".format(SnapManager.__class__.__name__))
|
||||
|
||||
def uninstall(self, pkg: SnapApplication, root_password: str, watcher: ProcessWatcher, disk_loader: DiskCacheLoader) -> TransactionResult:
|
||||
uninstalled = ProcessHandler(watcher).handle(SystemProcess(subproc=snap.uninstall_and_stream(pkg.name, root_password)))
|
||||
uninstalled = ProcessHandler(watcher).handle_simple(snap.uninstall_and_stream(pkg.name, root_password))[0]
|
||||
|
||||
if uninstalled:
|
||||
if self.suggestions_cache:
|
||||
@@ -254,7 +254,7 @@ class SnapManager(SoftwareManager):
|
||||
return action not in ('search', 'prepare')
|
||||
|
||||
def refresh(self, pkg: SnapApplication, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||
return ProcessHandler(watcher).handle(SystemProcess(subproc=snap.refresh_and_stream(pkg.name, root_password)))
|
||||
return ProcessHandler(watcher).handle_simple(snap.refresh_and_stream(pkg.name, root_password))[0]
|
||||
|
||||
def _start_category_task(self, task_man: TaskManager):
|
||||
if task_man:
|
||||
|
||||
@@ -5,7 +5,7 @@ import subprocess
|
||||
from io import StringIO
|
||||
from typing import List, Tuple, Set
|
||||
|
||||
from bauh.commons.system import new_root_subprocess, run_cmd, new_subprocess, SimpleProcess
|
||||
from bauh.commons.system import run_cmd, new_subprocess, SimpleProcess
|
||||
from bauh.gems.snap.model import SnapApplication
|
||||
|
||||
BASE_CMD = 'snap'
|
||||
@@ -171,8 +171,10 @@ def search(word: str, exact_name: bool = False) -> List[dict]:
|
||||
return apps
|
||||
|
||||
|
||||
def uninstall_and_stream(app_name: str, root_password: str):
|
||||
return new_root_subprocess([BASE_CMD, 'remove', app_name], root_password)
|
||||
def uninstall_and_stream(app_name: str, root_password: str) -> SimpleProcess:
|
||||
return SimpleProcess(cmd=[BASE_CMD, 'remove', app_name],
|
||||
root_password=root_password,
|
||||
shell=True)
|
||||
|
||||
|
||||
def install_and_stream(app_name: str, confinement: str, root_password: str) -> SimpleProcess:
|
||||
@@ -182,16 +184,19 @@ def install_and_stream(app_name: str, confinement: str, root_password: str) -> S
|
||||
if confinement == 'classic':
|
||||
install_cmd.append('--classic')
|
||||
|
||||
# return new_root_subprocess(install_cmd, root_password)
|
||||
return SimpleProcess(install_cmd, root_password=root_password)
|
||||
return SimpleProcess(install_cmd, root_password=root_password, shell=True)
|
||||
|
||||
|
||||
def downgrade_and_stream(app_name: str, root_password: str) -> subprocess.Popen:
|
||||
return new_root_subprocess([BASE_CMD, 'revert', app_name], root_password)
|
||||
def downgrade_and_stream(app_name: str, root_password: str) -> SimpleProcess:
|
||||
return SimpleProcess(cmd=[BASE_CMD, 'revert', app_name],
|
||||
root_password=root_password,
|
||||
shell=True)
|
||||
|
||||
|
||||
def refresh_and_stream(app_name: str, root_password: str) -> subprocess.Popen:
|
||||
return new_root_subprocess([BASE_CMD, 'refresh', app_name], root_password)
|
||||
def refresh_and_stream(app_name: str, root_password: str) -> SimpleProcess:
|
||||
return SimpleProcess(cmd=[BASE_CMD, 'refresh', app_name],
|
||||
root_password=root_password,
|
||||
shell=True)
|
||||
|
||||
|
||||
def run(app: SnapApplication, logger: logging.Logger):
|
||||
@@ -220,7 +225,7 @@ def run(app: SnapApplication, logger: logging.Logger):
|
||||
|
||||
if command:
|
||||
logger.info("Running '{}'".format(command))
|
||||
subprocess.Popen([BASE_CMD, 'run', command])
|
||||
subprocess.Popen('{} run {}'.format(BASE_CMD, command), shell=True)
|
||||
return
|
||||
|
||||
logger.error("No valid command found for '{}'".format(app_name))
|
||||
|
||||
Reference in New Issue
Block a user