Python sys.exc_type() Examples
The following are 30
code examples of sys.exc_type().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sys
, or try the search function
.
Example #1
Source File: errors.py From kotori with GNU Affero General Public License v3.0 | 6 votes |
def traceback_get_exception(num = -1): # build error message exception_string = ''.join(traceback.format_exception_only(sys.exc_type, hasattr(sys, 'exc_value') and sys.exc_value or 'Unknown')) # extract error location from traceback if hasattr(sys, 'exc_traceback'): (filename, line_number, function_name, text) = traceback.extract_tb(sys.exc_traceback)[num] else: (filename, line_number, function_name, text) = ('-', '-', '-', '-') error = { 'message': exception_string, 'location': { 'filename': filename, 'line_number': line_number, 'function_name': function_name, 'text': text, } } return error
Example #2
Source File: sbs_typeop.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_set(self): side1 = [ None, set(), set('a'), set('abc'), set('bde')] for x in side1: for y in side1: for func in funclist2: try: printwith("case", case_repr(x, y, func)); res = func(x, y) printwith("case", res) if isinstance(res, set): for c in 'abcde': printwith("same", c in res) else: printwith("same", res) except: printwith("same", sys.exc_type)
Example #3
Source File: UTscapy.py From CyberScan with GNU General Public License v3.0 | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #4
Source File: test_exceptions.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_str2(self): # verify we can assign to sys.exc_* sys.exc_traceback = None sys.exc_value = None sys.exc_type = None self.assertEqual(str(Exception()), '') @skipUnlessIronPython() def test_array(self): import System try: a = System.Array() except Exception, e: self.assertEqual(e.__class__, TypeError) else:
Example #5
Source File: UTscapy.py From smod-1 with GNU General Public License v2.0 | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #6
Source File: UTscapy.py From CVE-2016-6366 with MIT License | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #7
Source File: UTscapy.py From mptcp-abuse with GNU General Public License v2.0 | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #8
Source File: test_isinstance.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_reload_sys(self): import sys (old_copyright, old_byteorder) = (sys.copyright, sys.byteorder) (sys.copyright, sys.byteorder) = ("foo", "foo") (old_argv, old_exc_type) = (sys.argv, sys.exc_type) (sys.argv, sys.exc_type) = ("foo", "foo") reloaded_sys = reload(sys) # Most attributes get reset self.assertEqual((old_copyright, old_byteorder), (reloaded_sys.copyright, reloaded_sys.byteorder)) # Some attributes are not reset self.assertEqual((reloaded_sys.argv, reloaded_sys.exc_type), ("foo", "foo")) # Put back the original values (sys.copyright, sys.byteorder) = (old_copyright, old_byteorder) (sys.argv, sys.exc_type) = (old_argv, old_exc_type)
Example #9
Source File: manage_dirty.py From browserscope with Apache License 2.0 | 6 votes |
def ScheduleCategoryUpdate(result_parent_key): """Add a task to update a category's statistics. The task is handled by base.admin.UpdateCategory which then calls UpdateCategory below. """ # Give the task a name to ensure only one task for each ResultParent. result_parent = ResultParent.get(result_parent_key) category = result_parent.category name = 'categoryupdate-%s' % str(result_parent_key).replace('_', '-under-') url = '/_ah/queue/update-category/%s/%s' % (category, result_parent_key) task = taskqueue.Task(url=url, name=name, params={ 'category': category, 'user_agent_key': result_parent.user_agent.key(), }) attempt = 0 while attempt < 3: try: task.add(queue_name='update-category') break except: attempt += 1 logging.info('Cannot add task(attempt %s): %s:%s' % (attempt, sys.exc_type, sys.exc_value))
Example #10
Source File: UTscapy.py From dash-hack with MIT License | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #11
Source File: UTscapy.py From dash-hack with MIT License | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #12
Source File: UTscapy.py From isip with MIT License | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #13
Source File: UTscapy.py From dash-hack with MIT License | 6 votes |
def run_campaign(test_campaign, get_interactive_session, verb=2): passed=failed=0 if test_campaign.preexec: test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0] for testset in test_campaign: for t in testset: t.output,res = get_interactive_session(t.test.strip()) the_res = False try: if res is None or res: the_res= True except Exception,msg: t.output+="UTscapy: Error during result interpretation:\n" t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,)) if the_res: t.res = True res = "passed" passed += 1 else: t.res = False res = "failed" failed += 1 t.result = res if verb > 1: print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t
Example #14
Source File: Tkinter.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _report_exception(self): """Internal function.""" import sys exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback root = self._root() root.report_callback_exception(exc, val, tb)
Example #15
Source File: test_fixers.py From Imogen with MIT License | 5 votes |
def test_3(self): b = "sys.exc_type # Foo" a = "sys.exc_info()[0] # Foo" self.check(b, a)
Example #16
Source File: compat.py From python-for-android with Apache License 2.0 | 5 votes |
def formatExceptionTrace(e): newStr = "".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) return newStr
Example #17
Source File: test_fixers.py From datafari with Apache License 2.0 | 5 votes |
def test_3(self): b = "sys.exc_type # Foo" a = "sys.exc_info()[0] # Foo" self.check(b, a)
Example #18
Source File: test_fixers.py From datafari with Apache License 2.0 | 5 votes |
def test_4(self): b = "sys. exc_type" a = "sys. exc_info()[0]" self.check(b, a)
Example #19
Source File: test_fixers.py From datafari with Apache License 2.0 | 5 votes |
def test_5(self): b = "sys .exc_type" a = "sys .exc_info()[0]" self.check(b, a)
Example #20
Source File: traceback.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def print_exc(limit=None, file=None): """Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'. (In fact, it uses sys.exc_info() to retrieve the same information in a thread-safe way.)""" if file is None: file = sys.stderr try: etype, value, tb = sys.exc_info() print_exception(etype, value, tb, limit, file) finally: etype = value = tb = None
Example #21
Source File: test_fixers.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_3(self): b = "sys.exc_type # Foo" a = "sys.exc_info()[0] # Foo" self.check(b, a)
Example #22
Source File: test_fixers.py From Imogen with MIT License | 5 votes |
def test_0(self): b = "sys.exc_type" a = "sys.exc_info()[0]" self.check(b, a)
Example #23
Source File: test_fixers.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_5(self): b = "sys .exc_type" a = "sys .exc_info()[0]" self.check(b, a)
Example #24
Source File: test_fixers.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_4(self): b = "sys. exc_type" a = "sys. exc_info()[0]" self.check(b, a)
Example #25
Source File: test_fixers.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_3(self): b = "sys.exc_type # Foo" a = "sys.exc_info()[0] # Foo" self.check(b, a)
Example #26
Source File: test_fixers.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_0(self): b = "sys.exc_type" a = "sys.exc_info()[0]" self.check(b, a)
Example #27
Source File: report_aeroo.py From LibrERP with GNU Affero General Public License v3.0 | 5 votes |
def _raise_exception(self, e, print_id): tb_s = reduce(lambda x, y: x + y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) _logger.error(_("Report generation error!") + '\n' + tb_s) # subreports = self.oo_subreports.get(print_id, []) aeroo_print = self.active_prints.get(print_id, []) if aeroo_print: for sub_report in aeroo_print.subreports: if os.path.isfile(sub_report): os.unlink(sub_report) raise Exception(_("Aeroo Reports: Error while generating the report."), e, str(e), _("For more reference inspect error logs."))
Example #28
Source File: traceback.py From pmatic with GNU General Public License v2.0 | 5 votes |
def print_exc(limit=None, file=None): """Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'. (In fact, it uses sys.exc_info() to retrieve the same information in a thread-safe way.)""" if file is None: file = sys.stderr try: etype, value, tb = sys.exc_info() print_exception(etype, value, tb, limit, file) finally: etype = value = tb = None
Example #29
Source File: idaxml.py From GhIDA with Apache License 2.0 | 5 votes |
def import_bookmark(self, bookmark): """ Processes a BOOKMARK element. Args: bookmark: XML element object containing bookmark data. """ if self.options.Bookmarks.checked == False: return try: addr = self.get_address(bookmark, ADDRESS) if self.has_attribute(bookmark, TYPE): typ = self.get_attribute(bookmark, TYPE) category = '' if self.has_attribute(bookmark, CATEGORY): category = self.get_attribute(bookmark, CATEGORY) description = '' if self.has_attribute(bookmark, DESCRIPTION): description = self.get_attribute(bookmark, DESCRIPTION) if idc.is_mapped(addr) == False: msg = ("import_bookmark: address %X not enabled in database" % addr) print(msg) return self.update_counter(BOOKMARK) for slot in range(ida_moves.MAX_MARK_SLOT): ea = idc.get_bookmark(slot) if ea == BADADDR: idc.put_bookmark(addr, 0, 0, 0, slot, description) break except: msg = "** Exception occurred in import_bookmark **" print("\n" + msg + "\n", sys.exc_type, sys.exc_value)
Example #30
Source File: debug.py From gprime with GNU General Public License v2.0 | 5 votes |
def format_exception(tb_type=None, tb_value=None, tb=None): """ Get the usual traceback information, followed by a listing of all the local variables in each frame. Based on: code.activestate.com/recipes/52215-get-more-information-from-tracebacks """ import sys import traceback if tb_type is None: tb_type = sys.exc_type if tb_value is None: tb_value = sys.exc_value if tb is None: tb = sys.exc_info()[2] retval = traceback.format_exception(tb_type, tb_value, tb) + ["\n"] while tb.tb_next: tb = tb.tb_next stack = [] f = tb.tb_frame while f: stack.append(f) f = f.f_back stack.reverse() retval.append("Local variables (most recent frame last):\n") for frame in stack: retval.append(" Frame %s, File \"%s\", line %s:\n" % (frame.f_code.co_name, frame.f_code.co_filename, frame.f_lineno)) for key, value in frame.f_locals.items(): if key.startswith("__"): continue #We have to be careful not to cause a new error in our error #handler! Calling str() on an unknown object could cause an #error we don't want. try: line = " %s = %s\n" % (key, str(value)) except: line = " %s = %s\n" % (key, "<ERROR PRINTING VALUE>") retval.append(line) return retval