예제 #1
0
def main():

    # Get and validate our options and arguments
    parser = setup_parser()
    options, args = parser.parse_args()
    if len(args) < 1:
        parser.error("Must call easy_manage with one of 'install', 'upgrade', "
                     "'update', 'rollback', 'remove', 'save_state', or "
                     "'list', see -h for more details")

    # Set up logging
    basicConfig(level=options.logging, format="%(message)s")

    # Setup our verbosity.  We are verbose only if logging is DEBUG level.
    options.verbose = (DEBUG == options.logging)

    # Build our list of remote repositories we'll search for distributions to
    # install.  Any repository settings provided via the command line take
    # precedence over anything in the config file, and the index in the config
    # file always comes last.  This ordering is important because we now stop
    # as soon as we find a matching distribution in the first repository.
    remote_repos = [HTMLRepository(arg, verbose=options.verbose) for arg in
        options.find_links]
    remote_repos.extend([HTMLRepository(u, verbose=options.verbose) for u in
        get_configured_repos(unstable=options.allow_unstable,
        verbose=options.verbose)])
    remote_repos.append(HTMLRepository(get_configured_index(), index=True,
        verbose=options.verbose))

    # Try to set up a proxy server, either from options or environment vars.
    # This makes urllib2 calls do the right thing.
    try:
        installed = setup_proxy(options.proxy)
    except ValueError, e:
        error('Proxy configuration error: %s' % e)
        sys.exit(2)
예제 #2
0
    def __init__(self, index_url=None,
                 hosts=('*',), *args, **kw):
        # DMP 2009.05.13: Added 'no_default_index' keyword to allow ensetuptools
        # package code to create instances that have no index url at all.  We
        # have to strip this keyword out of the keywords before constructing
        # the base Environment class to avoid exceptions.
        if 'no_default_index' in kw:
            self.no_default_index = kw['no_default_index']
            del kw['no_default_index']
        else:
            self.no_default_index = None

        Environment.__init__(self, *args, **kw)
        self.index_url = index_url
        if self.index_url is None and not self.no_default_index:
            index_url = get_configured_index()
        # Make sure URL has single trailing slash
        if self.index_url:
            self.index_url = index_url.rstrip("/") + "/"
        self.scanned_urls = {}
        self.fetched_urls = {}
        self.package_pages = {}
        self.allows = re.compile('|'.join(map(translate,hosts))).match
        self.to_scan = []