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-tools

[Xen-tools] Re: [Xen-devel] [PATCH] rework xen/xm/main.py to be more str

To: Anthony Liguori <aliguori@xxxxxxxxxx>
Subject: [Xen-tools] Re: [Xen-devel] [PATCH] rework xen/xm/main.py to be more straight forward
From: Mark Williamson <mark.williamson@xxxxxxxxxxxx>
Date: Fri, 5 Aug 2005 17:17:05 +0100
Cc: xen-tools@xxxxxxxxxxxxxxxxxxx, Ian Pratt <m+Ian.Pratt@xxxxxxxxxxxx>
Delivery-date: Fri, 05 Aug 2005 16:17:11 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <42F38464.1080202@xxxxxxxxxx>
List-help: <mailto:xen-tools-request@lists.xensource.com?subject=help>
List-id: Xen control tools developers <xen-tools.lists.xensource.com>
List-post: <mailto:xen-tools@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-tools>, <mailto:xen-tools-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-tools>, <mailto:xen-tools-request@lists.xensource.com?subject=unsubscribe>
References: <20050801192216.GA5974@xxxxxxxxxxxxxxxxxxx> <42F38464.1080202@xxxxxxxxxx>
Sender: xen-tools-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.8.2
> #3 has the nice side-effect of ensuring that xmlib is completely
> documented which makes xmlib the perfect python interface for management
> tools.  It would be even nicer if the arguments were expanded instead of
> passed as a list so the functions could be called in a more natural way.

Just remembered what else I was going to say earlier:

If you do: function_name(*arg_list) it'll expand the list into separate args, 
so you can do exactly that.

(side note: a "**" will cause a dictionary to be expanded into a list of 
multiple named arguments)

See, Python Is Your Friend :-)

Cheers,
Mark

> A short help can be autogenerated by only grabbing the first sentence of
> __doc__.
>
> Aliases could be supported with module-level variables assigned to the
> function they alias.  However, I don't like aliases so I'd just not do
> anything.
>
> One thing this would break is abbrevation but I'm quite sure Mark is the
> only one using them :-)
>
> Regards,
>
> Anthony Liguori
>
> Sean Dague wrote:
> >The following patch is a major restructuring of main.py to be more
> > straight forward, and remove as much code as possible.  It does a number
> > of things:
> >
> >* It implements the standardized options proposed via my RFC for xm
> >* It restructures the calling of these functions to be function pointers
> > out of a dictionary, instead of subclasses found through inspection * It
> > consolidates all help info, making it easier to see that the help screen
> > looks consistent across commands
> >* It moves object importing into the functions that require them only,
> >  allowing commands like "xm help" to be runable as non root
> >* It adds command aliasing to provide backwards compatibility with many
> >  commands (i.e. xm balloon)
> >* It provides more useful error messages is most fail cases
> >* It implements a short help by default (which takes < 24 screen lines) as
> >  requested by Mark W at OLS
> >* It attempts to trap more exceptions than before and provide useful
> > errors based on them (this requires more testing)
> >
> >It also has the added benefit of dropping the total size of main.py from
> >935 lines to 694 lines.
> >
> >This patch makes no changes to any other elements of xen/xm, and works
> > with all other objects and libraries as is.

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