当前位置: 首页>>代码示例>>Python>>正文


Python sys.print_exception方法代码示例

本文整理汇总了Python中sys.print_exception方法的典型用法代码示例。如果您正苦于以下问题:Python sys.print_exception方法的具体用法?Python sys.print_exception怎么用?Python sys.print_exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sys的用法示例。


在下文中一共展示了sys.print_exception方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_state

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def load_state(self):
        """Verify file and load PIN state from it"""
        try:
            # verify that the pin file is ok
            _, data = self.load_aead(self.path+"/pin", self.secret)
            # load pin object
            data = json.loads(data.decode())
            self.pin = unhexlify(data["pin"]) if data["pin"] is not None else None
            self._pin_attempts_max = data["pin_attempts_max"]
            self._pin_attempts_left = data["pin_attempts_left"]
        except Exception as e:
            self.wipe(self.path)
            sys.print_exception(e)
            raise CriticalErrorWipeImmediately(
                "Something went terribly wrong!\nDevice is wiped!\n%s" % e
            ) 
开发者ID:cryptoadvance,项目名称:specter-diy,代码行数:18,代码来源:flash.py

示例2: board_name

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def board_name(default):
    """Returns the boards name (if available)."""
    try:
        import board
        try:
            name = board.name
        except AttributeError:
            # There was a board.py file, but it didn't have an name attribute
            # We also ignore this as an error
            name = default
    except ImportError:
        # No board.py file on the pyboard - not an error
        name = default
    except BaseException as err:
        print('Error encountered executing board.py')
        import sys
        sys.print_exception(err)
        name = default
    return repr(name) 
开发者ID:dhylands,项目名称:rshell,代码行数:21,代码来源:main.py

示例3: load_sinks

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def load_sinks(self, config) :
        if 'sinks' in config :
            ret = {}
            sink_configs = config['sinks']
            for name, config in sink_configs.items() :
                try :
                    sink_name = name + "_sink"
                    mod = __import__(sink_name, globals(), locals(), ['Sink'], 0)
                    ret[name] = mod.Sink(config)
                    print("loaded sink {}".format(name))
                except Exception as e :
                    print("Error: failed to load sink {} with config {}.  Error: {}".format(name, config, e))
                    sys.print_exception(e)
            return ret
        else :
            return {} 
开发者ID:fadushin,项目名称:esp8266,代码行数:18,代码来源:__init__.py

示例4: log

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def log(self, message) :
        try :
            print("{} [{}] {}: {}".format(
                message['datetime'], 
                message['level'], 
                message['name'], 
                message['message'])
            )
        except Exception as e :
            print("Error printing message:")
            sys.print_exception(e)
            print("begin message ==>")
            print(message['datetime'])
            print(message['level'])
            print(message['name'])
            print(message['message'])
            print("<=== end message") 
开发者ID:fadushin,项目名称:esp8266,代码行数:19,代码来源:console_sink.py

示例5: run

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def run(self):
        try:
            print("Welcome to ush-{}.  Type 'help' for help.  ^D to exit".format(VERSION))
            while True:
                line = Ush.prompt().strip()
                if line:
                    tokens = line.split()
                    cmd = tokens[0]
                    if cmd in self._handlers:
                        handler = self._handlers[cmd]
                        try:
                            handler.handle_command(tokens[1:])
                        except Exception as e:
                            sys.print_exception(e)
                    else:
                        print("Unknown command: {}".format(cmd))
        except Exception as e:
            print(e) 
开发者ID:fadushin,项目名称:esp8266,代码行数:20,代码来源:ush.py

示例6: update

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def update(self):
        if self.manager == None:
            return await asyncio.sleep_ms(100)
        if self.usb is None:
            return await asyncio.sleep_ms(100)
        if not platform.usb_connected():
            return await asyncio.sleep_ms(100)
        res = self.read_to_file()
        # if we got a filename - line is ready
        if res is not None:
            # first send the host that we are processing data
            self.usb.write(self.ACK)
            # open again for reading and try to process content
            try:
                with open(self.path+"/data", "rb") as f:
                    await self.process_command(f)
            # if we fail with host error - tell the host why we failed
            except HostError as e:
                self.respond(b"error: %s" % e)
                sys.print_exception(e)
            # for all other exceptions - send back generic message
            except Exception as e:
                self.respond(b"error: Unknown error")
                sys.print_exception(e)
            self.cleanup()

        # wait a bit
        await asyncio.sleep_ms(10) 
