mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 08:44:15 +02:00
[flatpak] initial partial update support | [ui] trying to fix resize issues
This commit is contained in:
@@ -104,16 +104,29 @@ class FlatpakManager(SoftwareManager):
|
|||||||
if thread_updates:
|
if thread_updates:
|
||||||
thread_updates.join()
|
thread_updates.join()
|
||||||
|
|
||||||
|
update_map = updates[0]
|
||||||
for app_json in installed:
|
for app_json in installed:
|
||||||
model = self._map_to_model(app_json=app_json, installed=True,
|
model = self._map_to_model(app_json=app_json, installed=True,
|
||||||
disk_loader=disk_loader, internet=internet_available)
|
disk_loader=disk_loader, internet=internet_available)
|
||||||
if version >= '1.5.0':
|
model.update = None
|
||||||
model.update = '{}/{}'.format(app_json['id'], app_json['branch']) in updates[0] if updates else None
|
|
||||||
else:
|
|
||||||
model.update = app_json['ref'] in updates[0] if updates else None
|
|
||||||
|
|
||||||
models.append(model)
|
models.append(model)
|
||||||
|
|
||||||
|
if update_map['full'] or update_map['partial']:
|
||||||
|
if version >= '1.5.0':
|
||||||
|
update_id = '{}/{}'.format(app_json['id'], app_json['branch'])
|
||||||
|
|
||||||
|
if update_map['full'] and update_id in update_map['full']:
|
||||||
|
model.update = True
|
||||||
|
|
||||||
|
if update_map['partial']:
|
||||||
|
for partial in update_map['partial']:
|
||||||
|
if app_json['id'] in partial and '/' + app_json['branch'] in partial:
|
||||||
|
partial_model = model.gen_partial(partial.split('/')[0])
|
||||||
|
partial_model.update = True
|
||||||
|
models.append(partial_model)
|
||||||
|
else:
|
||||||
|
model.update = app_json['ref'] in updates[0] if updates else None
|
||||||
|
|
||||||
return SearchResult(models, None, len(models))
|
return SearchResult(models, None, len(models))
|
||||||
|
|
||||||
def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool:
|
def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from typing import List
|
from typing import List, Dict
|
||||||
|
|
||||||
from bauh.api.exception import NoInternetException
|
from bauh.api.exception import NoInternetException
|
||||||
from bauh.commons.system import new_subprocess, run_cmd, new_root_subprocess
|
from bauh.commons.system import new_subprocess, run_cmd, new_root_subprocess
|
||||||
@@ -157,22 +157,31 @@ def uninstall(app_ref: str):
|
|||||||
return new_subprocess([BASE_CMD, 'uninstall', app_ref, '-y'])
|
return new_subprocess([BASE_CMD, 'uninstall', app_ref, '-y'])
|
||||||
|
|
||||||
|
|
||||||
def list_updates_as_str(version: str):
|
def list_updates_as_str(version: str) -> Dict[str, set]:
|
||||||
if version < '1.2':
|
if version < '1.2':
|
||||||
|
# TODO
|
||||||
return run_cmd('{} update --no-related'.format(BASE_CMD), ignore_return_code=True)
|
return run_cmd('{} update --no-related'.format(BASE_CMD), ignore_return_code=True)
|
||||||
else:
|
else:
|
||||||
updates = new_subprocess([BASE_CMD, 'update']).stdout
|
updates = new_subprocess([BASE_CMD, 'update']).stdout
|
||||||
|
|
||||||
out = StringIO()
|
reg = r'[0-9]+\.\s+.+' if version >= '1.5.0' else r'[0-9]+\.\s+(\w+|\.)+\s+\w+\s+(\w|\.)+'
|
||||||
|
|
||||||
reg = r'[0-9]+\.\s+(\w+|\.)+\s+(\w|\.)+' if version >= '1.5.0' else r'[0-9]+\.\s+(\w+|\.)+\s+\w+\s+(\w|\.)+'
|
res = {'partial': set(), 'full': set()}
|
||||||
|
|
||||||
for o in new_subprocess(['grep', '-E', reg, '-o', '--color=never'], stdin=updates).stdout:
|
for o in new_subprocess(['grep', '-E', reg, '-o', '--color=never'], stdin=updates).stdout:
|
||||||
if o:
|
if o:
|
||||||
out.write('/'.join(o.decode().strip().split('\t')[2:]) + '\n')
|
line_split = o.decode().strip().split('\t')
|
||||||
|
update_id = line_split[2] + '/' + line_split[3]
|
||||||
|
|
||||||
out.seek(0)
|
if len(line_split) == 7:
|
||||||
return out.read()
|
if line_split[4] != 'i':
|
||||||
|
if '(partial)' in line_split[6]:
|
||||||
|
res['partial'].add(update_id)
|
||||||
|
else:
|
||||||
|
res['full'].add(update_id)
|
||||||
|
else:
|
||||||
|
res['full'].add(update_id)
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
def downgrade(app_ref: str, commit: str, root_password: str) -> subprocess.Popen:
|
def downgrade(app_ref: str, commit: str, root_password: str) -> subprocess.Popen:
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import copy
|
||||||
|
from typing import Set
|
||||||
|
|
||||||
from bauh.api.abstract.model import SoftwarePackage
|
from bauh.api.abstract.model import SoftwarePackage
|
||||||
|
|
||||||
from bauh.commons import resource
|
from bauh.commons import resource
|
||||||
@@ -16,6 +19,7 @@ class FlatpakApplication(SoftwarePackage):
|
|||||||
self.origin = origin
|
self.origin = origin
|
||||||
self.runtime = runtime
|
self.runtime = runtime
|
||||||
self.commit = commit
|
self.commit = commit
|
||||||
|
self.partial = False
|
||||||
|
|
||||||
if runtime:
|
if runtime:
|
||||||
self.categories = ['runtime']
|
self.categories = ['runtime']
|
||||||
@@ -24,13 +28,13 @@ class FlatpakApplication(SoftwarePackage):
|
|||||||
return self.description is None and self.icon_url
|
return self.description is None and self.icon_url
|
||||||
|
|
||||||
def has_history(self):
|
def has_history(self):
|
||||||
return self.installed and self.ref
|
return not self.partial and self.installed and self.ref
|
||||||
|
|
||||||
def has_info(self):
|
def has_info(self):
|
||||||
return bool(self.id)
|
return bool(self.id)
|
||||||
|
|
||||||
def can_be_downgraded(self):
|
def can_be_downgraded(self):
|
||||||
return self.installed and self.ref
|
return not self.partial and self.installed and self.ref
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
return 'flatpak'
|
return 'flatpak'
|
||||||
@@ -63,7 +67,21 @@ class FlatpakApplication(SoftwarePackage):
|
|||||||
setattr(self, attr, data[attr])
|
setattr(self, attr, data[attr])
|
||||||
|
|
||||||
def can_be_run(self) -> bool:
|
def can_be_run(self) -> bool:
|
||||||
return self.installed and not self.runtime
|
return self.installed and not self.runtime and not self.partial
|
||||||
|
|
||||||
def get_publisher(self):
|
def get_publisher(self):
|
||||||
return self.origin
|
return self.origin
|
||||||
|
|
||||||
|
def can_be_uninstalled(self):
|
||||||
|
return self.installed and not self.partial
|
||||||
|
|
||||||
|
def gen_partial(self, partial_id: str) -> "FlatpakApplication":
|
||||||
|
partial = copy.deepcopy(self)
|
||||||
|
partial.id = partial_id
|
||||||
|
|
||||||
|
if self.ref:
|
||||||
|
ref_split = self.ref.split('/')
|
||||||
|
partial.ref = '/'.join((ref_split[0], partial_id, *ref_split[2:]))
|
||||||
|
|
||||||
|
partial.partial = True
|
||||||
|
return partial
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ from pathlib import Path
|
|||||||
from typing import List, Type, Set
|
from typing import List, Type, Set
|
||||||
|
|
||||||
from PyQt5.QtCore import QEvent, Qt, QSize, pyqtSignal
|
from PyQt5.QtCore import QEvent, Qt, QSize, pyqtSignal
|
||||||
from PyQt5.QtGui import QIcon, QWindowStateChangeEvent, QPixmap, QCursor
|
from PyQt5.QtGui import QIcon, QWindowStateChangeEvent, QCursor
|
||||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QCheckBox, QHeaderView, QToolBar, \
|
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QCheckBox, QHeaderView, QToolBar, \
|
||||||
QLabel, QPlainTextEdit, QLineEdit, QProgressBar, QPushButton, QComboBox, QMenu, QAction, QApplication, QListView
|
QLabel, QPlainTextEdit, QLineEdit, QProgressBar, QPushButton, QComboBox, QMenu, QAction, QApplication, QListView, \
|
||||||
|
QSizePolicy
|
||||||
|
|
||||||
from bauh.api.abstract.cache import MemoryCache
|
from bauh.api.abstract.cache import MemoryCache
|
||||||
from bauh.api.abstract.context import ApplicationContext
|
from bauh.api.abstract.context import ApplicationContext
|
||||||
@@ -33,7 +34,7 @@ from bauh.view.qt.thread import UpdateSelectedApps, RefreshApps, UninstallApp, D
|
|||||||
GetAppHistory, SearchPackages, InstallPackage, AnimateProgress, VerifyModels, FindSuggestions, ListWarnings, \
|
GetAppHistory, SearchPackages, InstallPackage, AnimateProgress, VerifyModels, FindSuggestions, ListWarnings, \
|
||||||
AsyncAction, LaunchApp, ApplyFilters, CustomAction, GetScreenshots
|
AsyncAction, LaunchApp, ApplyFilters, CustomAction, GetScreenshots
|
||||||
from bauh.view.qt.view_model import PackageView
|
from bauh.view.qt.view_model import PackageView
|
||||||
from bauh.view.qt.view_utils import load_icon, load_resource_icon
|
from bauh.view.qt.view_utils import load_icon
|
||||||
from bauh.view.util import util, resource
|
from bauh.view.util import util, resource
|
||||||
from bauh.view.util.translation import I18n
|
from bauh.view.util.translation import I18n
|
||||||
|
|
||||||
@@ -829,19 +830,20 @@ class ManageWindow(QWidget):
|
|||||||
self.ref_combo_categories.setVisible(False)
|
self.ref_combo_categories.setVisible(False)
|
||||||
|
|
||||||
def resize_and_center(self, accept_lower_width: bool = True):
|
def resize_and_center(self, accept_lower_width: bool = True):
|
||||||
if self.pkgs:
|
self.setMinimumWidth(self.layout.sizeHint().width())
|
||||||
new_width = reduce(operator.add, [self.table_apps.columnWidth(i) for i in range(self.table_apps.columnCount())])
|
# if self.pkgs:
|
||||||
|
# new_width = reduce(operator.add, [self.table_apps.columnWidth(i) for i in range(self.table_apps.columnCount())])
|
||||||
if self.ref_bt_upgrade.isVisible() or self.ref_bt_settings.isVisible():
|
#
|
||||||
new_width *= 1.07
|
# if self.ref_bt_upgrade.isVisible() or self.ref_bt_settings.isVisible():
|
||||||
else:
|
# new_width *= 1.07
|
||||||
new_width = self.toolbar_top.width()
|
# else:
|
||||||
|
# new_width = self.toolbar_top.width()
|
||||||
if accept_lower_width or new_width > self.width():
|
#
|
||||||
self.resize(new_width, self.height())
|
# if accept_lower_width or new_width > self.width():
|
||||||
|
# self.resize(new_width, self.height())
|
||||||
if self.ref_bt_upgrade.isVisible() and self.bt_upgrade.visibleRegion().isEmpty():
|
#
|
||||||
self.adjustSize()
|
# if self.ref_bt_upgrade.isVisible() and self.bt_upgrade.visibleRegion().isEmpty():
|
||||||
|
# self.adjustSize()
|
||||||
|
|
||||||
if self.first_refresh:
|
if self.first_refresh:
|
||||||
qt_utils.centralize(self)
|
qt_utils.centralize(self)
|
||||||
|
|||||||
Reference in New Issue
Block a user