[elbe-devel] [PATCH v2 5/6] Remove filtering a deprecation warning

bage at linutronix.de bage at linutronix.de
Mon Sep 2 12:46:52 CEST 2019


From: Bastian Germann <bage at linutronix.de>

The newer function is now used, so the filtering of the deprecation warning
is not in use anymore.

Signed-off-by: Bastian Germann <bage at linutronix.de>
Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/dump.py        |  9 +++------
 elbepack/rpcaptcache.py | 43 +++++++++++++----------------------------
 2 files changed, 16 insertions(+), 36 deletions(-)

diff --git a/elbepack/dump.py b/elbepack/dump.py
index c5d59174..4642ae92 100644
--- a/elbepack/dump.py
+++ b/elbepack/dump.py
@@ -5,7 +5,6 @@
 #
 # SPDX-License-Identifier: GPL-3.0-or-later
 
-import warnings
 import logging
 
 from datetime import datetime
@@ -22,11 +21,9 @@ report = logging.getLogger("report")
 validation = logging.getLogger("validation")
 
 def get_initvm_pkglist():
-    with warnings.catch_warnings():
-        warnings.filterwarnings("ignore", category=DeprecationWarning)
-        cache = Cache()
-        cache.open()
-        pkglist = [APTPackage(p) for p in cache if p.is_installed]
+    cache = Cache()
+    cache.open()
+    pkglist = [APTPackage(p) for p in cache if p.is_installed]
 
     return pkglist
 
diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
index 629286bd..afb29ed6 100644
--- a/elbepack/rpcaptcache.py
+++ b/elbepack/rpcaptcache.py
@@ -12,7 +12,6 @@ import logging
 import os
 import sys
 import time
-import warnings
 
 from multiprocessing.util import Finalize
 from multiprocessing.managers import BaseManager
@@ -217,16 +216,12 @@ class RPCAPTCache(InChRootObject):
         return [APTPackage(p, cache=self.cache) for p in deps]
 
     def get_installed_pkgs(self, section='all'):
-        # avoid DeprecationWarning: MD5Hash is deprecated, use Hashes instead
-        # triggerd by python-apt
-        with warnings.catch_warnings():
-            warnings.filterwarnings("ignore", category=DeprecationWarning)
-            if section == 'all':
-                pl = [APTPackage(p) for p in self.cache if p.is_installed]
-            else:
-                pl = [APTPackage(p) for p in self.cache if (
-                    p.section == section and p.is_installed)]
-            return pl
+        if section == 'all':
+            pl = [APTPackage(p) for p in self.cache if p.is_installed]
+        else:
+            pl = [APTPackage(p) for p in self.cache if (
+                p.section == section and p.is_installed)]
+        return pl
 
     def get_fileindex(self):
         index = {}
@@ -287,15 +282,9 @@ class RPCAPTCache(InChRootObject):
             pkgver = p.installed
         else:
             pkgver = p.versions[version]
-        # 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)
+        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]
@@ -304,16 +293,10 @@ class RPCAPTCache(InChRootObject):
         else:
             pkgver = p.versions[version]
 
-        # 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)
+        rel_filename = pkgver.fetch_source(path,
+                                           ElbeAcquireProgress(),
+                                           unpack=False)
+        return self.rfs.fname(rel_filename)
 
 def get_rpcaptcache(rfs, arch,
                     notifier=None, norecommend=False, noauth=True):
-- 
2.20.1




More information about the elbe-devel mailing list