开发者ID:cryptoadvance,项目名称:specter-diy,代码行数:30,代码来源:usb.py

示例7: handle_exception

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def handle_exception(self, exception, next_fn):
        """
        Handle exception, show proper error message
        and return next function to call and await
        """
        try:
            raise exception
        except CriticalErrorWipeImmediately as e:
            # wipe all wallets
            self.wallet_manager.wipe()
            # show error
            await self.gui.error("%s" % e)
            # TODO: actual reboot here
            return self.setup
        # catch an expected error
        except BaseError as e:
            # show error
            await self.gui.alert(e.NAME, "%s" % e)
            # restart
            return next_fn
        # show trace for unexpected errors
        except Exception as e:
            print(e)
            b = BytesIO()
            sys.print_exception(e, b)
            await self.gui.error("Something unexpected happened...\n\n%s" % b.getvalue().decode())
            # restart
            return next_fn 
开发者ID:cryptoadvance,项目名称:specter-diy,代码行数:30,代码来源:specter.py

示例8: host_exception_handler

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def host_exception_handler(self, e):
        try:
            raise e
        except HostError as ex:
            msg = "%s" % ex
        except:
            b = BytesIO()
            sys.print_exception(e, b)
            msg = b.getvalue().decode()
        res = await self.gui.error(msg, popup=True) 
开发者ID:cryptoadvance,项目名称:specter-diy,代码行数:12,代码来源:specter.py

示例9: _handle_exception

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def _handle_exception(loop, context):
    print('Global handler')
    sys.print_exception(context["exception"])
    sys.exit()  # Drastic - loop.stop() does not work when used this way 
开发者ID:peterhinch,项目名称:micropython-iot,代码行数:6,代码来源:s_qos_cp.py

示例10: _handle_exception

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def _handle_exception(loop, context):
    print('Global handler')
    sys.print_exception(context["exception"])
    sys.exit() 
开发者ID:peterhinch,项目名称:micropython-iot,代码行数:6,代码来源:s_qos_fast.py

示例11: set_global_exception

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def set_global_exception():
    def _handle_exception(loop, context):
        import sys
        sys.print_exception(context["exception"])
        sys.exit()
    loop = asyncio.get_event_loop()
    loop.set_exception_handler(_handle_exception) 
开发者ID:peterhinch,项目名称:micropython-iot,代码行数:9,代码来源:__init__.py

示例12: exc

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def exc(self, e, msg, *args):
        self.log(ERROR, msg, *args)
        sys.print_exception(e, _stream) 
开发者ID:peterhinch,项目名称:micropython-samples,代码行数:5,代码来源:ulogging.py

示例13: log

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def log(self, level, format_str, *args) :
        if level in self._levels :
            try :
                message = self.create(level, format_str, *args)
            except Exception :
                print("WARNING: Error formatting log message.  Log will be delivered unformatted.")
                sys.print_exception(e)
                message = (level, format_str, args)
            for name, sink in self._sinks.items() :
                self.do_log(sink, message) 
开发者ID:fadushin,项目名称:esp8266,代码行数:12,代码来源:__init__.py

示例14: do_log

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def do_log(self, sink, message) :
        try :
            sink.log(message)
        except Exception as e :
            sys.print_exception(e) 
开发者ID:fadushin,项目名称:esp8266,代码行数:7,代码来源:__init__.py

示例15: internal_server_error

# 需要导入模块: import sys [as 别名]
# 或者: from sys import print_exception [as 别名]
def internal_server_error(writer, e):
        sys.print_exception(e)
        error_message = "Internal Server Error: {}".format(e)
        return (yield from Server.error(writer, 500, error_message, e)) 
开发者ID:fadushin,项目名称:esp8266,代码行数:6,代码来源:__init__.py


注:本文中的sys.print_exception方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。