[flatpak] updating partials

This commit is contained in:
Vinícius Moreira
2020-01-10 16:11:45 -03:00
parent 969c647edf
commit 9d326efcd4
8 changed files with 56 additions and 51 deletions

View File

@@ -101,17 +101,18 @@ class FlatpakManager(SoftwareManager):
models = []
if installed:
update_map = None
if thread_updates:
thread_updates.join()
update_map = updates[0]
update_map = updates[0]
for app_json in installed:
model = self._map_to_model(app_json=app_json, installed=True,
disk_loader=disk_loader, internet=internet_available)
model.update = None
models.append(model)
if update_map['full'] or update_map['partial']:
if update_map and (update_map['full'] or update_map['partial']):
if version >= '1.5.0':
update_id = '{}/{}'.format(app_json['id'], app_json['branch'])
@@ -218,7 +219,7 @@ class FlatpakManager(SoftwareManager):
return PackageHistory(pkg=pkg, history=commits, pkg_status_idx=status_idx)
def install(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool:
res = ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.install(pkg.id, pkg.origin), wrong_error_phrase='Warning'))
res = ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.install(pkg.id, pkg.origin, pkg.installation), wrong_error_phrase='Warning'))
if res:
try:

View File

@@ -1,5 +1,6 @@
import re
import subprocess
import traceback
from datetime import datetime
from io import StringIO
from typing import List, Dict
@@ -168,19 +169,23 @@ def list_updates_as_str(version: str) -> Dict[str, set]:
res = {'partial': set(), 'full': set()}
for o in new_subprocess(['grep', '-E', reg, '-o', '--color=never'], stdin=updates).stdout:
if o:
line_split = o.decode().strip().split('\t')
update_id = line_split[2] + '/' + line_split[3]
try:
for o in new_subprocess(['grep', '-E', reg, '-o', '--color=never'], stdin=updates).stdout:
if o:
line_split = o.decode().strip().split('\t')
update_id = line_split[2] + '/' + line_split[3]
if len(line_split) == 7:
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)
except:
traceback.print_exc()
if len(line_split) == 7:
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
@@ -302,8 +307,8 @@ def search(version: str, word: str, app_id: bool = False) -> List[dict]:
return found
def install(app_id: str, origin: str):
return new_subprocess([BASE_CMD, 'install', origin, app_id, '-y'])
def install(app_id: str, origin: str, installation: str):
return new_subprocess([BASE_CMD, 'install', origin, app_id, '-y', '--{}'.format(installation)])
def set_default_remotes():

View File

@@ -1,8 +1,6 @@
import copy
from typing import Set
from bauh.api.abstract.model import SoftwarePackage
from bauh.commons import resource
from bauh.gems.flatpak import ROOT_DIR
@@ -20,14 +18,15 @@ class FlatpakApplication(SoftwarePackage):
self.runtime = runtime
self.commit = commit
self.partial = False
self.installation = 'system'
if runtime:
self.categories = ['runtime']
def is_incomplete(self):
def is_incomplete(self) -> bool:
return self.description is None and self.icon_url
def has_history(self):
def has_history(self) -> bool:
return not self.partial and self.installed and self.ref
def has_info(self):
@@ -72,7 +71,7 @@ class FlatpakApplication(SoftwarePackage):
def get_publisher(self):
return self.origin
def can_be_uninstalled(self):
def can_be_uninstalled(self) -> bool:
return self.installed and not self.partial
def gen_partial(self, partial_id: str) -> "FlatpakApplication":
@@ -80,8 +79,7 @@ class FlatpakApplication(SoftwarePackage):
partial.id = partial_id
if self.ref:
ref_split = self.ref.split('/')
partial.ref = '/'.join((ref_split[0], partial_id, *ref_split[2:]))
partial.ref = '/'.join((partial_id, *self.ref.split('/')[1:]))
partial.partial = True
return partial

View File

@@ -97,7 +97,7 @@ class WebApplication(SoftwarePackage):
self.set_custom_icon(self.custom_icon)
def can_be_run(self) -> bool:
return self.installed and self.installation_dir
return self.installed and bool(self.installation_dir)
def is_trustable(self) -> bool:
return False

View File

