sys.flags.verbose

Here are the examples of the python api sys.flags.verbose taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

56 Examples 7

Example 51

Project: neuroConstruct
Source File: site.py
View license
def execsitecustomize():
    """Run custom site specific code, if available."""
    try:
        import sitecustomize
    except ImportError:
        pass
    except Exception:
        if sys.flags.verbose:
            sys.excepthook(*sys.exc_info())
        else:
            print >>sys.stderr, \
                "'import sitecustomize' failed; use -v for traceback"

Example 52

Project: neuroConstruct
Source File: site.py
View license
def execusercustomize():
    """Run custom user specific code, if available."""
    try:
        import usercustomize
    except ImportError:
        pass
    except Exception:
        if sys.flags.verbose:
            sys.excepthook(*sys.exc_info())
        else:
            print>>sys.stderr, \
                "'import usercustomize' failed; use -v for traceback"

Example 53

Project: PyAutoC
Source File: site.py
View license
def execsitecustomize():
    """Run custom site specific code, if available."""
    try:
        import sitecustomize
    except ImportError:
        pass
    except Exception:
        if sys.flags.verbose:
            sys.excepthook(*sys.exc_info())
        else:
            print >>sys.stderr, \
                "'import sitecustomize' failed; use -v for traceback"

Example 54

Project: PyAutoC
Source File: site.py
View license
def execusercustomize():
    """Run custom user specific code, if available."""
    try:
        import usercustomize
    except ImportError:
        pass
    except Exception:
        if sys.flags.verbose:
            sys.excepthook(*sys.exc_info())
        else:
            print>>sys.stderr, \
                "'import usercustomize' failed; use -v for traceback"

Example 55

Project: pygtk-installer
Source File: __init__.py
View license
def _putenv(name, value):
    '''
    :param name: environment variable name
    :param value: environment variable value

    This function ensures that changes to an environment variable are applied
    to each copy of the environment variables used by a process. Starting from
    Python 2.4, os.environ changes only apply to the copy Python keeps (os.environ)
    and are no longer automatically applied to the other copies for the process.

    On Microsoft Windows, each process has multiple copies of the environment
    variables, one managed by the OS and one managed by the C library. We also
    need to take care of the fact that the C library used by Python is not
    necessarily the same as the C library used by PyGTK and friends. This because
    the latest releases of PyGTK and friends are built with mingw32 and are thus
    linked against msvcrt.dll. The official GTK+ binaries have always been built
    in this way.
    '''

    # Update Python's copy of the environment variables
    os.environ[name] = value

    # Update the copy maintained by Windows (so SysInternals Process Explorer sees it)
    try:
        result = windll.kernel32.SetEnvironmentVariableW(c_wchar_p(name), c_wchar_p(value))
        if result == 0: raise Warning
    except Exception:
        if sys.flags.verbose:
            sys.stderr.write('* pygtk-runtime: "kernel32.SetEnvironmentVariableW" failed\n')
            sys.stderr.flush()
    else:
        if sys.flags.verbose:
            sys.stderr.write('* pygtk-runtime: "kernel32.SetEnvironmentVariableW" successful\n')
            sys.stderr.flush()

    # Update the copy maintained by msvcrt (used by GTK+ runtime)
    try:
        result = cdll.msvcrt._putenv('%s=%s' % (name, value))
        if result != 0: raise Warning
    except Exception:
        if sys.flags.verbose:
            sys.stderr.write('* pygtk-runtime: "msvcrt._putenv" failed\n')
            sys.stderr.flush()
    else:
        if sys.flags.verbose:
            sys.stderr.write('* pygtk-runtime: "msvcrt._putenv" successful\n')
            sys.stderr.flush()

    # Update the copy maintained by whatever c runtime is used by Python
    try:
        msvcrt = find_msvcrt()
        msvcrtname = str(msvcrt).split('.')[0] if '.' in msvcrt else str(msvcrt)
        result = cdll.LoadLibrary(msvcrt)._putenv('%s=%s' % (name, value))
        if result != 0: raise Warning
    except Exception:
        if sys.flags.verbose:
            sys.stderr.write('* pygtk-runtime: "%s._putenv" failed\n' % msvcrtname)
            sys.stderr.flush()
    else:
        if sys.flags.verbose:
            sys.stderr.write('* pygtk-runtime: "%s._putenv" successful\n' % msvcrtname)
            sys.stderr.flush()

Example 56

Project: fatoptimizer
Source File: __init__.py
View license
    def ast_transformer(self, tree, context):
        filename = context.filename
        if sys.flags.verbose and not filename.startswith('<'):
            print("# run fatoptimizer on %s" % filename, file=sys.stderr)
        return optimize(tree, context.filename, self.config)