mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[feature] new parameter --clean to remove configuration and cache files
This commit is contained in:
@@ -19,7 +19,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- i18n:
|
||||
- Catalan contributions by [fitojb](https://github.com/fitojb)
|
||||
- German contributions by [JonasLoos](https://github.com/JonasLoos)
|
||||
- Italian contributions by [albanobattistella](https://github.com/albanobattistella)
|
||||
- Italian contributions by [albanobattistella](https://github.com/albanobattistella)
|
||||
|
||||
### Features
|
||||
- New command line argument to clean the configuration and cache files: `--clean`
|
||||
|
||||
### Fixes
|
||||
- Flatpak
|
||||
|
||||
@@ -87,6 +87,9 @@ Icon=/home/$USER/bauh_env/lib/python3.7/site-packages/bauh/view/resources/img/lo
|
||||
### Autostart
|
||||
In order to autostart the application, use your Desktop Environment settings to register it as a startup application / script (**bauh --tray=1**).
|
||||
|
||||
### Uninstallation
|
||||
Before uninstalling bauh via your package manager, consider executing `bauh --clean` to remove configuration and cache files stored in your **HOME** folder.
|
||||
|
||||
### Gems ( package technology support )
|
||||
#### Flatpak ( flatpak )
|
||||
- The user is able to search, install, uninstall, downgrade, launch and retrieve the applications history
|
||||
|
||||
@@ -2,3 +2,4 @@ from pathlib import Path
|
||||
|
||||
HOME_PATH = Path.home()
|
||||
CACHE_PATH = '{}/.cache/bauh'.format(HOME_PATH)
|
||||
CONFIG_PATH = '{}/.config/bauh'.format(HOME_PATH)
|
||||
|
||||
@@ -25,9 +25,14 @@ def main():
|
||||
os.environ['PYTHONUNBUFFERED'] = '1'
|
||||
|
||||
args = app_args.read()
|
||||
|
||||
logger = logs.new_logger(__app_name__, bool(args.logs))
|
||||
app_args.validate(args, logger)
|
||||
|
||||
if args.clean:
|
||||
util.clean_app_files()
|
||||
exit(0)
|
||||
|
||||
i18n_key, current_i18n = translation.get_locale_keys(args.locale)
|
||||
default_i18n = translation.get_locale_keys(DEFAULT_I18N_KEY)[1] if i18n_key != DEFAULT_I18N_KEY else {}
|
||||
i18n = I18n(current_i18n, default_i18n)
|
||||
|
||||
@@ -36,6 +36,7 @@ def read() -> Namespace:
|
||||
parser.add_argument('--logs', action="store", default=int(os.getenv('BAUH_LOGS', 0)), choices=[0, 1], type=int, help='If the application logs should be displayed. Default: %(default)s')
|
||||
parser.add_argument('--show-panel', action="store_true", help='Shows the management panel after the app icon is attached to the tray.')
|
||||
parser.add_argument('-dmt', '--download-mthread', action="store", default=os.getenv('BAUH_DOWNLOAD_MULTITHREAD', 1), choices=[0, 1], type=int, help='If installation files should be downloaded using multi-threads (only possible if aria2c is installed). Not all gems support this feature. Check README.md. Default: %(default)s')
|
||||
parser.add_argument('--clean', action="store_true", help='Removes all configuration and cache files')
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
from bauh import __app_name__
|
||||
from bauh.api.constants import CACHE_PATH, CONFIG_PATH
|
||||
from bauh.commons.system import run_cmd
|
||||
from bauh.view.util import resource
|
||||
|
||||
@@ -36,3 +38,12 @@ def get_distro():
|
||||
return 'ubuntu'
|
||||
|
||||
return 'unknown'
|
||||
|
||||
|
||||
def clean_app_files():
|
||||
print('[bauh] Cleaning configuration and cache files')
|
||||
for path in (CACHE_PATH, CONFIG_PATH):
|
||||
print('[bauh] Deleting directory {}'.format(path))
|
||||
if os.path.exists(path):
|
||||
shutil.rmtree(path)
|
||||
print('[bauh] Cleaning finished')
|
||||
|
||||
Reference in New Issue
Block a user