summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/pysh
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 /bitbake/lib/bb/pysh
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>
Diffstat (limited to 'bitbake/lib/bb/pysh')
-rw-r--r--bitbake/lib/bb/pysh/builtin.py10
-rw-r--r--bitbake/lib/bb/pysh/interp.py14
2 files changed, 12 insertions, 12 deletions
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