本文整理汇总了Python中traceback.print_exc方法的典型用法代码示例。如果您正苦于以下问题:Python traceback.print_exc方法的具体用法?Python traceback.print_exc怎么用?Python traceback.print_exc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类traceback
的用法示例。
在下文中一共展示了traceback.print_exc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getReadOut
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def getReadOut(self):
#pylint: disable=unidiomatic-typecheck, broad-except
for it in self.client.objects:
if type(it) == GXDLMSObject:
print("Unknown Interface: " + it.objectType.__str__())
continue
if isinstance(it, GXDLMSProfileGeneric):
continue
self.writeTrace("-------- Reading " + str(it.objectType) + " " + str(it.name) + " " + it.description, TraceLevel.INFO)
for pos in (it).getAttributeIndexToRead(True):
try:
val = self.read(it, pos)
self.showValue(pos, val)
except Exception as ex:
self.writeTrace("Error! Index: " + str(pos) + " " + str(ex), TraceLevel.ERROR)
self.writeTrace(str(ex), TraceLevel.ERROR)
if not isinstance(ex, (GXDLMSException, TimeoutException)):
traceback.print_exc()
示例2: refresh
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def refresh(self):
try:
#open the data url
self.req = urlopen(self.data_url)
#read data from the url
self.raw_data = self.req.read()
#load in the json
self.json_data = json.loads(self.raw_data.decode())
#get time from json
self.time = datetime.fromtimestamp(self.parser.time(self.json_data))
#load all the aircarft
self.aircraft = self.parser.aircraft_data(self.json_data, self.time)
except Exception:
print("exception in FlightData.refresh():")
traceback.print_exc()
示例3: cron_task_host
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def cron_task_host():
"""定时任务宿主, 每分钟检查一次列表, 运行时间到了的定时任务"""
while True:
# 当全局开关关闭时, 自动退出线程
if not enable_cron_tasks:
if threading.current_thread() != threading.main_thread():
exit()
else:
return
sleep(60)
try:
task_scheduler.run()
except: # coverage: exclude
errprint('ErrorDuringExecutingCronTasks')
traceback.print_exc()
示例4: test_import_error_custom_func
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def test_import_error_custom_func(self):
restore_config_file()
try:
shutil.copy(zmirror_file('config_default.py'), zmirror_file('config.py'))
try:
self.reload_zmirror({"custom_text_rewriter_enable": True,
"enable_custom_access_cookie_generate_and_verify": True,
"identity_verify_required": True,
})
except:
import traceback
traceback.print_exc()
os.remove(zmirror_file('config.py'))
except:
pass
copy_default_config_file()
示例5: launch
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def launch(args,q_in,q_out):
try:
parser=parser_lib.NetworkParserWrapper(args.model,args.parser_dir)
except:
traceback.print_exc()
sys.stderr.flush()
while True:
jobid,txt=q_in.get()
if jobid=="FINAL":
q_out.put((jobid,txt))
return
try:
conllu=parser.parse_text(txt)
if args.process_morpho == True:
conllu=process_batch(conllu, detransfer=True)
q_out.put((jobid,conllu))
except:
traceback.print_exc()
sys.stderr.flush()
示例6: test_format_docstrings
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def test_format_docstrings():
"""
Test if docstrings are well formatted.
"""
# Disabled for now
return True
try:
verify_format_docstrings()
except SkipTest as e:
import traceback
traceback.print_exc(e)
raise AssertionError(
"Some file raised SkipTest on import, and inadvertently"
" canceled the documentation testing."
)
示例7: install_syslinux
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def install_syslinux(self):
try:
try:
self.install_syslinux_impl()
finally:
config.process_exist = None
self.ui_enable_controls()
except (KeyboardInterrupt, SystemExit):
raise
except:
uninstall_distro.do_uninstall_distro(
config.distro, iso_basename(config.image_path))
o = io.StringIO()
traceback.print_exc(None, o)
QtWidgets.QMessageBox.information(
self, 'install_syslinux() failed',
o.getvalue())
log("install_syslinux() failed.")
log(o.getvalue())
示例8: main
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def main():
'''Entry-point function for the cookiejar Transaction Processor.'''
try:
# Setup logging for this class.
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
# Register the Transaction Handler and start it.
processor = TransactionProcessor(url=DEFAULT_URL)
sw_namespace = _hash(FAMILY_NAME.encode('utf-8'))[0:6]
handler = CookieJarTransactionHandler(sw_namespace)
processor.add_handler(handler)
processor.start()
except KeyboardInterrupt:
pass
except SystemExit as err:
raise err
except BaseException as err:
traceback.print_exc(file=sys.stderr)
sys.exit(1)
示例9: main
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def main():
'''Entry point function for the client CLI.'''
filters = [events_pb2.EventFilter(key="address",
match_string=
COOKIEJAR_TP_ADDRESS_PREFIX + ".*",
filter_type=events_pb2.
EventFilter.REGEX_ANY)]
try:
# To listen to all events, pass delta_filters=None :
#listen_to_events(delta_filters=None)
listen_to_events(delta_filters=filters)
except KeyboardInterrupt:
pass
except SystemExit as err:
raise err
except BaseException as err:
traceback.print_exc(file=sys.stderr)
sys.exit(1)
示例10: test
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def test():
gitter = Gitter(
token="",
rooms=(
"57397795c43b8c60197322b9",
"5739b957c43b8c6019732c0b",
),
me=''
)
def response(msg):
print(msg)
gitter.send_msg(
target=msg.receiver, content=msg.content, sender="fishroom")
gitter.send_to_bus = response
try:
gitter.listen_message_stream(id_blacklist=("master_tuna_twitter", ))
except Exception:
import traceback
traceback.print_exc()
示例11: post_one
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def post_one(self, query=None, frmt='json', **kargs):
self._calls()
self.logging.debug("BioServices:: Entering post_one function")
if query is None:
url = self.url
else:
url = '%s/%s' % (self.url, query)
self.logging.debug(url)
try:
res = self.session.post(url, **kargs)
self.last_response = res
res = self._interpret_returned_request(res, frmt)
try:
return res.decode()
except:
self.logging.debug("BioServices:: Could not decode the response")
return res
except Exception as err:
traceback.print_exc()
return None
示例12: on_error
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def on_error(context: TurnContext, error: Exception):
# This check writes out errors to console log .vs. app insights.
# NOTE: In production environment, you should consider logging this to Azure
# application insights.
print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
traceback.print_exc()
# Send a message to the user
await context.send_activity("The bot encountered an error or bug.")
await context.send_activity(
"To continue to run this bot, please fix the bot source code."
)
# Send a trace activity if we're talking to the Bot Framework Emulator
if context.activity.channel_id == "emulator":
# Create a trace activity that contains the error object
trace_activity = Activity(
label="TurnError",
name="on_turn_error Trace",
timestamp=datetime.utcnow(),
type=ActivityTypes.trace,
value=f"{error}",
value_type="https://www.botframework.com/schemas/error",
)
# Send a trace activity, which will be displayed in Bot Framework Emulator
await context.send_activity(trace_activity)
示例13: update_database
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def update_database(self, field, value):
"""
Update a given field in the database.
"""
ret = True
if self.database:
try:
cur = self.database.cursor()
cur.execute("UPDATE image SET " + field + "='" + value +
"' WHERE id=%s", (self.tag, ))
self.database.commit()
except BaseException:
ret = False
traceback.print_exc()
self.database.rollback()
finally:
if cur:
cur.close()
return ret
示例14: handle_read
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def handle_read(self, data, address, rtime, delayed = False):
if len(data) > 0 and self.uopts.data_callback != None:
self.stats[2] += 1
if self.uopts.ploss_in_rate > 0.0 and not delayed:
if random() < self.uopts.ploss_in_rate:
return
if self.uopts.pdelay_in_max > 0.0 and not delayed:
pdelay = self.uopts.pdelay_in_max * random()
Timeout(self.handle_read, pdelay, 1, data, address, rtime.getOffsetCopy(pdelay), True)
return
try:
self.uopts.data_callback(data, address, self, rtime)
except Exception as ex:
if isinstance(ex, SystemExit):
raise
print(datetime.now(), 'Udp_server: unhandled exception when processing incoming data')
print('-' * 70)
traceback.print_exc(file = sys.stdout)
print('-' * 70)
sys.stdout.flush()
示例15: set_trace
# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_exc [as 别名]
def set_trace():
"""Call pdb.set_trace in the caller's frame.
First restore sys.stdout and sys.stderr. Note that the streams are
NOT reset to whatever they were before the call once pdb is done!
"""
import pdb
for stream in 'stdout', 'stderr':
output = getattr(sys, stream)
orig_output = getattr(sys, '__%s__' % stream)
if output != orig_output:
# Flush the output before entering pdb
if hasattr(output, 'getvalue'):
orig_output.write(output.getvalue())
orig_output.flush()
setattr(sys, stream, orig_output)
exc, tb = sys.exc_info()[1:]
if tb:
if isinstance(exc, AssertionError) and exc.args:
# The traceback is not printed yet
print_exc()
pdb.post_mortem(tb)
else:
pdb.Pdb().set_trace(sys._getframe().f_back)