summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Garman <scott.a.garman@intel.com>2011-06-14 16:44:58 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-15 11:13:13 +0100
commit62d538fbe65cf61ebc5996b0d6eb7e4ec47b6ead (patch)
tree685b0c48785db94f4fc26f727932f8779bc2fb5a
parent039798a4d250665c66fd738dba4d07dc2ec70652 (diff)
downloadpoky-62d538fbe65cf61ebc5996b0d6eb7e4ec47b6ead.tar.gz
make exception handling syntax consistent
Update exception handling syntax to use the modern style: except ExcType as localvar (Bitbake rev: dbf5f42b06bef81749b13aa99945cc1292a6676d) Signed-off-by: Scott Garman <scott.a.garman@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbitbake/bin/bitbake2
-rw-r--r--bitbake/lib/bb/cooker.py10
-rw-r--r--bitbake/lib/bb/data.py2
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py4
-rw-r--r--bitbake/lib/bb/process.py2
-rw-r--r--bitbake/lib/bb/pysh/builtin.py10
-rw-r--r--bitbake/lib/bb/pysh/interp.py14
-rw-r--r--bitbake/lib/bb/runqueue.py2
-rw-r--r--bitbake/lib/bb/server/process.py4
-rw-r--r--bitbake/lib/prserv/serv.py6
10 files changed, 28 insertions, 28 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 5109f16ff9..a99dde311f 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -32,7 +32,7 @@ import warnings
32from traceback import format_exception 32from traceback import format_exception
33try: 33try:
34 import bb 34 import bb
35except RuntimeError, exc: 35except RuntimeError as exc:
36 sys.exit(str(exc)) 36 sys.exit(str(exc))
37from bb import event 37from bb import event
38import bb.msg 38import bb.msg
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index c81baf66b7..ebf963d5ba 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -100,7 +100,7 @@ class BBCooker:
100 name_array = (getattr(module, configuration.ui)).extraCaches 100 name_array = (getattr(module, configuration.ui)).extraCaches
101 for recipeInfoName in name_array: 101 for recipeInfoName in name_array:
102 caches_name_array.append(recipeInfoName) 102 caches_name_array.append(recipeInfoName)
103 except ImportError, exc: 103 except ImportError as exc:
104 # bb.ui.XXX is not defined and imported. It's an error! 104 # bb.ui.XXX is not defined and imported. It's an error!
105 logger.critical("Unable to import '%s' interface from bb.ui: %s" % (configuration.ui, exc)) 105 logger.critical("Unable to import '%s' interface from bb.ui: %s" % (configuration.ui, exc))
106 sys.exit("FATAL: Failed to import '%s' interface." % configuration.ui) 106 sys.exit("FATAL: Failed to import '%s' interface." % configuration.ui)
@@ -117,7 +117,7 @@ class BBCooker:
117 module_name, cache_name = var.split(':') 117 module_name, cache_name = var.split(':')
118 module = __import__(module_name, fromlist=(cache_name,)) 118 module = __import__(module_name, fromlist=(cache_name,))
119 self.caches_array.append(getattr(module, cache_name)) 119 self.caches_array.append(getattr(module, cache_name))
120 except ImportError, exc: 120 except ImportError as exc:
121 logger.critical("Unable to import extra RecipeInfo '%s' from '%s': %s" % (cache_name, module_name, exc)) 121 logger.critical("Unable to import extra RecipeInfo '%s' from '%s': %s" % (cache_name, module_name, exc))
122 sys.exit("FATAL: Failed to import extra cache class '%s'." % cache_name) 122 sys.exit("FATAL: Failed to import extra cache class '%s'." % cache_name)
123 123
@@ -280,7 +280,7 @@ class BBCooker:
280 if fn: 280 if fn:
281 try: 281 try:
282 envdata = bb.cache.Cache.loadDataFull(fn, self.get_file_appends(fn), self.configuration.data) 282 envdata = bb.cache.Cache.loadDataFull(fn, self.get_file_appends(fn), self.configuration.data)
283 except Exception, e: 283 except Exception as e:
284 parselog.exception("Unable to read %s", fn) 284 parselog.exception("Unable to read %s", fn)
285 raise 285 raise
286 286
@@ -1159,7 +1159,7 @@ def parse_file(task):
1159 filename, appends, caches_array = task 1159 filename, appends, caches_array = task
1160 try: 1160 try:
1161 return True, bb.cache.Cache.parse(filename, appends, parse_file.cfg, caches_array) 1161 return True, bb.cache.Cache.parse(filename, appends, parse_file.cfg, caches_array)
1162 except Exception, exc: 1162 except Exception as exc:
1163 tb = sys.exc_info()[2] 1163 tb = sys.exc_info()[2]
1164 exc.recipe = filename 1164 exc.recipe = filename
1165 exc.traceback = list(bb.exceptions.extract_traceback(tb, context=3)) 1165 exc.traceback = list(bb.exceptions.extract_traceback(tb, context=3))
@@ -1167,7 +1167,7 @@ def parse_file(task):
1167 # Need to turn BaseExceptions into Exceptions here so we gracefully shutdown 1167 # Need to turn BaseExceptions into Exceptions here so we gracefully shutdown
1168 # and for example a worker thread doesn't just exit on its own in response to 1168 # and for example a worker thread doesn't just exit on its own in response to
1169 # a SystemExit event for example. 1169 # a SystemExit event for example.
1170 except BaseException, exc: 1170 except BaseException as exc:
1171 raise ParsingFailure(exc, filename) 1171 raise ParsingFailure(exc, filename)
1172 1172
1173class CookerParser(object): 1173class CookerParser(object):
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 720dd76ef6..2269f9dc74 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -187,7 +187,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
187 val = getVar(var, d, 1) 187 val = getVar(var, d, 1)
188 except (KeyboardInterrupt, bb.build.FuncFailed): 188 except (KeyboardInterrupt, bb.build.FuncFailed):
189 raise 189 raise
190 except Exception, exc: 190 except Exception as exc:
191 o.write('# expansion of %s threw %s: %s\n' % (var, exc.__class__.__name__, str(exc))) 191 o.write('# expansion of %s threw %s: %s\n' % (var, exc.__class__.__name__, str(exc)))
192 return 0 192 return 0
193 193
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 02a36b523d..e9a64c57c0 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -663,7 +663,7 @@ class FetchMethod(object):
663 663
664 try: 664 try:
665 unpack = bb.utils.to_boolean(urldata.parm.get('unpack'), True) 665 unpack = bb.utils.to_boolean(urldata.parm.get('unpack'), True)
666 except ValueError, exc: 666 except ValueError as exc:
667 bb.fatal("Invalid value for 'unpack' parameter for %s: %s" % 667 bb.fatal("Invalid value for 'unpack' parameter for %s: %s" %
668 (file, urldata.parm.get('unpack'))) 668 (file, urldata.parm.get('unpack')))
669 669
@@ -692,7 +692,7 @@ class FetchMethod(object):
692 elif file.endswith('.zip') or file.endswith('.jar'): 692 elif file.endswith('.zip') or file.endswith('.jar'):
693 try: 693 try:
694 dos = bb.utils.to_boolean(urldata.parm.get('dos'), False) 694 dos = bb.utils.to_boolean(urldata.parm.get('dos'), False)
695 except ValueError, exc: 695 except ValueError as exc:
696 bb.fatal("Invalid value for 'dos' parameter for %s: %s" % 696 bb.fatal("Invalid value for 'dos' parameter for %s: %s" %
697 (file, urldata.parm.get('dos'))) 697 (file, urldata.parm.get('dos')))
698 cmd = 'unzip -q -o' 698 cmd = 'unzip -q -o'
diff --git a/bitbake/lib/bb/process.py b/bitbake/lib/bb/process.py
index 4150d80e06..b74cb18066 100644
--- a/bitbake/lib/bb/process.py
+++ b/bitbake/lib/bb/process.py
@@ -93,7 +93,7 @@ def run(cmd, input=None, log=None, **options):
93 93
94 try: 94 try:
95 pipe = Popen(cmd, **options) 95 pipe = Popen(cmd, **options)
96 except OSError, exc: 96 except OSError as exc:
97 if exc.errno == 2: 97 if exc.errno == 2:
98 raise NotFoundError(cmd) 98 raise NotFoundError(cmd)
99 else: 99 else:
diff --git a/bitbake/lib/bb/pysh/builtin.py b/bitbake/lib/bb/pysh/builtin.py
index 25ad22eb74..b748e4a4f2 100644
--- a/bitbake/lib/bb/pysh/builtin.py
+++ b/bitbake/lib/bb/pysh/builtin.py
@@ -151,7 +151,7 @@ def builtin_trap(name, args, interp, env, stdin, stdout, stderr, debugflags):
151 for sig in args[1:]: 151 for sig in args[1:]:
152 try: 152 try:
153 env.traps[sig] = action 153 env.traps[sig] = action
154 except Exception, e: 154 except Exception as e:
155 stderr.write('trap: %s\n' % str(e)) 155 stderr.write('trap: %s\n' % str(e))
156 return 0 156 return 0
157 157
@@ -214,7 +214,7 @@ def utility_cat(name, args, interp, env, stdin, stdout, stderr, debugflags):
214 data = f.read() 214 data = f.read()
215 finally: 215 finally:
216 f.close() 216 f.close()
217 except IOError, e: 217 except IOError as e:
218 if e.errno != errno.ENOENT: 218 if e.errno != errno.ENOENT:
219 raise 219 raise
220 status = 1 220 status = 1
@@ -433,7 +433,7 @@ def utility_mkdir(name, args, interp, env, stdin, stdout, stderr, debugflags):
433 if option.has_p: 433 if option.has_p:
434 try: 434 try:
435 os.makedirs(path) 435 os.makedirs(path)
436 except IOError, e: 436 except IOError as e:
437 if e.errno != errno.EEXIST: 437 if e.errno != errno.EEXIST:
438 raise 438 raise
439 else: 439 else:
@@ -561,7 +561,7 @@ def utility_sort(name, args, interp, env, stdin, stdout, stderr, debugflags):
561 lines = f.readlines() 561 lines = f.readlines()
562 finally: 562 finally:
563 f.close() 563 f.close()
564 except IOError, e: 564 except IOError as e:
565 stderr.write(str(e) + '\n') 565 stderr.write(str(e) + '\n')
566 return 1 566 return 1
567 567
@@ -679,7 +679,7 @@ def run_command(name, args, interp, env, stdin, stdout,
679 p = subprocess.Popen([name] + args, cwd=env['PWD'], env=exec_env, 679 p = subprocess.Popen([name] + args, cwd=env['PWD'], env=exec_env,
680 stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 680 stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
681 out, err = p.communicate() 681 out, err = p.communicate()
682 except WindowsError, e: 682 except WindowsError as e:
683 raise UtilityError(str(e)) 683 raise UtilityError(str(e))
684 684
685 if not unixoutput: 685 if not unixoutput:
diff --git a/bitbake/lib/bb/pysh/interp.py b/bitbake/lib/bb/pysh/interp.py
index efe5181e1e..25d8c92ec4 100644
--- a/bitbake/lib/bb/pysh/interp.py
+++ b/bitbake/lib/bb/pysh/interp.py
@@ -248,7 +248,7 @@ class Redirections:
248 raise NotImplementedError('cannot open absolute path %s' % repr(filename)) 248 raise NotImplementedError('cannot open absolute path %s' % repr(filename))
249 else: 249 else:
250 f = file(filename, mode+'b') 250 f = file(filename, mode+'b')
251 except IOError, e: 251 except IOError as e:
252 raise RedirectionError(str(e)) 252 raise RedirectionError(str(e))
253 253
254 wrapper = None 254 wrapper = None
@@ -368,7 +368,7 @@ def resolve_shebang(path, ignoreshell=False):
368 if arg is None: 368 if arg is None:
369 return [cmd, win32_to_unix_path(path)] 369 return [cmd, win32_to_unix_path(path)]
370 return [cmd, arg, win32_to_unix_path(path)] 370 return [cmd, arg, win32_to_unix_path(path)]
371 except IOError, e: 371 except IOError as e:
372 if e.errno!=errno.ENOENT and \ 372 if e.errno!=errno.ENOENT and \
373 (e.errno!=errno.EPERM and not os.path.isdir(path)): # Opening a directory raises EPERM 373 (e.errno!=errno.EPERM and not os.path.isdir(path)): # Opening a directory raises EPERM
374 raise 374 raise
@@ -747,7 +747,7 @@ class Interpreter:
747 for cmd in cmds: 747 for cmd in cmds:
748 try: 748 try:
749 status = self.execute(cmd) 749 status = self.execute(cmd)
750 except ExitSignal, e: 750 except ExitSignal as e:
751 if sourced: 751 if sourced:
752 raise 752 raise
753 status = int(e.args[0]) 753 status = int(e.args[0])
@@ -758,13 +758,13 @@ class Interpreter:
758 if 'debug-utility' in self._debugflags or 'debug-cmd' in self._debugflags: 758 if 'debug-utility' in self._debugflags or 'debug-cmd' in self._debugflags:
759 self.log('returncode ' + str(status)+ '\n') 759 self.log('returncode ' + str(status)+ '\n')
760 return status 760 return status
761 except CommandNotFound, e: 761 except CommandNotFound as e:
762 print >>self._redirs.stderr, str(e) 762 print >>self._redirs.stderr, str(e)
763 self._redirs.stderr.flush() 763 self._redirs.stderr.flush()
764 # Command not found by non-interactive shell 764 # Command not found by non-interactive shell
765 # return 127 765 # return 127
766 raise 766 raise
767 except RedirectionError, e: 767 except RedirectionError as e:
768 # TODO: should be handled depending on the utility status 768 # TODO: should be handled depending on the utility status
769 print >>self._redirs.stderr, str(e) 769 print >>self._redirs.stderr, str(e)
770 self._redirs.stderr.flush() 770 self._redirs.stderr.flush()
@@ -948,7 +948,7 @@ class Interpreter:
948 status = self.execute(func, redirs) 948 status = self.execute(func, redirs)
949 finally: 949 finally:
950 redirs.close() 950 redirs.close()
951 except ReturnSignal, e: 951 except ReturnSignal as e:
952 status = int(e.args[0]) 952 status = int(e.args[0])
953 env['?'] = status 953 env['?'] = status
954 return status 954 return status
@@ -1044,7 +1044,7 @@ class Interpreter:
1044 1044
1045 except ReturnSignal: 1045 except ReturnSignal:
1046 raise 1046 raise
1047 except ShellError, e: 1047 except ShellError as e:
1048 if is_special or isinstance(e, (ExitSignal, 1048 if is_special or isinstance(e, (ExitSignal,
1049 ShellSyntaxError, ExpansionError)): 1049 ShellSyntaxError, ExpansionError)):
1050 raise e 1050 raise e
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index af21eae42a..7a17fce789 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1228,7 +1228,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
1228 modname, name = sched.rsplit(".", 1) 1228 modname, name = sched.rsplit(".", 1)
1229 try: 1229 try:
1230 module = __import__(modname, fromlist=(name,)) 1230 module = __import__(modname, fromlist=(name,))
1231 except ImportError, exc: 1231 except ImportError as exc:
1232 logger.critical("Unable to import scheduler '%s' from '%s': %s" % (name, modname, exc)) 1232 logger.critical("Unable to import scheduler '%s' from '%s': %s" % (name, modname, exc))
1233 raise SystemExit(1) 1233 raise SystemExit(1)
1234 else: 1234 else:
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index 44b8e4d496..5c1044dd50 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -64,7 +64,7 @@ class EventAdapter():
64 def send(self, event): 64 def send(self, event):
65 try: 65 try:
66 self.queue.put(event) 66 self.queue.put(event)
67 except Exception, err: 67 except Exception as err:
68 print("EventAdapter puked: %s" % str(err)) 68 print("EventAdapter puked: %s" % str(err))
69 69
70 70
@@ -168,7 +168,7 @@ class ProcessServer(Process):
168 exitcode = 0 168 exitcode = 0
169 finally: 169 finally:
170 util._exit_function() 170 util._exit_function()
171 except SystemExit, e: 171 except SystemExit as e:
172 if not e.args: 172 if not e.args:
173 exitcode = 1 173 exitcode = 1
174 elif type(e.args[0]) is int: 174 elif type(e.args[0]) is int:
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index ecafe4f94d..2f488f4898 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -88,7 +88,7 @@ class PRServer(SimpleXMLRPCServer):
88 pid = os.fork() 88 pid = os.fork()
89 if pid > 0: 89 if pid > 0:
90 sys.exit(0) 90 sys.exit(0)
91 except OSError,e: 91 except OSError as e:
92 sys.stderr.write("1st fork failed: %d %s\n" % (e.errno, e.strerror)) 92 sys.stderr.write("1st fork failed: %d %s\n" % (e.errno, e.strerror))
93 sys.exit(1) 93 sys.exit(1)
94 94
@@ -101,7 +101,7 @@ class PRServer(SimpleXMLRPCServer):
101 pid = os.fork() 101 pid = os.fork()
102 if pid > 0: #parent 102 if pid > 0: #parent
103 sys.exit(0) 103 sys.exit(0)
104 except OSError,e: 104 except OSError as e:
105 sys.stderr.write("2nd fork failed: %d %s\n" % (e.errno, e.strerror)) 105 sys.stderr.write("2nd fork failed: %d %s\n" % (e.errno, e.strerror))
106 sys.exit(1) 106 sys.exit(1)
107 107
@@ -187,7 +187,7 @@ def stop_daemon():
187 while 1: 187 while 1:
188 os.kill(pid,signal.SIGTERM) 188 os.kill(pid,signal.SIGTERM)
189 time.sleep(0.1) 189 time.sleep(0.1)
190 except OSError, err: 190 except OSError as err:
191 err = str(err) 191 err = str(err)
192 if err.find("No such process") > 0: 192 if err.find("No such process") > 0:
193 if os.path.exists(PRServer.pidfile): 193 if os.path.exists(PRServer.pidfile):