mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 08:34:17 +02:00
0.2.0
**Features** - Management panel shows update commands streams - Management panel status label is "orange" now **Fixes** - Application name is not properly showing for Flatpak 1.2.X
This commit is contained in:
@@ -1 +1 @@
|
||||
__version__ = '0.1.0'
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class FlatpakController:
|
||||
def refresh(self) -> List[dict]:
|
||||
return self.model.read_installed()
|
||||
|
||||
def update(self, package_refs: List[str]) -> List[dict]:
|
||||
return self.model.update_apps(package_refs)
|
||||
def update(self, app_ref: str):
|
||||
return self.model.update_app(app_ref)
|
||||
|
||||
def check_installed(self) -> bool:
|
||||
version = self.model.get_version()
|
||||
|
||||
@@ -23,7 +23,7 @@ def app_str_to_json(line: str, version: str) -> dict:
|
||||
app['name'] = ref_data[0].split('.')[-1]
|
||||
app['version'] = None
|
||||
elif '1.2' <= version < '1.3':
|
||||
app = {'name': app_array[0][1].split('.')[-1],
|
||||
app = {'name': app_array[1].strip().split('.')[-1],
|
||||
'id': app_array[1],
|
||||
'version': app_array[2],
|
||||
'branch': app_array[3],
|
||||
@@ -68,8 +68,17 @@ def list_installed() -> List[dict]:
|
||||
return []
|
||||
|
||||
|
||||
def update(ref: str):
|
||||
return bool(system.run_cmd('flatpak update -y ' + ref))
|
||||
def update(app_ref: str) -> bool:
|
||||
return bool(system.run_cmd('flatpak update -y ' + app_ref))
|
||||
|
||||
|
||||
def update_and_stream(app_ref: str):
|
||||
"""
|
||||
Updates the app reference and streams Flatpak output,
|
||||
:param app_ref:
|
||||
:return:
|
||||
"""
|
||||
return system.stream_cmd(['flatpak', 'update', '-y', app_ref])
|
||||
|
||||
|
||||
def list_updates_as_str():
|
||||
|
||||
@@ -90,3 +90,19 @@ class FlatpakManager:
|
||||
return [*self.apps]
|
||||
|
||||
return []
|
||||
|
||||
def update_app(self, ref: str):
|
||||
|
||||
"""
|
||||
:param ref:
|
||||
:return: the update command stream
|
||||
"""
|
||||
|
||||
if self.apps:
|
||||
|
||||
package_found = [app for app in self.apps if app['ref'] == ref]
|
||||
|
||||
if package_found:
|
||||
return flatpak.update_and_stream(ref)
|
||||
|
||||
return None
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import os
|
||||
|
||||
app_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
def get_path(resource_path):
|
||||
app_dir = get_app_dir()
|
||||
return app_dir + '/resources/' + resource_path
|
||||
|
||||
|
||||
def get_app_dir():
|
||||
return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import subprocess
|
||||
from typing import List
|
||||
|
||||
|
||||
def run_cmd(cmd: str, expected_code: int = 0, ignore_return_code: bool = False) -> str:
|
||||
res = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
|
||||
return res.stdout.decode() if ignore_return_code or res.returncode == expected_code else None
|
||||
|
||||
|
||||
def stream_cmd(cmd: List[str]):
|
||||
return subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout
|
||||
|
||||
@@ -8,10 +8,11 @@ def get_locale_keys():
|
||||
|
||||
current_locale = locale.getdefaultlocale()
|
||||
locale_path = None
|
||||
|
||||
if current_locale:
|
||||
current_locale = current_locale[0]
|
||||
|
||||
locale_dir = '{}/resources/locale'.format(resource.get_app_dir())
|
||||
locale_dir = resource.get_path('locale')
|
||||
|
||||
for locale_file in glob.glob(locale_dir + '/*'):
|
||||
name = locale_file.split('/')[-1]
|
||||
@@ -21,7 +22,7 @@ def get_locale_keys():
|
||||
break
|
||||
|
||||
if not locale_path:
|
||||
locale_path = '{}/resources/locale/en'.format(resource.get_app_dir())
|
||||
locale_path = resource.get_path('locale/en')
|
||||
|
||||
with open(locale_path, 'r') as f:
|
||||
locale_keys = f.readlines()
|
||||
|
||||
Reference in New Issue
Block a user