Isaku Yamahata
2009-Jul-23 04:04 UTC
[Xen-devel] [PATCH] python: make tools/python/xen/util/fileuri.py work on python 2.3
python: make tools/python/xen/util/fileuri.py work on python 2.3 @staticmethod syntax sugar was introduced at python2.4. expand the syntax sugar for python 2.3 Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> diff --git a/tools/python/xen/util/fileuri.py b/tools/python/xen/util/fileuri.py --- a/tools/python/xen/util/fileuri.py +++ b/tools/python/xen/util/fileuri.py @@ -50,7 +50,6 @@ class scheme_error(Exception): # o Only base64 is currently supported class scheme_data: - @staticmethod def encode(data, mediatype = ''application/octet-stream'', encoding = ''base64''): # XXX Limit this to base64 for current implementation @@ -58,9 +57,9 @@ class scheme_data: raise scheme_error("invalid encoding") return ''data:'' + mediatype + ";" + encoding \ + "," + base64.b64encode(data) + encode = staticmethod(encode) # Private method: parse encoded data - @staticmethod def parse(encoded_data): if not isinstance(encoded_data, str): raise scheme_error("encoded data has wrong type") @@ -78,11 +77,11 @@ class scheme_data: raise scheme_error("encoding is not base64") mediatype = mtenc[:-7] return (mediatype, ''base64'', comma+1) + parse = staticmethod(parse) # Stores the data in a local file and returns the filename # and a flag if this file in temporary only and must be deleted # after starting the VM. - @staticmethod def decode(encoded_data): mkdir.parents("/var/run/xend/boot/", stat.S_IRWXU) mediatype, encoding, data_start = scheme_data.parse(encoded_data) @@ -91,10 +90,10 @@ class scheme_data: os.write(fd, base64.b64decode(encoded_data[data_start:])) os.close(fd) return filename, True + decode = staticmethod(decode) # Utility function which reads in the given (local) file and # creates a data scheme from this. - @staticmethod def create_from_file(filename): try: f = open(filename, "r") @@ -103,6 +102,7 @@ class scheme_data: return scheme_data.encode(d) except IOError: raise scheme_error("file does not exists") + create_from_file = staticmethod(create_from_file) class scheme_data_unit_tests(unittest.TestCase): @@ -181,15 +181,14 @@ class scheme_data_unit_tests(unittest.Te # This class supports absolut paths only. class scheme_file: - @staticmethod def encode(filename): if len(filename) == 0: raise scheme_error("filename is empty") if filename[0] != ''/'': raise scheme_error("filename is not absolut") return ''file://'' + filename + encode = staticmethod(encode) - @staticmethod def decode(encoded_data): if not encoded_data.startswith("file://"): raise scheme_error("no file:// scheme found") @@ -199,6 +198,7 @@ class scheme_file: if path[0]!=''/'': raise scheme_error("path is not absolute") return path, False + decode = staticmethod(decode) class scheme_file_unit_tests(unittest.TestCase): -- yamahata _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Andreas Florath
2009-Jul-26 21:07 UTC
Re: [Xen-devel] [PATCH] python: make tools/python/xen/util/fileuri.py work on python 2.3
Hello! It would be nice, if you can please provide some more information: especially the OS / Distribution (Version) you are using. I looked around but did not find any Linux distribution nowadays which still comes with python2.3 - even Debian etch (which is known to be ''stable'' :-) ) comes with python 2.4.4. Looking though the xen-unstable tree I found at least two different supported python version numbers: 1. ''README'' : ... Development install of Python v2.3 or later... 2. ''./docs/src/user.tex'': ... Development installation of Python v2.2 or later ... Are there any guidelines (written or unwritten) which python version to support for new patches? IMHO at least 2.4, 2.5 and 2.6 should be supported. When interpreting the documentation literally also python 3 should work. Must 2.3 and maybe even 2.2 be supported? Is there some kind of roadmap saying e.g.: xen 3.6 will be the last version which supports python 2.3? Or: starting from xen 4.0 python 3 will be supported? Background: The feature was removed from the repository because of another bug report. But before providing a corrected version, I want to be sure that I''ll get all aspects of the changes send in the meantime; especially here to test the feature with all supported python versions. Kind regards Andreas Florath _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Isaku Yamahata
2009-Jul-27 03:02 UTC
Re: [Xen-devel] [PATCH] python: make tools/python/xen/util/fileuri.py work on python 2.3
Hello. Thank you for taking care of old python. Kuwamura-san could give more detailed informations. Actually one of my testing environment is a very old distro, so I just fixed the version issue ad hoc to make xend boot. I don''t know about the xen official policy with python version. I''m afraid that the document you referred isn''t well-maintained. thanks, On Sun, Jul 26, 2009 at 11:07:29PM +0200, Andreas Florath wrote:> Hello! > > It would be nice, if you can please provide some more information: > especially the OS / Distribution (Version) you are using. I looked > around but did not find any Linux distribution nowadays which still > comes with python2.3 - even Debian etch (which is known to be ''stable'' > :-) ) comes with python 2.4.4. > > Looking though the xen-unstable tree I found at least two different > supported python version numbers: > > 1. ''README'' : ... Development install of Python v2.3 or later... > 2. ''./docs/src/user.tex'': ... Development installation of Python v2.2 > or later ... > > Are there any guidelines (written or unwritten) which python version to > support for new patches? > IMHO at least 2.4, 2.5 and 2.6 should be supported. > When interpreting the documentation literally also python 3 should work. > Must 2.3 and maybe even 2.2 be supported? > > Is there some kind of roadmap saying e.g.: xen 3.6 will be the last > version which supports python 2.3? Or: starting from xen 4.0 python 3 > will be supported? > > Background: > The feature was removed from the repository because of another bug > report. But before providing a corrected version, I want to be sure > that I''ll get all aspects of the changes send in the meantime; > especially here to test the feature with all supported python versions. > > > Kind regards > > Andreas Florath > >-- yamahata _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel