FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora/Linux Management Tools

 
 
LinkBack Thread Tools
 
Old 07-17-2008, 06:56 PM
 
Default virt-convert: fix Python 2.4 compatibility

# HG changeset patch
# User john.levon@sun.com
# Date 1216320992 25200
# Node ID cdab3fd5617c32955e16b9bf9cf1d121634746ec
# Parent cd648dc6a9492fe3b703e5ebc7f43d05bb03adeb
virt-convert: fix Python 2.4 compatibility

Sadly, pkgutil.iter_modules() is new in Python 2.5, so the automatic
module finding code won't work in 2.4. Add hard-coded fallbacks for Python 2.4
and earlier.

Signed-off-by: John Levon <john.levon@sun.com>

diff --git a/virtconv/__init__.py b/virtconv/__init__.py
--- a/virtconv/__init__.py
+++ b/virtconv/__init__.py
@@ -24,6 +24,15 @@

parsers_path = [os.path.join(__path__[0], "parsers/")]

-for loader, name, ispkg in pkgutil.iter_modules(parsers_path):
+# iter_modules is only in Python 2.5, sadly
+parser_names = [ "vmx", "virtimage" ]
+
+if hasattr(pkgutil, "iter_modules"):
+ print "here"
+ parser_names = []
+ for _, name, _ in pkgutil.iter_modules(parsers_path):
+ parser_names += [ name ]
+
+for name in parser_names:
filename, pathname, desc = imp.find_module(name, parsers_path)
imp.load_module(name, filename, pathname, desc)

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 07-17-2008, 07:07 PM
Cole Robinson
 
Default virt-convert: fix Python 2.4 compatibility

john.levon@sun.com wrote:
> # HG changeset patch
> # User john.levon@sun.com
> # Date 1216320992 25200
> # Node ID cdab3fd5617c32955e16b9bf9cf1d121634746ec
> # Parent cd648dc6a9492fe3b703e5ebc7f43d05bb03adeb
> virt-convert: fix Python 2.4 compatibility
>
> Sadly, pkgutil.iter_modules() is new in Python 2.5, so the automatic
> module finding code won't work in 2.4. Add hard-coded fallbacks for Python 2.4
> and earlier.
>
> Signed-off-by: John Levon <john.levon@sun.com>
>
> diff --git a/virtconv/__init__.py b/virtconv/__init__.py
> --- a/virtconv/__init__.py
> +++ b/virtconv/__init__.py
> @@ -24,6 +24,15 @@
>
> parsers_path = [os.path.join(__path__[0], "parsers/")]
>
> -for loader, name, ispkg in pkgutil.iter_modules(parsers_path):
> +# iter_modules is only in Python 2.5, sadly
> +parser_names = [ "vmx", "virtimage" ]
> +
> +if hasattr(pkgutil, "iter_modules"):
> + print "here"

Probably didn't mean to include this line.

> + parser_names = []
> + for _, name, _ in pkgutil.iter_modules(parsers_path):

Please use something other than '_' here as previously
mentioned.

- Cole

> + parser_names += [ name ]
> +
> +for name in parser_names:
> filename, pathname, desc = imp.find_module(name, parsers_path)
> imp.load_module(name, filename, pathname, desc)
>

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 07-17-2008, 09:07 PM
John Levon
 
Default virt-convert: fix Python 2.4 compatibility

On Thu, Jul 17, 2008 at 03:07:08PM -0400, Cole Robinson wrote:

> > +if hasattr(pkgutil, "iter_modules"):
> > + print "here"
>
> Probably didn't mean to include this line.

Sigh, sorry.

> > + parser_names = []
> > + for _, name, _ in pkgutil.iter_modules(parsers_path):
>
> Please use something other than '_' here as previously
> mentioned.

Even for obviously internal only files like this? Will do.

Will resend shortly.

regards
john

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 07-17-2008, 09:19 PM
Cole Robinson
 
Default virt-convert: fix Python 2.4 compatibility

John Levon wrote:
>>> + parser_names = []
>>> + for _, name, _ in pkgutil.iter_modules(parsers_path):
>> Please use something other than '_' here as previously
>> mentioned.
>
> Even for obviously internal only files like this? Will do.
>

Yeah, I (wrongly) thought that this could stomp '_' in any
files that imported it but I wasn't thinking clearly.

- Cole

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 07-17-2008, 09:30 PM
 
Default virt-convert: fix Python 2.4 compatibility

# HG changeset patch
# User john.levon@sun.com
# Date 1216330222 25200
# Node ID 2ff8e5fe0868cf18643e1d7d2455d479c9379f44
# Parent cd648dc6a9492fe3b703e5ebc7f43d05bb03adeb
virt-convert: fix Python 2.4 compatibility

Sadly, pkgutil.iter_modules() is new in Python 2.5, so the automatic
module finding code won't work in 2.4. Add hard-coded fallbacks for Python 2.4
and earlier.

Signed-off-by: John Levon <john.levon@sun.com>

diff --git a/virtconv/__init__.py b/virtconv/__init__.py
--- a/virtconv/__init__.py
+++ b/virtconv/__init__.py
@@ -24,6 +24,14 @@

parsers_path = [os.path.join(__path__[0], "parsers/")]

-for loader, name, ispkg in pkgutil.iter_modules(parsers_path):
+# iter_modules is only in Python 2.5, sadly
+parser_names = [ "vmx", "virtimage" ]
+
+if hasattr(pkgutil, "iter_modules"):
+ parser_names = []
+ for ignore, name, ignore in pkgutil.iter_modules(parsers_path):
+ parser_names += [ name ]
+
+for name in parser_names:
filename, pathname, desc = imp.find_module(name, parsers_path)
imp.load_module(name, filename, pathname, desc)

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 
Old 07-22-2008, 04:19 PM
Cole Robinson
 
Default virt-convert: fix Python 2.4 compatibility

john.levon@sun.com wrote:
> # HG changeset patch
> # User john.levon@sun.com
> # Date 1216330222 25200
> # Node ID 2ff8e5fe0868cf18643e1d7d2455d479c9379f44
> # Parent cd648dc6a9492fe3b703e5ebc7f43d05bb03adeb
> virt-convert: fix Python 2.4 compatibility
>
> Sadly, pkgutil.iter_modules() is new in Python 2.5, so the automatic
> module finding code won't work in 2.4. Add hard-coded fallbacks for Python 2.4
> and earlier.
>
> Signed-off-by: John Levon <john.levon@sun.com>
>
> diff --git a/virtconv/__init__.py b/virtconv/__init__.py
> --- a/virtconv/__init__.py
> +++ b/virtconv/__init__.py
> @@ -24,6 +24,14 @@
>
> parsers_path = [os.path.join(__path__[0], "parsers/")]
>
> -for loader, name, ispkg in pkgutil.iter_modules(parsers_path):
> +# iter_modules is only in Python 2.5, sadly
> +parser_names = [ "vmx", "virtimage" ]
> +
> +if hasattr(pkgutil, "iter_modules"):
> + parser_names = []
> + for ignore, name, ignore in pkgutil.iter_modules(parsers_path):
> + parser_names += [ name ]
> +
> +for name in parser_names:
> filename, pathname, desc = imp.find_module(name, parsers_path)
> imp.load_module(name, filename, pathname, desc)
>

Okay, looks good. I've committed this:

http://hg.et.redhat.com/virt/applications/virtinst--devel?cs=2ff8e5fe0868

Thanks,
Cole

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@redhat.com
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
 

Thread Tools




All times are GMT. The time now is 08:30 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org