예제 #1
0
def run_uprint(text):
    """
    Invoke _uprint() on the text and print any exception that may be raised.
    """
    try:
        _uprint(None, text)
    except Exception as exc:  # pylint: disable=broad-except
        print("Error: %s raised by: _uprint(None, %r)" %
              (exc.__class__.__name__, text),
              file=sys.stderr)
        print_debug_info()
        sys.stderr.flush()
        raise
예제 #2
0
파일: run_uprint.py 프로젝트: tony23/pywbem
def main():
    """Main routine"""

    if len(sys.argv) > 1:
        mode = sys.argv[1]  # 'small', 'ucs2', 'all'
    else:
        mode = 'small'

    print("Debug: mode=%s; sys.stdout: isatty=%r, encoding=%r" %
          (mode, sys.stdout.isatty(), getattr(sys.stdout, 'encoding', None)),
          file=sys.stderr)
    print(
        "Debug: sys.getfilesystemencoding=%r locale.getpreferredencoding=%r" %
        (sys.getfilesystemencoding(), locale.getpreferredencoding()),
        file=sys.stderr)

    if mode == 'small':
        test_string = u'\u212b \u0420 \u043e \u0441 \u0441 \u0438 \u044f \u00e0'
        _uprint(None, test_string)
    elif mode == 'ucs2':
        for cp in six.moves.xrange(0, 0xFFFF):
            test_string = six.unichr(cp)
            _uprint(None, test_string)
    elif mode == 'all':
        test_string = u''
        if sys.maxunicode < 0x10FFFF:
            print("Info: Testing Unicode range of only up to U+%.6X "
                  "(out of U+10FFFF)" % sys.maxunicode,
                  file=sys.stderr)
        for cp in six.moves.xrange(0, sys.maxunicode):
            test_string = six.unichr(cp)
            _uprint(None, test_string)