Esempio n. 1
0
def get_pkg_description(metadata):
    """
    Returns the long description text for the given package metadata, based
    off its ``README.txt`` or package ``__init__.py`` file and changelog.
    Assumes we're running this within a package root.

    Parameters
    ----------
    metadata : `dict`
        Package metadata dictionary as returned from `parse_metadata`
    """
    # XXX Not yet working, something wrong with the imports :(
    return ''

    readme = ''
    try:
        readme = open('README.txt').read()
    except IOError:
        # Need to handle this gracefully, this function gets called when
        # bootstrapping pkglib, importlib might not exist at this point.
        try:
            import importlib
        except ImportError:
            distutils.log().warn("Can't find importlib to read package description.")
        else:
            mod = importlib.import_module(metadata['name'])
            readme = mod.__doc__
    try:
        changes = open('CHANGES.txt').read()
    except IOError:
        changes = ''
    return readme + '\n\n' + changes
Esempio n. 2
0
    def finalize_options(self):
        sdist.finalize_options(self)
        if 'SKIP_BOOTSTRAP_DOWNLOAD' in os.environ:
            log('Please stop using \'SKIP_BOOTSTRAP_DOWNLOAD\' and use '
                '\'DOWNLOAD_BOOTSTRAP_SCRIPT\' instead')

        if 'DOWNLOAD_BOOTSTRAP_SCRIPT' in os.environ:
            download_bootstrap_script = os.environ.get(
                'DOWNLOAD_BOOTSTRAP_SCRIPT', '0')
            self.download_bootstrap_script = download_bootstrap_script == '1'
Esempio n. 3
0
File: setup.py Progetto: iquaba/salt
    def finalize_options(self):
        Sdist.finalize_options(self)
        if 'SKIP_BOOTSTRAP_DOWNLOAD' in os.environ:
            log('Please stop using \'SKIP_BOOTSTRAP_DOWNLOAD\' and use '
                '\'DOWNLOAD_BOOTSTRAP_SCRIPT\' instead')

        if 'DOWNLOAD_BOOTSTRAP_SCRIPT' in os.environ:
            download_bootstrap_script = os.environ.get(
                'DOWNLOAD_BOOTSTRAP_SCRIPT', '0'
            )
            self.download_bootstrap_script = download_bootstrap_script == '1'
Esempio n. 4
0
    def finalize_options(self):
        Sdist.finalize_options(self)
        if "SKIP_BOOTSTRAP_DOWNLOAD" in os.environ:
            # pylint: disable=not-callable
            log("Please stop using 'SKIP_BOOTSTRAP_DOWNLOAD' and use "
                "'DOWNLOAD_BOOTSTRAP_SCRIPT' instead")
            # pylint: enable=not-callable

        if "DOWNLOAD_BOOTSTRAP_SCRIPT" in os.environ:
            download_bootstrap_script = os.environ.get(
                "DOWNLOAD_BOOTSTRAP_SCRIPT", "0")
            self.download_bootstrap_script = download_bootstrap_script == "1"
Esempio n. 5
0
def run_process(args, logger=None, initial_env=None):
    def log(buffer, checkNewLine=False):
        endsWithNewLine = False
        if buffer.endswith('\n'):
            endsWithNewLine = True
        if checkNewLine and buffer.find('\n') == -1:
            return buffer
        lines = buffer.splitlines()
        buffer = ''
        if checkNewLine and not endsWithNewLine:
            buffer = lines[-1]
            lines = lines[:-1]
        for line in lines:
            if not logger is None:
                logger.info(line.rstrip('\r'))
            else:
                print(line.rstrip('\r'))
        return buffer
    
    log("Running process: {0}".format(" ".join([(" " in x and '"{0}"'.format(x) or x) for x in args])))
    
    if sys.platform != "win32":
        try:
            spawn(args)
            return 0
        except DistutilsExecError:
            return -1

    shell = False
    if sys.platform == "win32":
        shell = True
    
    if initial_env is None:
        initial_env = os.environ
    
    proc = popenasync.Popen(args,
        stdin = subprocess.PIPE,
        stdout = subprocess.PIPE, 
        stderr = subprocess.STDOUT,
        universal_newlines = 1,
        shell = shell,
        env = initial_env)
    
    log_buffer = None;
    while proc.poll() is None:
        log_buffer = log(proc.read_async(wait=0.1, e=0))
    if log_buffer:
        log(log_buffer)
    
    proc.wait()
    return proc.returncode
Esempio n. 6
0
                self._log_to_stderr(level, msg, *args)
            else:
                distutils.log.log(level, msg, *args)

        def _log_to_stderr(self, level, msg, *args):
            # This is the only truly 'public' way to get the current threshold
            # of the log
            current_threshold = distutils.log.set_threshold(distutils.log.WARN)
            distutils.log.set_threshold(current_threshold)
            if level >= current_threshold:
                if args:
                    msg = msg % args
                sys.stderr.write('%s\n' % msg)
                sys.stderr.flush()

    log = log()

# Output of `git submodule status` is as follows:
#
# 1: Status indicator: '-' for submodule is uninitialized, '+' if submodule is
# initialized but is not at the commit currently indicated in .gitmodules (and
# thus needs to be updated), or 'U' if the submodule is in an unstable state
# (i.e. has merge conflicts)
#
# 2. SHA-1 hash of the current commit of the submodule (we don't really need
# this information but it's useful for checking that the output is correct)
#
# 3. The output of `git describe` for the submodule's current commit hash (this
# includes for example what branches the commit is on) but only if the
# submodule is initialized.  We ignore this information for now
_git_submodule_status_re = re.compile(
Esempio n. 7
0
def _log_replace(self, level, msg, args):
    log_msg = msg % args
    log('%s\n' % log_msg, p=False)
    _orig_dist_Log_log(self, level, msg, args)