diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-05-07 13:55:55 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-05-09 14:06:50 +0100 |
commit | 2ac4f8b39711209ba9323fc221c1dcd185da57ea (patch) | |
tree | cbaa1e573abd13c7827a5b4a57724fd884df148b | |
parent | 00052fe69582f238166511e733d3ba875cbe0ad2 (diff) | |
download | poky-2ac4f8b39711209ba9323fc221c1dcd185da57ea.tar.gz |
clases/lib: Use modern exception syntax
Update older code to use modern exception handling syntax which
is the form accepted by python 3.
(From OE-Core rev: b010501cd089e649a68f683be0cf4d0aac90fbe3)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/base.bbclass | 4 | ||||
-rw-r--r-- | meta/classes/package.bbclass | 6 | ||||
-rw-r--r-- | meta/classes/sanity.bbclass | 6 | ||||
-rw-r--r-- | meta/lib/oe/cachedpath.py | 4 | ||||
-rw-r--r-- | meta/lib/oe/patch.py | 2 | ||||
-rw-r--r-- | meta/lib/oe/path.py | 6 | ||||
-rw-r--r-- | meta/lib/oe/qa.py | 2 | ||||
-rw-r--r-- | meta/lib/oe/types.py | 2 | ||||
-rw-r--r-- | meta/lib/oe/utils.py | 2 |
9 files changed, 19 insertions, 15 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index 641316d1fa..196acdbb30 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass | |||
@@ -108,7 +108,7 @@ python base_do_fetch() { | |||
108 | try: | 108 | try: |
109 | fetcher = bb.fetch2.Fetch(src_uri, localdata) | 109 | fetcher = bb.fetch2.Fetch(src_uri, localdata) |
110 | fetcher.download() | 110 | fetcher.download() |
111 | except bb.fetch2.BBFetchException, e: | 111 | except bb.fetch2.BBFetchException as e: |
112 | raise bb.build.FuncFailed(e) | 112 | raise bb.build.FuncFailed(e) |
113 | } | 113 | } |
114 | 114 | ||
@@ -128,7 +128,7 @@ python base_do_unpack() { | |||
128 | try: | 128 | try: |
129 | fetcher = bb.fetch2.Fetch(src_uri, localdata) | 129 | fetcher = bb.fetch2.Fetch(src_uri, localdata) |
130 | fetcher.unpack(rootdir) | 130 | fetcher.unpack(rootdir) |
131 | except bb.fetch2.BBFetchException, e: | 131 | except bb.fetch2.BBFetchException as e: |
132 | raise bb.build.FuncFailed(e) | 132 | raise bb.build.FuncFailed(e) |
133 | } | 133 | } |
134 | 134 | ||
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 1a8da40fdb..96228b0bc0 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
@@ -777,7 +777,8 @@ python split_and_strip_files () { | |||
777 | try: | 777 | try: |
778 | ltarget = cpath.realpath(file, dvar, False) | 778 | ltarget = cpath.realpath(file, dvar, False) |
779 | s = cpath.lstat(ltarget) | 779 | s = cpath.lstat(ltarget) |
780 | except OSError, (err, strerror): | 780 | except OSError as e: |
781 | (err, strerror) = e.args | ||
781 | if err != errno.ENOENT: | 782 | if err != errno.ENOENT: |
782 | raise | 783 | raise |
783 | # Skip broken symlinks | 784 | # Skip broken symlinks |
@@ -855,7 +856,8 @@ python split_and_strip_files () { | |||
855 | # Skip it if the target doesn't exist | 856 | # Skip it if the target doesn't exist |
856 | try: | 857 | try: |
857 | s = os.stat(fpath) | 858 | s = os.stat(fpath) |
858 | except OSError, (err, strerror): | 859 | except OSError as e: |
860 | (err, strerror) = e.args | ||
859 | if err != errno.ENOENT: | 861 | if err != errno.ENOENT: |
860 | raise | 862 | raise |
861 | continue | 863 | continue |
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass index ac2314fdcf..766e97e916 100644 --- a/meta/classes/sanity.bbclass +++ b/meta/classes/sanity.bbclass | |||
@@ -235,12 +235,14 @@ def check_create_long_filename(filepath, pathname): | |||
235 | f = file(testfile, "w") | 235 | f = file(testfile, "w") |
236 | f.close() | 236 | f.close() |
237 | os.remove(testfile) | 237 | os.remove(testfile) |
238 | except IOError as (errno, strerror): | 238 | except IOError as e: |
239 | errno, strerror = e.args | ||
239 | if errno == 36: # ENAMETOOLONG | 240 | if errno == 36: # ENAMETOOLONG |
240 | return "Failed to create a file with a long name in %s. Please use a filesystem that does not unreasonably limit filename length.\n" % pathname | 241 | return "Failed to create a file with a long name in %s. Please use a filesystem that does not unreasonably limit filename length.\n" % pathname |
241 | else: | 242 | else: |
242 | return "Failed to create a file in %s: %s.\n" % (pathname, strerror) | 243 | return "Failed to create a file in %s: %s.\n" % (pathname, strerror) |
243 | except OSError as (errno, strerror): | 244 | except OSError as e: |
245 | errno, strerror = e.args | ||
244 | return "Failed to create %s directory in which to run long name sanity check: %s.\n" % (pathname, strerror) | 246 | return "Failed to create %s directory in which to run long name sanity check: %s.\n" % (pathname, strerror) |
245 | return "" | 247 | return "" |
246 | 248 | ||
diff --git a/meta/lib/oe/cachedpath.py b/meta/lib/oe/cachedpath.py index e350c8a70e..c7860ef4fb 100644 --- a/meta/lib/oe/cachedpath.py +++ b/meta/lib/oe/cachedpath.py | |||
@@ -125,7 +125,7 @@ class CachedPath(object): | |||
125 | # Note that listdir and error are globals in this module due | 125 | # Note that listdir and error are globals in this module due |
126 | # to earlier import-*. | 126 | # to earlier import-*. |
127 | names = os.listdir(top) | 127 | names = os.listdir(top) |
128 | except error, err: | 128 | except error as err: |
129 | if onerror is not None: | 129 | if onerror is not None: |
130 | onerror(err) | 130 | onerror(err) |
131 | return | 131 | return |
@@ -221,7 +221,7 @@ class CachedPath(object): | |||
221 | file = self.__realpath_rel(root, file[(len(root) - 1):], root, loop_cnt, assume_dir) | 221 | file = self.__realpath_rel(root, file[(len(root) - 1):], root, loop_cnt, assume_dir) |
222 | else: | 222 | else: |
223 | file = self.__realpath(file, root, loop_cnt, assume_dir)[0] | 223 | file = self.__realpath(file, root, loop_cnt, assume_dir)[0] |
224 | except OSError, e: | 224 | except OSError as e: |
225 | if e.errno == errno.ELOOP: | 225 | if e.errno == errno.ELOOP: |
226 | # make ELOOP more readable; without catching it, there will | 226 | # make ELOOP more readable; without catching it, there will |
227 | # be printed a backtrace with 100s of OSError exceptions | 227 | # be printed a backtrace with 100s of OSError exceptions |
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index 7ab74fae8a..cbc5cd9755 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py | |||
@@ -392,7 +392,7 @@ class UserResolver(Resolver): | |||
392 | os.chdir(self.patchset.dir) | 392 | os.chdir(self.patchset.dir) |
393 | try: | 393 | try: |
394 | self.patchset.Push(False) | 394 | self.patchset.Push(False) |
395 | except CmdError, v: | 395 | except CmdError as v: |
396 | # Patch application failed | 396 | # Patch application failed |
397 | patchcmd = self.patchset.Push(True, False, False) | 397 | patchcmd = self.patchset.Push(True, False, False) |
398 | 398 | ||
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py index 76a6ed8314..d8eb80225f 100644 --- a/meta/lib/oe/path.py +++ b/meta/lib/oe/path.py | |||
@@ -107,7 +107,7 @@ def remove(path, recurse=True): | |||
107 | for name in glob.glob(path): | 107 | for name in glob.glob(path): |
108 | try: | 108 | try: |
109 | os.unlink(name) | 109 | os.unlink(name) |
110 | except OSError, exc: | 110 | except OSError as exc: |
111 | if recurse and exc.errno == errno.EISDIR: | 111 | if recurse and exc.errno == errno.EISDIR: |
112 | shutil.rmtree(name) | 112 | shutil.rmtree(name) |
113 | elif exc.errno != errno.ENOENT: | 113 | elif exc.errno != errno.ENOENT: |
@@ -119,7 +119,7 @@ def symlink(source, destination, force=False): | |||
119 | if force: | 119 | if force: |
120 | remove(destination) | 120 | remove(destination) |
121 | os.symlink(source, destination) | 121 | os.symlink(source, destination) |
122 | except OSError, e: | 122 | except OSError as e: |
123 | if e.errno != errno.EEXIST or os.readlink(destination) != source: | 123 | if e.errno != errno.EEXIST or os.readlink(destination) != source: |
124 | raise | 124 | raise |
125 | 125 | ||
@@ -247,7 +247,7 @@ def realpath(file, root, use_physdir = True, loop_cnt = 100, assume_dir = False) | |||
247 | file = __realpath_rel(root, file[(len(root) - 1):], root, loop_cnt, assume_dir) | 247 | file = __realpath_rel(root, file[(len(root) - 1):], root, loop_cnt, assume_dir) |
248 | else: | 248 | else: |
249 | file = __realpath(file, root, loop_cnt, assume_dir)[0] | 249 | file = __realpath(file, root, loop_cnt, assume_dir)[0] |
250 | except OSError, e: | 250 | except OSError as e: |
251 | if e.errno == errno.ELOOP: | 251 | if e.errno == errno.ELOOP: |
252 | # make ELOOP more readable; without catching it, there will | 252 | # make ELOOP more readable; without catching it, there will |
253 | # be printed a backtrace with 100s of OSError exceptions | 253 | # be printed a backtrace with 100s of OSError exceptions |
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py index d9848c8e4a..4777ddc06a 100644 --- a/meta/lib/oe/qa.py +++ b/meta/lib/oe/qa.py | |||
@@ -106,6 +106,6 @@ class ELFFile: | |||
106 | bb.note("%s %s %s" % (objdump, cmd, self.name)) | 106 | bb.note("%s %s %s" % (objdump, cmd, self.name)) |
107 | self.objdump_output[cmd] = bb.process.run([objdump, cmd, self.name], env=env, shell=False)[0] | 107 | self.objdump_output[cmd] = bb.process.run([objdump, cmd, self.name], env=env, shell=False)[0] |
108 | return self.objdump_output[cmd] | 108 | return self.objdump_output[cmd] |
109 | except Exception, e: | 109 | except Exception as e: |
110 | bb.note("%s %s %s failed: %s" % (objdump, cmd, self.name, e)) | 110 | bb.note("%s %s %s failed: %s" % (objdump, cmd, self.name, e)) |
111 | return "" | 111 | return "" |
diff --git a/meta/lib/oe/types.py b/meta/lib/oe/types.py index ea53df9bf2..5dac9de239 100644 --- a/meta/lib/oe/types.py +++ b/meta/lib/oe/types.py | |||
@@ -92,7 +92,7 @@ def regex(value, regexflags=None): | |||
92 | 92 | ||
93 | try: | 93 | try: |
94 | return re.compile(value, flagval) | 94 | return re.compile(value, flagval) |
95 | except re.error, exc: | 95 | except re.error as exc: |
96 | raise ValueError("Invalid regex value '%s': %s" % | 96 | raise ValueError("Invalid regex value '%s': %s" % |
97 | (value, exc.args[0])) | 97 | (value, exc.args[0])) |
98 | 98 | ||
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index acd39693b5..ed9409613a 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py | |||
@@ -1,7 +1,7 @@ | |||
1 | def read_file(filename): | 1 | def read_file(filename): |
2 | try: | 2 | try: |
3 | f = file( filename, "r" ) | 3 | f = file( filename, "r" ) |
4 | except IOError, reason: | 4 | except IOError as reason: |
5 | return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M: | 5 | return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M: |
6 | else: | 6 | else: |
7 | return f.read().strip() | 7 | return f.read().strip() |