18583 the output of pkg verify and fix has rotted a bit
authorShawn Walker <shawn.walker@oracle.com>
Thu, 14 Jul 2011 08:30:30 -0700
changeset 2463 a23c2a2b7080
parent 2462 d89a0da0a548
child 2464 76e611359813
18583 the output of pkg verify and fix has rotted a bit
src/client.py
src/modules/client/image.py
src/modules/client/progress.py
--- a/src/client.py	Wed Jul 13 17:41:55 2011 -0700
+++ b/src/client.py	Thu Jul 14 08:30:30 2011 -0700
@@ -707,7 +707,6 @@
                     api_errors.SigningException,
                     api_errors.InvalidResourceLocation,
                     api_errors.ConflictingActionErrors), e:
-                        logger.error("\n")
                         logger.error(str(e))
                 except api_errors.ImageFormatUpdateNeeded, e:
                         format_update_error(e)
@@ -715,9 +714,6 @@
                             result=history.RESULT_FAILED_CONFIGURATION)
                         return EXIT_OOPS
                 except api_errors.PlanLicenseErrors, e:
-                        # Prepend a newline because otherwise the exception will
-                        # be printed on the same line as the spinner.
-                        logger.error("\n")
                         error(_("The following packages require their "
                             "licenses to be accepted before they can be "
                             "repaired: "))
@@ -742,7 +738,6 @@
                         api_inst.log_operation_end(error=e)
                         raise
 
-                progresstracker.verify_done()
                 if not success:
                         api_inst.log_operation_end(
                             result=history.RESULT_FAILED_UNKNOWN)
@@ -813,14 +808,13 @@
                                 # Nothing more to do.
                                 continue
 
-                        # Could this be moved into the progresstracker?
                         if display_headers:
                                 display_headers = False
-                                msg(_("Verifying: %(pkg_name)-50s "
-                                    "%(result)7s") % { "pkg_name": _("PACKAGE"),
+                                msg(_("%(pkg_name)-70s %(result)7s") % {
+                                    "pkg_name": _("PACKAGE"),
                                     "result": _("STATUS") })
 
-                        msg(_("%(pkg_name)-50s %(result)7s") % {
+                        msg(_("%(pkg_name)-70s %(result)7s") % {
                             "pkg_name": pfmri.get_pkg_stem(),
                             "result": result })
 
@@ -846,9 +840,6 @@
                 format_update_error(e)
                 return EXIT_OOPS
 
-        if processed:
-                progresstracker.verify_done()
-
         if notfound:
                 if processed:
                         # Ensure a blank line is inserted after verify output.
@@ -859,9 +850,9 @@
 
                 if processed:
                         if any_errors:
-                                msg2 = "See above for\nverification failures."
+                                msg2 = _("See above for\nverification failures.")
                         else:
-                                msg2 = "No packages failed\nverification."
+                                msg2 = _("No packages failed\nverification.")
                         logger.error(_("\nAll other patterns matched "
                             "installed packages.  %s" % msg2))
                 any_errors = True
--- a/src/modules/client/image.py	Wed Jul 13 17:41:55 2011 -0700
+++ b/src/modules/client/image.py	Thu Jul 14 08:30:30 2011 -0700
@@ -2210,29 +2210,32 @@
                         return med_version == cfg_med_version and \
                             med.mediator_impl_matches(med_impl, cfg_med_impl)
 
-                for act in manf.gen_actions(
-                    self.list_excludes()):
-                        if (act.name == "link" or act.name == "hardlink") and \
-                            not mediation_allowed(act):
-                                # Link doesn't match configured mediation, so
-                                # shouldn't be verified.
-                                continue
-
-                        errors, warnings, info = act.verify(self, pfmri=fmri,
-                            **kwargs)
-                        progresstracker.verify_add_progress(fmri)
-                        actname = act.distinguished_name()
-                        if errors:
-                                progresstracker.verify_yield_error(actname,
-                                    errors)
-                        if warnings:
-                                progresstracker.verify_yield_warning(actname,
-                                    warnings)
-                        if info:
-                                progresstracker.verify_yield_info(actname,
-                                    info)
-                        if errors or warnings or info:
-                                yield act, errors, warnings, info
+                try:
+                        for act in manf.gen_actions(
+                            self.list_excludes()):
+                                if (act.name == "link" or act.name == "hardlink") and \
+                                    not mediation_allowed(act):
+                                        # Link doesn't match configured
+                                        # mediation, so shouldn't be verified.
+                                        continue
+
+                                errors, warnings, info = act.verify(self,
+                                    pfmri=fmri, **kwargs)
+                                progresstracker.verify_add_progress(fmri)
+                                actname = act.distinguished_name()
+                                if errors:
+                                        progresstracker.verify_yield_error(
+                                            actname, errors)
+                                if warnings:
+                                        progresstracker.verify_yield_warning(
+                                            actname, warnings)
+                                if info:
+                                        progresstracker.verify_yield_info(
+                                            actname, info)
+                                if errors or warnings or info:
+                                        yield act, errors, warnings, info
+                finally:
+                        progresstracker.verify_done()
 
         def image_config_update(self, new_variants, new_facets, new_mediators):
                 """update variants in image config"""
@@ -2245,20 +2248,25 @@
                         self.cfg.mediators = new_mediators
                 self.save_config()
 
-        def repair(self, *args, **kwargs):
+        def repair(self, repair, progtrack, **kwargs):
                 """Repair any actions in the fmri that failed a verify."""
 
                 # prune off any new_history_op keyword argument, used for
                 # locked_op(), but not for __repair()
                 need_history_op = kwargs.pop("new_history_op", True)
 
-                with self.locked_op("fix", new_history_op=need_history_op):
-                        try:
-                                return self.__repair(*args, **kwargs)
-                        except apx.ActionExecutionError, e:
-                                raise
-                        except pkg.actions.ActionError, e:
-                                raise apx.InvalidPackageErrors([e])
+                try:
+                        with self.locked_op("fix",
+                            new_history_op=need_history_op):
+                                try:
+                                        return self.__repair(repair, progtrack,
+                                            **kwargs)
+                                except apx.ActionExecutionError, e:
+                                        raise
+                                except pkg.actions.ActionError, e:
+                                        raise apx.InvalidPackageErrors([e])
+                finally:
+                        progtrack.verify_done()
 
         def __repair(self, repairs, progtrack, accept=False,
             show_licenses=False):
--- a/src/modules/client/progress.py	Wed Jul 13 17:41:55 2011 -0700
+++ b/src/modules/client/progress.py	Thu Jul 14 08:30:30 2011 -0700
@@ -989,7 +989,7 @@
                         self.last_print_time = time.time()
                         self.spinner = (self.spinner + 1) % \
                             len(self.spinner_chars)
-                        s = "%-50s..... %c%c" % \
+                        s = "%-70s..... %c%c" % \
                             (self.ver_cur_fmri.get_pkg_stem(),
                              self.spinner_chars[self.spinner],
                              self.spinner_chars[self.spinner])