Make ResolverPlayground.run() use try/finally when saving/restoring
authorZac Medico <zmedico@gentoo.org>
Wed, 8 Sep 2010 21:00:55 +0000 (14:00 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 8 Sep 2010 21:00:55 +0000 (14:00 -0700)
global variable settings.

pym/portage/tests/resolver/ResolverPlayground.py

index 0b950059f82744565e6167b721e51ff98f5c496a..5c04afd9842e1153a37555ad20f93acf85bff46a 100644 (file)
@@ -315,25 +315,29 @@ class ResolverPlayground(object):
                if self.debug:
                        options["--debug"] = True
 
-               if not self.debug:
-                       portage.util.noiselimit = -2
-               _emerge.emergelog._disable = True
-
-               if options.get("--depclean"):
-                       rval, cleanlist, ordered, req_pkg_count = \
-                               calc_depclean(self.settings, self.trees, None,
-                               options, "depclean", atoms, None)
-                       result = ResolverPlaygroundDepcleanResult( \
-                               atoms, rval, cleanlist, ordered, req_pkg_count)
-               else:
-                       params = create_depgraph_params(options, action)
-                       success, depgraph, favorites = backtrack_depgraph(
-                               self.settings, self.trees, options, params, action, atoms, None)
-                       depgraph.display_problems()
-                       result = ResolverPlaygroundResult(atoms, success, depgraph, favorites)
+               global_noiselimit = portage.util.noiselimit
+               global_emergelog_disable = _emerge.emergelog._disable
+               try:
 
-               portage.util.noiselimit = 0
-               _emerge.emergelog._disable = False
+                       if not self.debug:
+                               portage.util.noiselimit = -2
+                       _emerge.emergelog._disable = True
+
+                       if options.get("--depclean"):
+                               rval, cleanlist, ordered, req_pkg_count = \
+                                       calc_depclean(self.settings, self.trees, None,
+                                       options, "depclean", atoms, None)
+                               result = ResolverPlaygroundDepcleanResult( \
+                                       atoms, rval, cleanlist, ordered, req_pkg_count)
+                       else:
+                               params = create_depgraph_params(options, action)
+                               success, depgraph, favorites = backtrack_depgraph(
+                                       self.settings, self.trees, options, params, action, atoms, None)
+                               depgraph.display_problems()
+                               result = ResolverPlaygroundResult(atoms, success, depgraph, favorites)
+               finally:
+                       portage.util.noiselimit = global_noiselimit
+                       _emerge.emergelog._disable = global_emergelog_disable
 
                return result