@@ -252,7 +252,7 @@ class AppsTable(QTableWidget):
col = QWidget()
col_bt = QPushButton()
col_bt.setText(text)
col_bt.setStyleSheet('QPushButton { ' + style + '}')
col_bt.setStyleSheet('QPushButton { ' + style + '} QPushButton:disabled { background: grey }')
col_bt.clicked.connect(callback)
layout = QHBoxLayout()
@@ -265,16 +265,11 @@ class AppsTable(QTableWidget):
def _set_col_installed(self, col: int, pkg: PackageView):
if pkg.model.installed:
if pkg.model.can_be_uninstalled():
def uninstall():
self._uninstall_app(pkg)
def uninstall():
self._uninstall_app(pkg)
item = self._gen_row_button(self.i18n['uninstall'].capitalize(), INSTALL_BT_STYLE.format(back='#cc0000'), uninstall)
else:
item = QLabel()
item.setPixmap((QPixmap(resource.get_path('img/checked.svg'))))
item.setAlignment(Qt.AlignCenter)
item.setToolTip(self.i18n['installed'])
item = self._gen_row_button(self.i18n['uninstall'].capitalize(), INSTALL_BT_STYLE.format(back='#cc0000'), uninstall)
item.setEnabled(pkg.model.can_be_uninstalled())
elif pkg.model.can_be_installed():
def install():
self._install_app(pkg)
@@ -423,31 +418,36 @@ class AppsTable(QTableWidget):
def _set_col_settings(self, col: int, pkg: PackageView):
item = QToolBar()
if pkg.model.can_be_run():
if pkg.model.installed:
def run():
self.window.run_app(pkg)
item.addWidget(IconButton(QIcon(resource.get_path('img/app_play.svg')), action=run, background='#088A08', tooltip=self.i18n['action.run.tooltip']))
bt = IconButton(QIcon(resource.get_path('img/app_play.svg')), action=run, background='#088A08', tooltip=self.i18n['action.run.tooltip'])
bt.setEnabled(pkg.model.can_be_run())
item.addWidget(bt)
if pkg.model.has_info():
def get_info():
self.window.get_app_info(pkg)
def get_info():
self.window.get_app_info(pkg)
bt = IconButton(QIcon(resource.get_path('img/app_info.svg')), action=get_info, background='#2E68D3', tooltip=self.i18n['action.info.tooltip'])
bt.setEnabled(bool(pkg.model.has_info()))
item.addWidget(bt)
item.addWidget(IconButton(QIcon(resource.get_path('img/app_info.svg')), action=get_info, background='#2E68D3', tooltip=self.i18n['action.info.tooltip']))
if pkg.model.has_screenshots():
if not pkg.model.installed:
def get_screenshots():
self.window.get_screenshots(pkg)
item.addWidget(IconButton(QIcon(resource.get_path('img/camera.svg')), action=get_screenshots, background='purple', tooltip=self.i18n['action.screenshots.tooltip']))
bt = IconButton(QIcon(resource.get_path('img/camera.svg')), action=get_screenshots, background='purple', tooltip=self.i18n['action.screenshots.tooltip'])
bt.setEnabled(bool(pkg.model.has_screenshots()))
item.addWidget(bt)
def handle_click():
self.show_pkg_settings(pkg)
if self.has_any_settings(pkg):
settings = self.has_any_settings(pkg)
if pkg.model.installed or settings:
bt = IconButton(QIcon(resource.get_path('img/app_settings.svg')), action=handle_click, background='#12ABAB', tooltip=self.i18n['action.settings.tooltip'])
bt.setEnabled(bool(settings))
item.addWidget(bt)
self.setCellWidget(pkg.table_index, col, item)

View File

@@ -248,7 +248,9 @@ class IconButton(QWidget):
self.bt.clicked.connect(action)
if background:
self.bt.setStyleSheet('QToolButton { color: white; background: ' + background + '}')
style = 'QToolButton { color: white; background: ' + background + '} '
style += 'QToolButton:disabled { color: white; background: grey }'
self.bt.setStyleSheet(style)
if tooltip:
self.bt.setToolTip(tooltip)

View File

@@ -53,7 +53,7 @@ class ScreenshotsDialog(QDialog):
self.bottom_bar = QToolBar()
self.bt_back = QPushButton(self.i18n['screenshots.bt_back.label'].capitalize())
self.bt_back = QPushButton(' < ' + self.i18n['screenshots.bt_back.label'].capitalize())
self.bt_back.clicked.connect(self.back)
self.ref_bt_back = self.bottom_bar.addWidget(self.bt_back)
self.bottom_bar.addWidget(new_spacer(50))
@@ -65,7 +65,7 @@ class ScreenshotsDialog(QDialog):
self.ref_progress_bar = self.bottom_bar.addWidget(self.progress_bar)
self.bottom_bar.addWidget(new_spacer(50))
self.bt_next = QPushButton(self.i18n['screenshots.bt_next.label'].capitalize())
self.bt_next = QPushButton(self.i18n['screenshots.bt_next.label'].capitalize() + ' > ')
self.bt_next.clicked.connect(self.next)
self.ref_bt_next = self.bottom_bar.addWidget(self.bt_next)

View File

@@ -840,8 +840,7 @@ class ManageWindow(QWidget):
if (self.pkgs and accept_lower_width) or new_width > self.width():
self.resize(new_width, self.height())
if self.first_refresh:
qt_utils.centralize(self)
qt_utils.centralize(self)
def update_selected(self):
if self.pkgs: