mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 20:54:15 +02:00
[appimage] -> improvement: manual file upgrade -> auto-filling version and settings default search path to '~/Downloads'
This commit is contained in:
@@ -7,7 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
## [0.9.7] 2020
|
## [0.9.7] 2020
|
||||||
### Improvements
|
### Improvements
|
||||||
- AppImage
|
- AppImage
|
||||||
- Manual file installation:
|
- Manual file installation/upgrade:
|
||||||
- default search path set to '~/Downloads'
|
- default search path set to '~/Downloads'
|
||||||
- trying to auto-fill the 'Name' and 'Version' fields
|
- trying to auto-fill the 'Name' and 'Version' fields
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from bauh.api.constants import CONFIG_PATH
|
from bauh.api.constants import CONFIG_PATH
|
||||||
from bauh.commons import resource
|
from bauh.commons import resource
|
||||||
@@ -16,3 +17,8 @@ SYMLINKS_DIR = '{}/.local/bin'.format(str(Path.home()))
|
|||||||
|
|
||||||
def get_icon_path() -> str:
|
def get_icon_path() -> str:
|
||||||
return resource.get_path('img/appimage.svg', ROOT_DIR)
|
return resource.get_path('img/appimage.svg', ROOT_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_manual_installation_file_dir() -> Optional[str]:
|
||||||
|
default_path = '{}/Downloads'.format(str(Path.home()))
|
||||||
|
return default_path if os.path.isdir(default_path) else None
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from distutils.version import LooseVersion
|
|||||||
from math import floor
|
from math import floor
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from typing import Set, Type, List, Tuple
|
from typing import Set, Type, List, Tuple, Optional
|
||||||
|
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ from bauh.commons.config import save_config
|
|||||||
from bauh.commons.html import bold
|
from bauh.commons.html import bold
|
||||||
from bauh.commons.system import SystemProcess, new_subprocess, ProcessHandler, run_cmd, SimpleProcess
|
from bauh.commons.system import SystemProcess, new_subprocess, ProcessHandler, run_cmd, SimpleProcess
|
||||||
from bauh.gems.appimage import query, INSTALLATION_PATH, LOCAL_PATH, SUGGESTIONS_FILE, CONFIG_FILE, ROOT_DIR, \
|
from bauh.gems.appimage import query, INSTALLATION_PATH, LOCAL_PATH, SUGGESTIONS_FILE, CONFIG_FILE, ROOT_DIR, \
|
||||||
CONFIG_DIR, UPDATES_IGNORED_FILE, util
|
CONFIG_DIR, UPDATES_IGNORED_FILE, util, get_default_manual_installation_file_dir
|
||||||
from bauh.gems.appimage.config import read_config
|
from bauh.gems.appimage.config import read_config
|
||||||
from bauh.gems.appimage.model import AppImage
|
from bauh.gems.appimage.model import AppImage
|
||||||
from bauh.gems.appimage.worker import DatabaseUpdater, SymlinksVerifier
|
from bauh.gems.appimage.worker import DatabaseUpdater, SymlinksVerifier
|
||||||
@@ -47,7 +47,7 @@ RE_APPIMAGE_NAME = re.compile(r'(.+)\.appimage', flags=re.IGNORECASE)
|
|||||||
|
|
||||||
class ManualInstallationFileObserver(ViewObserver):
|
class ManualInstallationFileObserver(ViewObserver):
|
||||||
|
|
||||||
def __init__(self, name: TextInputComponent, version: TextInputComponent):
|
def __init__(self, name: Optional[TextInputComponent], version: TextInputComponent):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.version = version
|
self.version = version
|
||||||
|
|
||||||
@@ -57,12 +57,16 @@ class ManualInstallationFileObserver(ViewObserver):
|
|||||||
|
|
||||||
if name_found:
|
if name_found:
|
||||||
name_split = name_found[0].split('-')
|
name_split = name_found[0].split('-')
|
||||||
self.name.set_value(name_split[0].strip())
|
|
||||||
|
if self.name:
|
||||||
|
self.name.set_value(name_split[0].strip())
|
||||||
|
|
||||||
if len(name_split) > 1:
|
if len(name_split) > 1:
|
||||||
self.version.set_value(name_split[1].strip())
|
self.version.set_value(name_split[1].strip())
|
||||||
else:
|
else:
|
||||||
self.name.set_value(None)
|
if self.name:
|
||||||
|
self.name.set_value(None)
|
||||||
|
|
||||||
self.version.set_value(None)
|
self.version.set_value(None)
|
||||||
|
|
||||||
|
|
||||||
@@ -91,14 +95,9 @@ class AppImageManager(SoftwareManager):
|
|||||||
icon_path=resource.get_path('img/upgrade.svg', ROOT_DIR))]
|
icon_path=resource.get_path('img/upgrade.svg', ROOT_DIR))]
|
||||||
|
|
||||||
def install_file(self, root_password: str, watcher: ProcessWatcher) -> bool:
|
def install_file(self, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||||
default_path = '{}/Downloads'.format(str(Path.home()))
|
|
||||||
|
|
||||||
if not os.path.isdir(default_path):
|
|
||||||
default_path = None
|
|
||||||
|
|
||||||
file_chooser = FileChooserComponent(label=self.i18n['file'].capitalize(),
|
file_chooser = FileChooserComponent(label=self.i18n['file'].capitalize(),
|
||||||
allowed_extensions={'AppImage'},
|
allowed_extensions={'AppImage'},
|
||||||
search_path=default_path)
|
search_path=get_default_manual_installation_file_dir())
|
||||||
input_name = TextInputComponent(label=self.i18n['name'].capitalize())
|
input_name = TextInputComponent(label=self.i18n['name'].capitalize())
|
||||||
input_version = TextInputComponent(label=self.i18n['version'].capitalize())
|
input_version = TextInputComponent(label=self.i18n['version'].capitalize())
|
||||||
file_chooser.observers.append(ManualInstallationFileObserver(input_name, input_version))
|
file_chooser.observers.append(ManualInstallationFileObserver(input_name, input_version))
|
||||||
@@ -150,8 +149,11 @@ class AppImageManager(SoftwareManager):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def update_file(self, pkg: AppImage, root_password: str, watcher: ProcessWatcher):
|
def update_file(self, pkg: AppImage, root_password: str, watcher: ProcessWatcher):
|
||||||
file_chooser = FileChooserComponent(label=self.i18n['file'].capitalize(), allowed_extensions={'AppImage'})
|
file_chooser = FileChooserComponent(label=self.i18n['file'].capitalize(),
|
||||||
|
allowed_extensions={'AppImage'},
|
||||||
|
search_path=get_default_manual_installation_file_dir())
|
||||||
input_version = TextInputComponent(label=self.i18n['version'].capitalize())
|
input_version = TextInputComponent(label=self.i18n['version'].capitalize())
|
||||||
|
file_chooser.observers.append(ManualInstallationFileObserver(None, input_version))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if watcher.request_confirmation(title=self.i18n['appimage.custom_action.manual_update.details'], body=None,
|
if watcher.request_confirmation(title=self.i18n['appimage.custom_action.manual_update.details'], body=None,
|
||||||
|
|||||||
Reference in New Issue
Block a user