提交 f51d808f 编写于 作者: L Lucas Meneghel Rodrigues

Merge pull request #548 from ldoktor/genio.2

 avocado: Exception handling bugfixes [v2]
......@@ -983,7 +983,7 @@ class Tail(Spawn):
if _thread_kill_requested:
try:
os.close(fd)
except:
except Exception:
pass
return
try:
......
......@@ -54,7 +54,7 @@ class ProgressStreamHandler(logging.StreamHandler):
self.flush()
except (KeyboardInterrupt, SystemExit):
raise
except:
except Exception:
self.handleError(record)
......@@ -89,13 +89,13 @@ class Paginator(object):
def close(self):
try:
self.pipe.close()
except:
except Exception:
pass
def write(self, msg):
try:
self.pipe.write(msg)
except:
except Exception:
pass
......
......@@ -421,7 +421,7 @@ class GDB(object):
# generated by the application being run inside the debugger
try:
parsed_response = parse_mi(line)
except:
except Exception:
cmd.application_output.append(line)
continue
......@@ -660,7 +660,7 @@ class GDBServer(object):
c.connect(self.port)
connection_ok = True
break
except:
except Exception:
time.sleep(0.1)
c.disconnect()
c.exit()
......
......@@ -17,16 +17,21 @@
Test loader module.
"""
import imp
import inspect
import os
import re
import sys
import imp
import inspect
from avocado import test
from avocado.core import data_dir
from avocado.utils import path
try:
import cStringIO as StringIO
except ImportError:
import StringIO
class _DebugJob(object):
......@@ -99,7 +104,11 @@ class TestLoader(object):
'base_logdir': self.job.logdir,
'params': params,
'job': self.job}
stdin, stdout, stderr = sys.stdin, sys.stdout, sys.stderr
try:
sys.stdin = None
sys.stdout = StringIO.StringIO()
sys.stderr = StringIO.StringIO()
f, p, d = imp.find_module(module_name, [test_module_dir])
test_module = imp.load_module(module_name, f, p, d)
f.close()
......@@ -135,7 +144,9 @@ class TestLoader(object):
# Since a lot of things can happen here, the broad exception is
# justified. The user will get it unadulterated anyway, and avocado
# will not crash.
except Exception, details:
except BaseException, details: # Ugly python files can raise any exc
if isinstance(details, KeyboardInterrupt):
raise # Don't ignore ctrl+c
if os.access(test_path, os.X_OK):
# Module can't be imported, and it's executable. Let's try to
# execute it.
......@@ -159,6 +170,10 @@ class TestLoader(object):
params['exception'] = details
else:
test_class = test.NotATest
finally:
sys.stdin = stdin
sys.stdout = stdout
sys.stderr = stderr
sys.path.pop(sys.path.index(test_module_dir))
......
......@@ -172,5 +172,7 @@ class TestList(plugin.Plugin):
self.view.notify(event='error', msg=msg)
else:
sys.stderr.write(msg)
self.view.cleanup()
finally:
if self.view:
self.view.cleanup()
sys.exit(rc)
......@@ -188,7 +188,7 @@ class Connection(object):
"""
try:
self.request('version')
except:
except Exception:
return False
return True
......
......@@ -89,7 +89,7 @@ def convert_value_type(value, value_type):
# strip off leading and trailing white space
try:
sval = value.strip()
except:
except Exception:
sval = value
if isinstance(value_type, str):
......
......@@ -147,7 +147,7 @@ def read_all_lines(filename):
try:
with open(filename, 'r') as file_obj:
contents = [line.rstrip('\n') for line in file_obj.readlines()]
except:
except Exception:
pass
return contents
......
......@@ -687,7 +687,7 @@ class GDBSubProcess(object):
try:
msgs = self.gdb.read_until_break()
messages += msgs
except:
except Exception:
pass
try:
......
"""
Please don't get inspired by this ugly code
"""
import sys
sys.stdout.write("Direct output to stdout\n")
sys.stderr.write("Direct output to stderr\n")
raw_input("I really want some input on each import")
sys.stdin = 'This is my __COOL__ stdin'
sys.stdout = 'my stdout'
sys.stderr = 'my stderr'
sys.exit(-1) # Exit even on import
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册