This commit is contained in:
Vinícius Moreira
2020-04-13 11:49:28 -03:00
parent 83aab1ff55
commit 01a60ea686
165 changed files with 12778 additions and 6171 deletions

View File

@@ -1,9 +1,18 @@
from bauh.api.abstract.model import SoftwarePackage
from typing import List
from bauh.api.abstract.model import SoftwarePackage, CustomSoftwareAction
from bauh.commons import resource
from bauh.gems.appimage import ROOT_DIR, INSTALLATION_PATH
from bauh.view.util.translation import I18n
CACHED_ATTRS = {'name', 'description', 'version', 'url_download', 'author', 'license', 'source',
'icon_path', 'github', 'categories'}
'icon_path', 'github', 'categories', 'imported', 'install_dir'}
CUSTOM_ACTIONS = [CustomSoftwareAction(i18_label_key='appimage.custom_action.manual_update',
i18n_status_key='appimage.custom_action.manual_update.status',
manager_method='update_file',
requires_root=False,
icon_path=resource.get_path('img/refresh.svg', ROOT_DIR))]
class AppImage(SoftwarePackage):
@@ -11,7 +20,8 @@ class AppImage(SoftwarePackage):
def __init__(self, name: str = None, description: str = None, github: str = None, source: str = None, version: str = None,
url_download: str = None, url_icon: str = None, url_screenshot: str = None, license: str = None, author: str = None,
categories=None, icon_path: str = None, installed: bool = False,
url_download_latest_version: str = None, **kwargs):
url_download_latest_version: str = None, local_file_path: str = None, imported: bool = False,
i18n: I18n = None, install_dir: str = None, **kwargs):
super(AppImage, self).__init__(id=name, name=name, version=version, latest_version=version,
icon_url=url_icon, license=license, description=description,
installed=installed)
@@ -23,6 +33,10 @@ class AppImage(SoftwarePackage):
self.url_screenshot = url_screenshot
self.author = author
self.url_download_latest_version = url_download_latest_version
self.local_file_path = local_file_path
self.imported = imported
self.i18n = i18n
self.install_dir = install_dir
def __repr__(self):
return "{} (name={}, github={})".format(self.__class__.__name__, self.name, self.github)
@@ -31,13 +45,13 @@ class AppImage(SoftwarePackage):
return not self.installed and self.url_download
def has_history(self):
return self.installed
return self.installed and not self.imported
def has_info(self):
return True
def can_be_downgraded(self):
return self.installed
return self.installed and not self.imported
def get_type(self):
return 'AppImage'
@@ -75,7 +89,9 @@ class AppImage(SoftwarePackage):
return self.author
def get_disk_cache_path(self) -> str:
if self.name:
if self.install_dir:
return self.install_dir
elif self.name:
return INSTALLATION_PATH + self.name.lower()
def get_disk_icon_path(self):
@@ -83,3 +99,16 @@ class AppImage(SoftwarePackage):
def has_screenshots(self):
return not self.installed and self.url_screenshot
def get_display_name(self) -> str:
if self.name and self.imported:
return '{} ( {} )'.format(self.name, self.i18n['imported'])
return self.name
def get_custom_supported_actions(self) -> List[CustomSoftwareAction]:
if self.imported:
return CUSTOM_ACTIONS
def supports_backup(self) -> bool:
return False