[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