def get_packages(self, args, auto_checkout=False, deploy=False, checked_out=False): if auto_checkout: packages = set(self.deploy.auto_checkout) else: packages = set(self.deploy.sources) if deploy: packages = packages.intersection(set(self.deploy.develeggs)) if checked_out: for name in set(packages): if not self.deploy.sources[name].exists(): packages.remove(name) if not args: return packages result = set() regexp = re.compile("|".join("(%s)" % x for x in args)) for name in packages: if not regexp.search(name): continue result.add(name) if len(result) == 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) return result
def __call__(self, args): config = self.deploy.config packages = self.get_packages(getattr(args, 'package-regexp'), auto_checkout=args.auto_checkout) try: workingcopies = WorkingCopies(self.deploy.sources) workingcopies.checkout(sorted(packages), verbose=args.verbose, always_accept_server_certificate=self.deploy.always_accept_server_certificate) for name in sorted(packages): source = self.deploy.sources[name] if not source.get('egg', True): continue config.deploy[name] = True logger.info("Activated '%s'." % name) logger.warn("Don't forget to run buildout again, so the checked out packages are used as deploy eggs.") config.save() except (ValueError, KeyError), e: logger.error(e) sys.exit(1)
def __call__(self, **kwargs): logger.setLevel(logging.INFO) ch = logging.StreamHandler() ch.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) logger.addHandler(ch) self.parser = ArgumentParser() version = pkg_resources.get_distribution("duke.deploy").version self.parser.add_argument('-v', '--version', action='version', version='duke.deploy %s' % version) self.parsers = self.parser.add_subparsers(title="commands", metavar="") CmdInstall(self) CmdUpdate(self) args = self.parser.parse_args() try: self.buildout_dir = find_base() except IOError, e: self.parser.print_help() logger.error("You are not in a path which has duke.deploy installed (%s)." % e) return
def unknown(self): logger.error("Unknown command '%s'." % sys.argv[1]) logger.info("Type '%s help' for usage." % os.path.basename(sys.argv[0])) sys.exit(1)