[elbe-devel] [PATCH 1/1] cdrom: ignore deprecation warning

Manuel Traut manut at linutronix.de
Fri Apr 5 06:52:18 CEST 2019


python-apt from debian/stretch produces another deprecation warning.
ignore it, to be able to build cdroms again:

--8<--
Build failed
Traceback (most recent call last):
  File "/var/cache/elbe/devel/elbepack/asyncworker.py", line 158, in execute
    skip_pbuild=self.skip_pbuilder)
  File "/var/cache/elbe/devel/elbepack/elbeproject.py", line 582, in build
    self.build_cdroms(build_bin, build_sources, cdrom_size)
  File "/var/cache/elbe/devel/elbepack/elbeproject.py", line 405, in build_cdroms
    cdrom_size=cdrom_size)
  File "/var/cache/elbe/devel/elbepack/cdroms.py", line 159, in mk_binary_cdrom
    pkg.installed_version)
  File "<string>", line 2, in download_binary
  File "/usr/lib/python2.7/multiprocessing/managers.py", line 774, in _callmethod
    raise convert_to_error(kind, result)
DeprecationWarning: MD5Hash is deprecated, use Hashes instead

Exception:
MD5Hash is deprecated, use Hashes instead
--8<--

Signed-off-by: Manuel Traut <manut at linutronix.de>
---
 elbepack/rpcaptcache.py | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
index c5487aaf..d621a5e9 100644
--- a/elbepack/rpcaptcache.py
+++ b/elbepack/rpcaptcache.py
@@ -247,10 +247,15 @@ class RPCAPTCache(InChRootObject):
             pkgver = p.installed
         else:
             pkgver = p.versions[version]
-
-        rel_filename = pkgver.fetch_binary(path,
-                                           ElbeAcquireProgress())
-        return self.rfs.fname(rel_filename)
+        # avoid DeprecationWarning:
+        # "MD5Hash is deprecated, use Hashes instead"
+        # triggerd by python-apt
+        with warnings.catch_warnings():
+            warnings.filterwarnings("ignore",
+                                    category=DeprecationWarning)
+            rel_filename = pkgver.fetch_binary(path,
+                                               ElbeAcquireProgress())
+            return self.rfs.fname(rel_filename)
 
     def download_source(self, pkgname, path, version=None):
         p = self.cache[pkgname]
@@ -259,9 +264,16 @@ class RPCAPTCache(InChRootObject):
         else:
             pkgver = p.versions[version]
 
-        rel_filename = pkgver.fetch_source(path,
-                                           ElbeAcquireProgress(), unpack=False)
-        return self.rfs.fname(rel_filename)
+        # avoid DeprecationWarning:
+        # "MD5Hash is deprecated, use Hashes instead"
+        # triggerd by python-apt
+        with warnings.catch_warnings():
+            warnings.filterwarnings("ignore",
+                                    category=DeprecationWarning)
+            rel_filename = pkgver.fetch_source(path,
+                                               ElbeAcquireProgress(),
+                                               unpack=False)
+            return self.rfs.fname(rel_filename)
 
 
 class MyMan(BaseManager):
-- 
2.20.1




More information about the elbe-devel mailing list