def __call__(self, args): sources = self.develop.sources auto_checkout = self.develop.auto_checkout packages = self.get_packages(getattr(args, 'package-regexp'), auto_checkout=args.auto_checkout, checked_out=args.checked_out, develop=args.develop) workingcopies = WorkingCopies(sources) for name in sorted(packages): source = sources[name] if args.status: if source.exists(): if not workingcopies.matches(source): print "C", else: if name in auto_checkout: print " ", else: print "~", else: if name in auto_checkout: print "!", else: print "#", if args.long: print "(%s)" % source['kind'], name, source['url'] else: print name
def __call__(self): options, args = self.parser.parse_args(sys.argv[2:]) sources = self.develop.sources auto_checkout = self.develop.auto_checkout packages = self.get_packages(args, auto_checkout=options.auto_checkout, checked_out=options.checked_out, develop=options.develop) workingcopies = WorkingCopies(sources) for name in sorted(packages): source = sources[name] if options.status: if source.exists(): if not workingcopies.matches(source): print "C", else: if name in auto_checkout: print " ", else: print "~", else: if name in auto_checkout: print "!", else: print "#", if options.long: print "(%s)" % source['kind'], name, source['url'] else: print name
def __call__(self): options, args = self.parser.parse_args(sys.argv[2:]) sources = self.develop.sources auto_checkout = self.develop.auto_checkout packages = set(self.get_packages(args)) workingcopies = WorkingCopies(sources) for name in sorted(sources): if args and name not in packages: continue if options.auto_checkout and name not in auto_checkout: continue source = sources[name] if options.status: if os.path.exists(source["path"]): if not workingcopies.matches(source): print "C", else: if name in auto_checkout: print " ", else: print "~", else: if name in auto_checkout: print "!", else: print "#", if options.long: print "(%s)" % source["kind"], name, source["url"] else: print name
def __call__(self, args): buildout_dir = self.develop.buildout_dir packages = self.get_packages(getattr(args, 'package-regexp'), checked_out=True) packages = packages - self.develop.auto_checkout packages = packages - set(self.develop.develeggs) workingcopies = WorkingCopies(self.develop.sources) if args.dry_run: logger.info("Dry run, nothing will be removed.") for name in packages: source = self.develop.sources[name] path = source['path'] if path.startswith(buildout_dir): path = path[len(buildout_dir)+1:] if source['kind'] != 'svn': logger.warn("The directory of package '%s' at '%s' might contain unrecoverable files and will not be removed." % (name, path)) continue if workingcopies.status(source) != 'clean': logger.warn("The package '%s' is dirty and will not be removed." % name) continue logger.info("Removing package '%s' at '%s'." % (name, path)) if not args.dry_run: shutil.rmtree(source['path'], ignore_errors=False, onerror=self.handle_remove_readonly)
def __call__(self): options, args = self.parser.parse_args(sys.argv[2:]) config = self.develop.config # Find out which packages to checkout if len(args) == 0: if options.auto_checkout: packages = self.develop.auto_checkout else: print self.parser.format_help() sys.exit(0) else: packages = self.get_packages(args) if options.auto_checkout: packages = [x for x in packages if x in self.develop.auto_checkout] if len(packages) == 0: if len(args) > 1: regexps = "%s or '%s'" % (", ".join("'%s'" % x for x in args[:-1]), args[-1]) else: regexps = "'%s'" % args[0] logger.error("No package matched %s." % regexps) sys.exit(1) # Actually checkout try: workingcopies = WorkingCopies(self.develop.sources) workingcopies.checkout(packages, verbose=options.verbose) for name in packages: config.develop[name] = True logger.info("Activated '%s'." % name) logger.warn("Don't forget to run buildout again, so the checked out packages are used as develop eggs.") config.save() except (ValueError, KeyError), e: logger.error(e) sys.exit(1)
def __call__(self, args): auto_checkout = self.develop.auto_checkout develeggs = self.develop.develeggs packages = self.get_packages(getattr(args, 'package-regexp'), auto_checkout=args.auto_checkout, checked_out=args.checked_out, develop=args.develop) workingcopies = WorkingCopies(self.develop.sources) for name in sorted(packages): source = self.develop.sources[name] if not source.exists(): if name in auto_checkout: print "!", " ", name continue if not workingcopies.matches(source): print "C", else: if name in auto_checkout: print " ", else: print "~", if args.verbose: status, output = workingcopies.status(source, verbose=True) else: status = workingcopies.status(source) if status == 'clean': print " ", else: print "M", if self.develop.config.develop.get(name, name in auto_checkout): if name in develeggs: print " ", else: if source.get('egg', True): print "A", else: print " ", else: if name not in develeggs: if not source.get('egg', True): print " ", elif name in auto_checkout: print "!", else: print "-", else: if source.get('egg', True): print "D", else: print " ", print name if args.verbose: output = output.strip() if output: for line in output.split('\n'): print " ", line print
def __call__(self, args): packages = self.get_packages(getattr(args, 'package-regexp'), auto_checkout=args.auto_checkout, checked_out=True, develop=args.develop) workingcopies = WorkingCopies(self.develop.sources) workingcopies.update(sorted(packages), force=args.force, verbose=args.verbose)
def __call__(self): options, args = self.parser.parse_args(sys.argv[2:]) packages = self.get_packages(args, auto_checkout=options.auto_checkout, checked_out=True, develop=options.develop) workingcopies = WorkingCopies(self.develop.sources) workingcopies.update(sorted(packages), force=options.force, verbose=options.verbose)
def __call__(self, args): packages = self.get_packages(getattr(args, 'package-regexp'), auto_checkout=args.auto_checkout, checked_out=True, develop=args.develop) workingcopies = WorkingCopies(self.develop.sources) force = args.force or self.develop.always_checkout workingcopies.update(sorted(packages), force=force, verbose=args.verbose, always_accept_server_certificate=self.develop.always_accept_server_certificate)
def __call__(self, args): packages = self.get_packages(getattr(args, 'package-regexp'), auto_checkout=args.auto_checkout, checked_out=True, develop=args.develop) workingcopies = WorkingCopies(self.develop.sources) force = args.force or self.develop.always_checkout workingcopies.update(sorted(packages), force=force, verbose=args.verbose, always_accept_server_certificate=self.develop. always_accept_server_certificate)
def __call__(self): options, args = self.parser.parse_args(sys.argv[2:]) sources = self.develop.sources auto_checkout = self.develop.auto_checkout develeggs = self.develop.develeggs packages = set(self.get_packages(args)) workingcopies = WorkingCopies(sources) for name in sorted(sources): if args and name not in packages: continue source = sources[name] path = source["path"] if not os.path.exists(path): if name in auto_checkout: print "!", " ", name continue if not workingcopies.matches(source): print "C", else: if name in auto_checkout: print " ", else: print "~", if options.verbose: status, output = workingcopies.status(source, verbose=True) else: status = workingcopies.status(source) if status == "clean": print " ", else: print "M", if self.develop.config.develop.get(name, name in auto_checkout): if name in develeggs: print " ", else: print "A", else: if name not in develeggs: if name in auto_checkout: print "!", else: print "-", else: print "D", print name if options.verbose: output = output.strip() if output: for line in output.split("\n"): print " ", line print
def __call__(self, args): buildout_dir = self.develop.buildout_dir packages = self.get_packages(getattr(args, 'package-regexp'), checked_out=True) packages = packages - self.develop.auto_checkout packages = packages - set(self.develop.develeggs) force = args.force force_all = False workingcopies = WorkingCopies(self.develop.sources) if args.dry_run: logger.info("Dry run, nothing will be removed.") for name in packages: source = self.develop.sources[name] path = source['path'] if path.startswith(buildout_dir): path = path[len(buildout_dir) + 1:] need_force = False if source['kind'] != 'svn': need_force = True logger.warn( "The directory of package '%s' at '%s' might contain unrecoverable files and will not be removed without --force." % (name, path)) if workingcopies.status(source) != 'clean': need_force = True logger.warn( "The package '%s' is dirty and will not be removed without --force." % name) if need_force: if not force: continue # We only get here when a --force is needed and we # have actually added the --force argument on the # command line. if not force_all: answer = yesno("Do you want to purge it anyway?", default=False, all=True) if not answer: logger.info("Skipped purge of '%s'." % name) continue if answer == 'all': force_all = True logger.info("Removing package '%s' at '%s'." % (name, path)) if not args.dry_run: shutil.rmtree(source['path'], ignore_errors=False, onerror=self.handle_remove_readonly)
def __call__(self): options, args = self.parser.parse_args(sys.argv[2:]) sources = self.develop.sources auto_checkout = self.develop.auto_checkout packages = set(self.get_packages(args)) workingcopies = WorkingCopies(sources) toupdate = [] for name in sorted(sources): if options.auto_checkout and name not in auto_checkout: continue source = sources[name] if args and name not in packages: continue if not os.path.exists(source["path"]): continue toupdate.append(name) workingcopies.update(toupdate, force=options.force, verbose=options.verbose)
def __call__(self, args): config = self.develop.config packages = self.get_packages(getattr(args, 'package-regexp'), auto_checkout=args.auto_checkout) try: workingcopies = WorkingCopies(self.develop.sources) workingcopies.checkout(sorted(packages), verbose=args.verbose) for name in sorted(packages): source = self.develop.sources[name] if not source.get('egg', True): continue config.develop[name] = True logger.info("Activated '%s'." % name) logger.warn("Don't forget to run buildout again, so the checked out packages are used as develop eggs.") config.save() except (ValueError, KeyError), e: logger.error(e) sys.exit(1)
def __call__(self): options, args = self.parser.parse_args(sys.argv[2:]) config = self.develop.config if len(args) == 0 and not options.auto_checkout: print self.parser.format_help() sys.exit(0) packages = self.get_packages(args, auto_checkout=options.auto_checkout) try: workingcopies = WorkingCopies(self.develop.sources) workingcopies.checkout(sorted(packages), verbose=options.verbose) for name in sorted(packages): config.develop[name] = True logger.info("Activated '%s'." % name) logger.warn("Don't forget to run buildout again, so the checked out packages are used as develop eggs.") config.save() except (ValueError, KeyError), e: logger.error(e) sys.exit(1)
def __call__(self, args): buildout_dir = self.develop.buildout_dir packages = self.get_packages(getattr(args, 'package-regexp'), checked_out=True) packages = packages - self.develop.auto_checkout packages = packages - set(self.develop.develeggs) force = args.force force_all = False workingcopies = WorkingCopies(self.develop.sources) if args.dry_run: logger.info("Dry run, nothing will be removed.") for name in packages: source = self.develop.sources[name] path = source['path'] if path.startswith(buildout_dir): path = path[len(buildout_dir)+1:] need_force = False if source['kind'] != 'svn': need_force = True logger.warn("The directory of package '%s' at '%s' might contain unrecoverable files and will not be removed without --force." % (name, path)) if workingcopies.status(source) != 'clean': need_force = True logger.warn("The package '%s' is dirty and will not be removed without --force." % name) if need_force: if not force: continue # We only get here when a --force is needed and we # have actually added the --force argument on the # command line. if not force_all: answer = yesno("Do you want to purge it anyway?", default=False, all=True) if not answer: logger.info("Skipped purge of '%s'." % name) continue if answer == 'all': force_all = True logger.info("Removing package '%s' at '%s'." % (name, path)) if not args.dry_run: shutil.rmtree(source['path'], ignore_errors=False, onerror=self.handle_remove_readonly)
def __call__(self): options, args = self.parser.parse_args(sys.argv[2:]) buildout_dir = self.develop.buildout_dir packages = self.get_packages(args, checked_out=True) packages = packages - self.develop.auto_checkout packages = packages - set(self.develop.develeggs) workingcopies = WorkingCopies(self.develop.sources) for name in packages: source = self.develop.sources[name] path = source['path'] if path.startswith(buildout_dir): path = path[len(buildout_dir)+1:] if source['kind'] != 'svn': logger.warn("The directory of package '%s' at '%s' might contain unrecoverable files and will not be removed." % (name, path)) continue if workingcopies.status(source) != 'clean': logger.warn("The package '%s' is dirty and will not be removed." % name) continue logger.info("Removing package '%s' at '%s'." % (name, path)) shutil.rmtree(source['path'])
def __call__(self, args): config = self.develop.config packages = self.get_packages(getattr(args, 'package-regexp'), auto_checkout=args.auto_checkout) try: workingcopies = WorkingCopies(self.develop.sources) workingcopies.checkout(sorted(packages), verbose=args.verbose, always_accept_server_certificate=self. develop.always_accept_server_certificate) for name in sorted(packages): source = self.develop.sources[name] if not source.get('egg', True): continue config.develop[name] = True logger.info("Activated '%s'." % name) logger.warn( "Don't forget to run buildout again, so the checked out packages are used as develop eggs." ) config.save() except (ValueError, KeyError), e: logger.error(e) sys.exit(1)
def __call__(self, args): auto_checkout = self.develop.auto_checkout sources_dir = self.develop.sources_dir develeggs = self.develop.develeggs package_regexp = getattr(args, 'package-regexp') packages = self.get_packages(package_regexp, auto_checkout=args.auto_checkout, checked_out=args.checked_out, develop=args.develop) workingcopies = WorkingCopies(self.develop.sources) paths = [] for name in sorted(packages): source = self.develop.sources[name] if not source.exists(): if name in auto_checkout: print "!", " ", name continue paths.append(source['path']) if not workingcopies.matches(source): print "C", else: if name in auto_checkout: print " ", else: print "~", if args.verbose: status, output = workingcopies.status(source, verbose=True) else: status = workingcopies.status(source) if status == 'clean': print " ", else: print "M", if self.develop.config.develop.get(name, name in auto_checkout): if name in develeggs: print " ", else: if source.get('egg', True): print "A", else: print " ", else: if name not in develeggs: if not source.get('egg', True): print " ", elif name in auto_checkout: print "!", else: print "-", else: if source.get('egg', True): print "D", else: print " ", print name if args.verbose: output = output.strip() if output: for line in output.split('\n'): print " ", line print # Only report on unknown entries when we have no package regexp. if not package_regexp: for entry in os.listdir(sources_dir): if not os.path.join(sources_dir, entry) in paths: print '?', ' ', entry
def extension(buildout=None): import zc.buildout.easy_install buildout_dir = buildout['buildout']['directory'] sources_dir = buildout['buildout'].get('sources-dir', 'src') if not os.path.isabs(sources_dir): sources_dir = os.path.join(buildout_dir, sources_dir) config = Config(buildout_dir, sources_dir) if os.path.split(sys.argv[0])[1] == 'buildout': config.buildout_args = list(sys.argv) sources = {} section = buildout.get(buildout['buildout'].get('sources', 'sources'), {}) for name, info in section.iteritems(): sources[name] = sourcefromcfgline(config, name, info) # do automatic checkout of specified packages auto_checkout = set(buildout['buildout'].get('auto-checkout', '').split()) if '*' in auto_checkout: auto_checkout = set(sources.keys()) workingcopies = WorkingCopies(sources) if not auto_checkout.issubset(set(sources.keys())): diff = list(sorted(auto_checkout.difference(set(sources.keys())))) if len(diff) > 1: pkgs = "%s and '%s'" % (", ".join("'%s'" % x for x in diff[:-1]), diff[-1]) logger.error("The packages %s from auto-checkout have no source information." % pkgs) else: logger.error("The package '%s' from auto-checkout has no source information." % diff[0]) sys.exit(1) root_logger = logging.getLogger() workingcopies.checkout(sorted(auto_checkout), verbose=root_logger.level <= 10) # make the develop eggs if the package is checked out and fixup versions develop = buildout['buildout'].get('develop', '') versions = buildout.get(buildout['buildout'].get('versions'), {}) develeggs = {} for path in develop.split(): head, tail = os.path.split(path) develeggs[tail] = path for name in sources: if name not in develeggs: path = sources[name]['path'] if os.path.exists(path) and config.develop.get(name, name in auto_checkout): config.develop.setdefault(name, True) status = config.develop.get(name, name in auto_checkout) if os.path.exists(path) and status: if name in auto_checkout: config.develop.setdefault(name, 'auto') else: if status == 'auto': if name in config.develop: del config.develop[name] continue config.develop.setdefault(name, True) pkgbasedir = sources[name]['pkgbasedir'] if pkgbasedir is not None: path = os.path.join(path, pkgbasedir, name) develeggs[name] = path if name in versions: del versions[name] if versions: zc.buildout.easy_install.default_versions(dict(versions)) develop = [] for path in develeggs.itervalues(): if path.startswith(buildout_dir): develop.append(path[len(buildout_dir)+1:]) else: develop.append(path) buildout['buildout']['develop'] = "\n".join(develop) # build the fake part to install the checkout script if FAKE_PART_ID in buildout._raw: logger.error("mr.developer: The buildout already has a '%s' section, this shouldn't happen" % FAKE_PART_ID) sys.exit(1) args = dict( sources = pformat(sources), auto_checkout = pformat(auto_checkout), buildout_dir = '%r' % buildout_dir, develeggs = pformat(develeggs), ) buildout._raw[FAKE_PART_ID] = dict( recipe='zc.recipe.egg', eggs='mr.developer', arguments=',\n'.join("=".join(x) for x in args.items()), ) # insert the fake part parts = buildout['buildout']['parts'].split() parts.insert(0, FAKE_PART_ID) buildout['buildout']['parts'] = " ".join(parts) config.save()
def get_workingcopies(self): return WorkingCopies(self.get_sources())
def extension(buildout=None): import zc.buildout.easy_install buildout_dir = buildout['buildout']['directory'] config = Config(buildout_dir) if os.path.split(sys.argv[0])[1] == 'buildout': config.buildout_args = list(sys.argv) sources_dir = buildout['buildout'].get('sources-dir', 'src') if not os.path.isabs(sources_dir): sources_dir = os.path.join(buildout_dir, sources_dir) sources = {} section = buildout.get(buildout['buildout'].get('sources', 'sources'), {}) for name, info in section.iteritems(): info = info.split() kind = info[0] url = info[1] for rewrite in config.rewrites: if len(rewrite) == 2 and url.startswith(rewrite[0]): url = "%s%s" % (rewrite[1], url[len(rewrite[0]):]) if len(info) > 2: path = os.path.join(info[2], name) if not os.path.isabs(path): path = os.path.join(buildout_dir, path) else: path = os.path.join(sources_dir, name) sources[name] = dict(kind=kind, name=name, url=url, path=path) # deprecated way of specifing sources if 'sources-svn' in buildout['buildout']: logger.warn("'sources-svn' is deprecated, use 'sources' instead (see README for usage).") section = buildout.get(buildout['buildout'].get('sources-svn'), {}) for name, url in section.iteritems(): for rewrite in config.rewrites: if len(rewrite) == 2 and url.startswith(rewrite[0]): url = "%s%s" % (rewrite[1], url[len(rewrite[0]):]) if name in sources: logger.error("The source for '%s' is already set." % name) sys.exit(1) sources[name] = dict( kind='svn', name=name, url=url, path=os.path.join(sources_dir, name)) if 'sources-git' in buildout['buildout']: logger.warn("'sources-git' is deprecated, use 'sources' instead (see README for usage).") section = buildout.get(buildout['buildout'].get('sources-git'), {}) for name, url in section.iteritems(): for rewrite in config.rewrites: if len(rewrite) == 2 and url.startswith(rewrite[0]): url = "%s%s" % (rewrite[1], url[len(rewrite[0]):]) if name in sources: logger.error("The source for '%s' is already set." % name) sys.exit(1) sources[name] = dict( kind='git', name=name, url=url, path=os.path.join(sources_dir, name)) # do automatic checkout of specified packages auto_checkout = set(buildout['buildout'].get('auto-checkout', '').split()) workingcopies = WorkingCopies(sources) if not auto_checkout.issubset(set(sources.keys())): diff = list(sorted(auto_checkout.difference(set(sources.keys())))) if len(diff) > 1: pkgs = "%s and '%s'" % (", ".join("'%s'" % x for x in diff[:-1]), diff[-1]) logger.error("The packages %s from auto-checkout have no source information." % pkgs) else: logger.error("The package '%s' from auto-checkout has no source information." % diff[0]) sys.exit(1) if workingcopies.checkout(sorted(auto_checkout), skip_errors=True): atexit.register(report_error) # make the develop eggs if the package is checked out and fixup versions develop = buildout['buildout'].get('develop', '') versions = buildout.get(buildout['buildout'].get('versions'), {}) develeggs = {} for path in develop.split(): head, tail = os.path.split(path) develeggs[tail] = path for name in sources: if name not in develeggs: path = sources[name]['path'] if os.path.exists(path) and config.develop.get(name, name in auto_checkout): config.develop.setdefault(name, True) develeggs[name] = path if name in versions: del versions[name] if versions: zc.buildout.easy_install.default_versions(dict(versions)) develop = [] for path in develeggs.itervalues(): if path.startswith(buildout_dir): develop.append(path[len(buildout_dir)+1:]) else: develop.append(path) buildout['buildout']['develop'] = "\n".join(develop) # build the fake part to install the checkout script if FAKE_PART_ID in buildout._raw: logger.error("mr.developer: The buildout already has a '%s' section, this shouldn't happen" % FAKE_PART_ID) sys.exit(1) args = dict( sources = pformat(sources), auto_checkout = pformat(auto_checkout), buildout_dir = '"%s"' % buildout_dir, develeggs = pformat(develeggs), ) buildout._raw[FAKE_PART_ID] = dict( recipe='zc.recipe.egg', eggs='mr.developer', arguments=',\n'.join("=".join(x) for x in args.items()), ) # insert the fake part parts = buildout['buildout']['parts'].split() parts.insert(0, FAKE_PART_ID) buildout['buildout']['parts'] = " ".join(parts) config.save()
def get_workingcopies(self): return WorkingCopies(self.get_sources(), threads=self.get_threads())
def get_workingcopies(self, sources): return WorkingCopies(sources, threads=self.develop.threads)