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


Python sys.e方法代码示例

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


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

示例1: _handleLogError

# 需要导入模块: import sys [as 别名]
# 或者: from sys import e [as 别名]
def _handleLogError(self, msg, data, marker, pattern):
        print('')
        print('    ERROR: %s' % msg)

        if not self.interactive:
            raise pytest.fail(msg)

        p = ('    Show: '
             '[L]og [M]arker [P]attern; '
             '[I]gnore, [R]aise, or sys.e[X]it >> ')
        sys.stdout.write(p + ' ')
        # ARGH
        sys.stdout.flush()
        while True:
            i = getchar().upper()
            if i not in 'MPLIRX':
                continue
            print(i.upper())  # Also prints new line
            if i == 'L':
                for x, line in enumerate(data):
                    if (x + 1) % self.console_height == 0:
                        # The \r and comma should make the next line overwrite
                        sys.stdout.write('<-- More -->\r ')
                        m = getchar().lower()
                        # Erase our "More" prompt
                        sys.stdout.write('            \r ')
                        if m == 'q':
                            break
                    print(line.rstrip())
            elif i == 'M':
                print(repr(marker or self.lastmarker))
            elif i == 'P':
                print(repr(pattern))
            elif i == 'I':
                # return without raising the normal exception
                return
            elif i == 'R':
                raise pytest.fail(msg)
            elif i == 'X':
                self.exit()
            sys.stdout.write(p + ' ') 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:43,代码来源:logtest.py

示例2: _handleLogError

# 需要导入模块: import sys [as 别名]
# 或者: from sys import e [as 别名]
def _handleLogError(self, msg, data, marker, pattern):
        print('')
        print('    ERROR: %s' % msg)

        if not self.interactive:
            raise self.failureException(msg)

        p = ('    Show: '
             '[L]og [M]arker [P]attern; '
             '[I]gnore, [R]aise, or sys.e[X]it >> ')
        sys.stdout.write(p + ' ')
        # ARGH
        sys.stdout.flush()
        while True:
            i = getchar().upper()
            if i not in 'MPLIRX':
                continue
            print(i.upper())  # Also prints new line
            if i == 'L':
                for x, line in enumerate(data):
                    if (x + 1) % self.console_height == 0:
                        # The \r and comma should make the next line overwrite
                        sys.stdout.write('<-- More -->\r ')
                        m = getchar().lower()
                        # Erase our "More" prompt
                        sys.stdout.write('            \r ')
                        if m == 'q':
                            break
                    print(line.rstrip())
            elif i == 'M':
                print(repr(marker or self.lastmarker))
            elif i == 'P':
                print(repr(pattern))
            elif i == 'I':
                # return without raising the normal exception
                return
            elif i == 'R':
                raise self.failureException(msg)
            elif i == 'X':
                self.exit()
            sys.stdout.write(p + ' ') 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:43,代码来源:logtest.py

示例3: _handleLogError

# 需要导入模块: import sys [as 别名]
# 或者: from sys import e [as 别名]
def _handleLogError(self, msg, data, marker, pattern):
        print("")
        print("    ERROR: %s" % msg)
        
        if not self.interactive:
            raise self.failureException(msg)
        
        p = "    Show: [L]og [M]arker [P]attern; [I]gnore, [R]aise, or sys.e[X]it >> "
        sys.stdout.write(p + ' ')
        # ARGH
        sys.stdout.flush()
        while True:
            i = getchar().upper()
            if i not in "MPLIRX":
                continue
            print(i.upper())  # Also prints new line
            if i == "L":
                for x, line in enumerate(data):
                    if (x + 1) % self.console_height == 0:
                        # The \r and comma should make the next line overwrite
                        sys.stdout.write("<-- More -->\r ")
                        m = getchar().lower()
                        # Erase our "More" prompt
                        sys.stdout.write("            \r ")
                        if m == "q":
                            break
                    print(line.rstrip())
            elif i == "M":
                print(repr(marker or self.lastmarker))
            elif i == "P":
                print(repr(pattern))
            elif i == "I":
                # return without raising the normal exception
                return
            elif i == "R":
                raise self.failureException(msg)
            elif i == "X":
                self.exit()
            sys.stdout.write(p + ' ') 
开发者ID:binhex,项目名称:moviegrabber,代码行数:41,代码来源:logtest.py

示例4: _handlewebError

# 需要导入模块: import sys [as 别名]
# 或者: from sys import e [as 别名]
def _handlewebError(self, msg):
        print('')
        print('    ERROR: %s' % msg)

        if not self.interactive:
            raise self.failureException(msg)

        p = (
            '    Show: '
            '[B]ody [H]eaders [S]tatus [U]RL; '
            '[I]gnore, [R]aise, or sys.e[X]it >> '
        )
        sys.stdout.write(p)
        sys.stdout.flush()
        while True:
            i = getchar().upper()
            if not isinstance(i, type('')):
                i = i.decode('ascii')
            if i not in 'BHSUIRX':
                continue
            print(i.upper())  # Also prints new line
            if i == 'B':
                for x, line in enumerate(self.body.splitlines()):
                    if (x + 1) % self.console_height == 0:
                        # The \r and comma should make the next line overwrite
                        sys.stdout.write('<-- More -->\r')
                        m = getchar().lower()
                        # Erase our "More" prompt
                        sys.stdout.write('            \r')
                        if m == 'q':
                            break
                    print(line)
            elif i == 'H':
                pprint.pprint(self.headers)
            elif i == 'S':
                print(self.status)
            elif i == 'U':
                print(self.url)
            elif i == 'I':
                # return without raising the normal exception
                return
            elif i == 'R':
                raise self.failureException(msg)
            elif i == 'X':
                sys.exit()
            sys.stdout.write(p)
            sys.stdout.flush() 
