mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 20:14:14 +02:00
improvement: replacing subprocess commands to detected installed CLIs by Python faster native calls (shutil.which)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import re
|
||||
import re
|
||||
import shutil
|
||||
import time
|
||||
import traceback
|
||||
from subprocess import Popen, STDOUT
|
||||
@@ -16,7 +17,6 @@ from bauh.api.abstract.view import ViewComponent, TabGroupComponent, MessageType
|
||||
from bauh.api.exception import NoInternetException
|
||||
from bauh.commons.boot import CreateConfigFile
|
||||
from bauh.commons.html import bold
|
||||
from bauh.commons.system import run_cmd
|
||||
from bauh.view.core.config import CoreConfigManager
|
||||
from bauh.view.core.settings import GenericSettingsManager
|
||||
from bauh.view.core.update import check_for_update
|
||||
@@ -71,7 +71,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
refresh=False): self.is_backups_action_available}
|
||||
|
||||
def _is_timeshift_launcher_available(self) -> bool:
|
||||
return bool(run_cmd('which timeshift-launcher', print_error=False))
|
||||
return bool(shutil.which('timeshift-launcher'))
|
||||
|
||||
def is_backups_action_available(self, app_config: dict) -> bool:
|
||||
return bool(app_config['backup']['enabled']) and self._is_timeshift_launcher_available()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import time
|
||||
import traceback
|
||||
from math import floor
|
||||
@@ -29,15 +30,15 @@ class AdaptableFileDownloader(FileDownloader):
|
||||
|
||||
@staticmethod
|
||||
def is_aria2c_available() -> bool:
|
||||
return bool(run_cmd('which aria2c', print_error=False))
|
||||
return bool(shutil.which('aria2c'))
|
||||
|
||||
@staticmethod
|
||||
def is_axel_available() -> bool:
|
||||
return bool(run_cmd('which axel', print_error=False))
|
||||
return bool(shutil.which('axel'))
|
||||
|
||||
@staticmethod
|
||||
def is_wget_available() -> bool:
|
||||
return bool(run_cmd('which wget', print_error=False))
|
||||
return bool(shutil.which('wget'))
|
||||
|
||||
def _get_aria2c_process(self, url: str, output_path: str, cwd: str, root_password: str, threads: int) -> SimpleProcess:
|
||||
cmd = ['aria2c', url,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from bauh.commons.system import run_cmd, SimpleProcess
|
||||
import shutil
|
||||
|
||||
from bauh.commons.system import SimpleProcess
|
||||
|
||||
|
||||
def is_available() -> bool:
|
||||
return bool(run_cmd('which timeshift', print_error=False))
|
||||
return bool(shutil.which('timeshift'))
|
||||
|
||||
|
||||
def delete_all_snapshots(root_password: str) -> SimpleProcess:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import traceback
|
||||
from io import StringIO
|
||||
@@ -15,7 +16,6 @@ from PyQt5.QtWidgets import QSystemTrayIcon, QMenu
|
||||
from bauh import __app_name__, ROOT_DIR
|
||||
from bauh.api.abstract.model import PackageUpdate
|
||||
from bauh.api.http import HttpClient
|
||||
from bauh.commons import system
|
||||
from bauh.commons.system import run_cmd
|
||||
from bauh.context import generate_i18n
|
||||
from bauh.view.core.tray_client import TRAY_CHECK_FILE
|
||||
@@ -40,11 +40,8 @@ def get_cli_path() -> str:
|
||||
if os.path.exists(cli_path):
|
||||
return cli_path
|
||||
else:
|
||||
cli_path = system.run_cmd('which bauh-cli', print_error=False)
|
||||
return shutil.which('bauh-cli')
|
||||
|
||||
if cli_path:
|
||||
return cli_path.strip()
|
||||
|
||||
|
||||
def list_updates(logger: logging.Logger) -> List[PackageUpdate]:
|
||||
cli_path = get_cli_path()
|
||||
|
||||
Reference in New Issue
Block a user