From 5ddd374350b14b7ee990457a104ece9e7534350f Mon Sep 17 00:00:00 2001 From: Fuxino Date: Fri, 2 Jun 2023 17:01:37 +0200 Subject: [PATCH] Fix notification bug Correctly handle exception when trying to display notification if dbus-python is not available --- README.md | 14 ++++++++------ setup.cfg | 7 ++++++- simple_backup.install | 8 -------- simple_backup/simple_backup.py | 5 ++++- 4 files changed, 18 insertions(+), 16 deletions(-) delete mode 100644 simple_backup.install diff --git a/README.md b/README.md index c872282..2cca2d8 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,10 @@ The script uses rsync to actually run the backup, so you will have to install it sudo pacman -Syu rsync ``` +It's also required to have python-dotenv + +Optional dependencies are systemd-python to enable using systemd journal for logging, and dbus-python for desktop notifications. + ## Install To install the program, first clone the repository: @@ -27,23 +31,21 @@ To install the program, first clone the repository: git clone https://github.com/Fuxino/simple_backup.git ``` -Install tools required to build and install the package: +Then install the tools required to build the package: ```bash -pip install --upgrade build installer wheel +pip install --upgrade build wheel ``` -Then run: +Finally, run: ```bash cd simple_backup python -m build --wheel -python -m installer dist/*.whl +python -m pip install dist/*.whl ``` For Arch Linux and Arch-based distros, two packages are available in the AUR (aur.archlinux.org): - **simple_backup** for the release version - **simple_backup-git** for the git version -After installing, copy simple_backup.conf (if you used the PKGBUILD on Arch, it will be in /etc/simple_backup/) to $HOME/.config/simple_backup and edit is as needed. - diff --git a/setup.cfg b/setup.cfg index 1cfd233..7bad00b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,12 @@ packages = simple_backup python_requires = >=3.7 install_requires = python-dotenv - systemd-python + +[options.extras_require] +JOURNAL = + systemd-python +NOTIFICATIONS = + dbus-python [options.entry_points] console_scripts = diff --git a/simple_backup.install b/simple_backup.install deleted file mode 100644 index cfc5d1a..0000000 --- a/simple_backup.install +++ /dev/null @@ -1,8 +0,0 @@ -post_install() { - echo "An example configuration file is found in /etc/simple_backup/simple_backup.conf." - echo "Copy it to ~/config/simple_backup/simple_backup.conf and modify it as needed" -} - -post_upgrade() { - post_install -} diff --git a/simple_backup/simple_backup.py b/simple_backup/simple_backup.py index efcc66c..399d1eb 100755 --- a/simple_backup/simple_backup.py +++ b/simple_backup/simple_backup.py @@ -250,7 +250,10 @@ class Backup: except NameError: pass else: - notify('Backup finished') + try: + notify('Backup finished') + except NameError: + pass def _parse_arguments():