[elbe-devel] [PATCH 4/4] updated: Depend on pyudev and packaging

Torben Hohn torben.hohn at linutronix.de
Wed Oct 28 15:18:53 CET 2020


On Fri, Oct 02, 2020 at 07:46:20PM +0200, bage at linutronix.de wrote:
> From: Bastian Germann <bage at linutronix.de>
> 
> Make the two optional packages mandatory dependences.
> This gets rid of the last ImportError catches in Elbe.


mmm... i am not sure on this one.
maybe kurt can comment ?

> 
> Signed-off-by: Bastian Germann <bage at linutronix.de>
> ---
>  debian/control               |  5 +++--
>  elbepack/updated.py          | 20 +++++++-------------
>  elbepack/updated_monitors.py |  7 +------
>  3 files changed, 11 insertions(+), 21 deletions(-)
> 
> diff --git a/debian/control b/debian/control
> index 228c466f3..949f161ff 100644
> --- a/debian/control
> +++ b/debian/control
> @@ -191,11 +191,12 @@ Depends: ${misc:Depends},
>    python3-lxml (>= 2.3.2-1),
>    python3-pyinotify,
>    python3-apt,
> +  python3-packaging,
> +  python3-pyudev,
>    python3-suds,
>    python3-spyne,
>    lsb-base (>= 3.0-6)
> -Suggests: python3-pyudev,
> -  usbmount
> +Suggests: usbmount
>  Description: update daemon for embedded systems
>   This package is typically installed on a embedded system. The update daemon
>   monitors a directory or USB mounts. If an ELBE update file (generated by
> diff --git a/elbepack/updated.py b/elbepack/updated.py
> index 4c73bbad3..f9117153e 100644
> --- a/elbepack/updated.py
> +++ b/elbepack/updated.py
> @@ -18,6 +18,7 @@ from multiprocessing import Process
>  from zipfile import (ZipFile, BadZipfile)
>  from shutil import copyfile, rmtree, copy
>  
> +from packaging import version
>  from syslog import syslog
>  
>  from suds.client import Client
> @@ -36,12 +37,6 @@ from elbepack.egpg import unsign_file
>  from elbepack.treeutils import etree
>  from elbepack.shellhelper import CommandError, system
>  
> -downgrade_prevention_feature_available = True
> -try:
> -    from packaging import version
> -except ImportError:
> -    downgrade_prevention_feature_available = False
> -
>  # TODO:py3 Remove object inheritance
>  # pylint: disable=useless-object-inheritance
>  class UpdateStatus(object):
> @@ -477,14 +472,13 @@ def action_select(upd_file, status):
>          upd_file_z.extract("new.xml", "/tmp/")
>  
>      # prevent downgrades (if available)
> -    if downgrade_prevention_feature_available:
> -        try:
> -            if reject_downgrade(status, "/tmp/new.xml"):
> -                return
> -        # pylint: disable=broad-except
> -        except Exception as e:
> -            status.log('Error while reading XML files occurred: ' + str(e))
> +    try:
> +        if reject_downgrade(status, "/tmp/new.xml"):
>              return
> +    # pylint: disable=broad-except
> +    except Exception as e:
> +        status.log('Error while reading XML files occurred: ' + str(e))
> +        return
>  
>      xml = etree("/tmp/new.xml")
>      prefix = status.repo_dir + "/" + fname_replace(xml.text("/project/name"))
> diff --git a/elbepack/updated_monitors.py b/elbepack/updated_monitors.py
> index 16b4994f2..8424aaa4a 100644
> --- a/elbepack/updated_monitors.py
> +++ b/elbepack/updated_monitors.py
> @@ -7,12 +7,7 @@
>  import os
>  import threading
>  import pyinotify
> -
> -try:
> -    import pyudev
> -    udev_available = True
> -except ImportError:
> -    udev_available = False
> +import pyudev
>  
>  from elbepack.updated import is_update_file, handle_update_file
>  
> -- 
> 2.28.0
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner


More information about the elbe-devel mailing list