开发者ID:cherrypy,项目名称:cheroot,代码行数:49,代码来源:webtest.py

示例5: _handlewebError

# 需要导入模块: import sys [as 别名]
# 或者: from sys import e [as 别名]
def _handlewebError(self, msg):
        print('')
        print('    ERROR: %s' % msg)

        if not self.interactive:
            raise self.failureException(msg)

        p = ('    Show: '
             '[B]ody [H]eaders [S]tatus [U]RL; '
             '[I]gnore, [R]aise, or sys.e[X]it >> ')
        sys.stdout.write(p)
        sys.stdout.flush()
        while True:
            i = getchar().upper()
            if not isinstance(i, type('')):
                i = i.decode('ascii')
            if i not in 'BHSUIRX':
                continue
            print(i.upper())  # Also prints new line
            if i == 'B':
                for x, line in enumerate(self.body.splitlines()):
                    if (x + 1) % self.console_height == 0:
                        # The \r and comma should make the next line overwrite
                        sys.stdout.write('<-- More -->\r')
                        m = getchar().lower()
                        # Erase our "More" prompt
                        sys.stdout.write('            \r')
                        if m == 'q':
                            break
                    print(line)
            elif i == 'H':
                pprint.pprint(self.headers)
            elif i == 'S':
                print(self.status)
            elif i == 'U':
                print(self.url)
            elif i == 'I':
                # return without raising the normal exception
                return
            elif i == 'R':
                raise self.failureException(msg)
            elif i == 'X':
                self.exit()
            sys.stdout.write(p)
            sys.stdout.flush() 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:47,代码来源:webtest.py

示例6: openURL

# 需要导入模块: import sys [as 别名]
# 或者: from sys import e [as 别名]
def openURL(url, headers=None, method='GET', body=None,
            host='127.0.0.1', port=8000, http_conn=HTTPConnection,
            protocol='HTTP/1.1', raise_subcls=None):
    """
    Open the given HTTP resource and return status, headers, and body.

    `raise_subcls` must be a tuple with the exceptions classes
    or a single exception class that are not going to be considered
    a socket.error regardless that they were are subclass of a
    socket.error and therefore not considered for a connection retry.
    """
    headers = cleanHeaders(headers, method, body, host, port)

    # Trying 10 times is simply in case of socket errors.
    # Normal case--it should run once.
    for trial in range(10):
        try:
            # Allow http_conn to be a class or an instance
            if hasattr(http_conn, 'host'):
                conn = http_conn
            else:
                conn = http_conn(interface(host), port)

            conn._http_vsn_str = protocol
            conn._http_vsn = int(''.join([x for x in protocol if x.isdigit()]))

            if six.PY3 and isinstance(url, bytes):
                url = url.decode()
            conn.putrequest(method.upper(), url, skip_host=True,
                            skip_accept_encoding=True)

            for key, value in headers:
                conn.putheader(key, value.encode('Latin-1'))
            conn.endheaders()

            if body is not None:
                conn.send(body)

            # Handle response
            response = conn.getresponse()

            s, h, b = shb(response)

            if not hasattr(http_conn, 'host'):
                # We made our own conn instance. Close it.
                conn.close()

            return s, h, b
        except socket.error as e:
            if raise_subcls is not None and isinstance(e, raise_subcls):
                raise
            else:
                time.sleep(0.5)
                if trial == 9:
                    raise




# Add any exceptions which your web framework handles
# normally (that you don't want server_error to trap). 
开发者ID:morpheus65535,项目名称:bazarr,代码行数:63,代码来源:webtest.py

示例7: _handlewebError

# 需要导入模块: import sys [as 别名]
# 或者: from sys import e [as 别名]
def _handlewebError(self, msg):
        print("")
        print("    ERROR: %s" % msg)

        if not self.interactive:
            raise self.failureException(msg)

        p = "    Show: [B]ody [H]eaders [S]tatus [U]RL; [I]gnore, [R]aise, or sys.e[X]it >> "
        sys.stdout.write(p)
        sys.stdout.flush()
        while True:
            i = getchar().upper()
            if not isinstance(i, type("")):
                i = i.decode('ascii')
            if i not in "BHSUIRX":
                continue
            print(i.upper())  # Also prints new line
            if i == "B":
                for x, line in enumerate(self.body.splitlines()):
                    if (x + 1) % self.console_height == 0:
                        # The \r and comma should make the next line overwrite
                        sys.stdout.write("<-- More -->\r")
                        m = getchar().lower()
                        # Erase our "More" prompt
                        sys.stdout.write("            \r")
                        if m == "q":
                            break
                    print(line)
            elif i == "H":
                pprint.pprint(self.headers)
            elif i == "S":
                print(self.status)
            elif i == "U":
                print(self.url)
            elif i == "I":
                # return without raising the normal exception
                return
            elif i == "R":
                raise self.failureException(msg)
            elif i == "X":
                self.exit()
            sys.stdout.write(p)
            sys.stdout.flush() 
开发者ID:binhex,项目名称:moviegrabber,代码行数:45,代码来源:webtest.py


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