當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。