WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] pygrub: do not overload RuntimeError for "no men

To: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] pygrub: do not overload RuntimeError for "no menu.lst found"
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Thu, 20 Oct 2011 09:32:39 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 20 Oct 2011 01:33:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <bd1f7361d3d7f4c767af.1319096998@xxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <bd1f7361d3d7f4c767af.1319096998@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Thu, 2011-10-20 at 09:10 +0100, Paolo Bonzini wrote:
> From: pbonzini@xxxxxxxxxx
> 
> # HG changeset patch
> # User Paolo Bonzini <pbonzini@xxxxxxxxxx>
> # Date 1319096986 -7200
> # Node ID bd1f7361d3d7f4c767af21317fb4ec7ea1372f42
> # Parent  1b110e895e285f43f14532e14c77597e54a0bcd2
> pygrub will still try the next partition if run_grub exits with a
> "real" error, thus hiding the root cause from the trace.  Defining
> a separate exception for "no bootloader config file found" avoids
> this.

Are all the other RuntimeError's ok or should we be defining a bunch of
more specific exceptions?

We need a signed-off-by for this change, per DCO:
http://wiki.xen.org/xenwiki/SubmittingXenPatches

Thanks,
Ian.

> 
> diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
> --- a/tools/pygrub/src/pygrub
> +++ b/tools/pygrub/src/pygrub
> @@ -29,6 +29,9 @@ import grub.ExtLinuxConf
>  
>  PYGRUB_VER = 0.6
>  
> +class NotFoundError(RuntimeError):
> +    pass
> +
>  def enable_cursor(ison):
>      if ison:
>          val = 2
> @@ -412,7 +412,7 @@ class Grub:
>                  self.cf.filename = f
>                  break
>          if self.__dict__.get('cf', None) is None:
> -            raise RuntimeError, "couldn't find bootloader config file in the 
> image provided."
> +            raise NotFoundError, "couldn't find bootloader config file in 
> the image provided."
>          f = fs.open_file(self.cf.filename)
>          buf = f.read()
>          del f
> @@ -763,9 +766,9 @@ if __name__ == "__main__":
>                  break
>              fs = None
>  
> -        except:
> +        except (IOError, NotFoundError):
>              # IOErrors raised by fsimage.open
> -            # RuntimeErrors raised by run_grub if no menu.lst present
> +            # NotFoundError raised by run_grub if no menu.lst present
>              fs = None
>              continue
>  
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>