def remote(self, *args): """ manage remotes """ parser = argparse.ArgumentParser(description=self.remote.__doc__, prog="conan remote") subparsers = parser.add_subparsers(dest='subcommand', help='sub-command help') # create the parser for the "a" command subparsers.add_parser('list', help='list current remotes') parser_add = subparsers.add_parser('add', help='add a remote') parser_add.add_argument('remote', help='name of the remote') parser_add.add_argument('url', help='url of the remote') parser_add.add_argument('verify_ssl', help='Verify SSL certificated. Default True', default="True", nargs="?") parser_rm = subparsers.add_parser('remove', help='remove a remote') parser_rm.add_argument('remote', help='name of the remote') parser_upd = subparsers.add_parser('update', help='update the remote url') parser_upd.add_argument('remote', help='name of the remote') parser_upd.add_argument('url', help='url') parser_upd.add_argument('verify_ssl', help='Verify SSL certificated. Default True', default="True", nargs="?") subparsers.add_parser('list_ref', help='list the package recipes and its associated remotes') parser_padd = subparsers.add_parser('add_ref', help="associate a recipe's reference to a remote") parser_padd.add_argument('reference', help='package recipe reference') parser_padd.add_argument('remote', help='name of the remote') parser_prm = subparsers.add_parser('remove_ref', help="dissociate a recipe's reference and its remote") parser_prm.add_argument('reference', help='package recipe reference') parser_pupd = subparsers.add_parser('update_ref', help="update the remote associated " "with a package recipe") parser_pupd.add_argument('reference', help='package recipe reference') parser_pupd.add_argument('remote', help='name of the remote') args = parser.parse_args(*args) registry = RemoteRegistry(self._client_cache.registry, self._user_io.out) if args.subcommand == "list": for r in registry.remotes: self._user_io.out.info("%s: %s [Verify SSL: %s]" % (r.name, r.url, r.verify_ssl)) elif args.subcommand == "add": verify = get_bool_from_text_value(args.verify_ssl) registry.add(args.remote, args.url, args.verify_ssl) elif args.subcommand == "remove": registry.remove(args.remote) elif args.subcommand == "update": verify = get_bool_from_text_value(args.verify_ssl) registry.update(args.remote, args.url, verify) elif args.subcommand == "list_ref": for ref, remote in registry.refs.items(): self._user_io.out.info("%s: %s" % (ref, remote)) elif args.subcommand == "add_ref": registry.add_ref(args.reference, args.remote) elif args.subcommand == "remove_ref": registry.remove_ref(args.reference) elif args.subcommand == "update_ref": registry.update_ref(args.reference, args.remote)
def load_registry_txt(contents): """Remove in Conan 2.0""" remotes = Remotes() refs = {} end_remotes = False # Parse the file for line in contents.splitlines(): line = line.strip() if not line: if end_remotes: raise ConanException("Bad file format, blank line") end_remotes = True continue chunks = line.split() if not end_remotes: if len(chunks) == 2: # Retro compatibility remote_name, url = chunks verify_ssl = "True" elif len(chunks) == 3: remote_name, url, verify_ssl = chunks else: raise ConanException( "Bad file format, wrong item numbers in line '%s'" % line) verify_ssl = get_bool_from_text_value(verify_ssl) remotes.add(remote_name, url, verify_ssl) else: ref, remote_name = chunks refs[ref] = remote_name return remotes, refs
def _parse(self, contents): remotes = OrderedDict() refs = {} end_remotes = False # Parse the file for line in contents.splitlines(): line = line.strip() if not line: if end_remotes: raise ConanException("Bad file format, blank line %s" % self._filename) end_remotes = True continue chunks = line.split() if not end_remotes: if len(chunks) == 2: # Retro compatibility ref, remote = chunks verify_ssl = "True" elif len(chunks) == 3: ref, remote, verify_ssl = chunks else: raise ConanException( "Bad file format, wrong item numbers in line '%s'" % line) verify_ssl = get_bool_from_text_value(verify_ssl) remotes[ref] = (remote, verify_ssl) else: ref, remote = chunks refs[ref] = remote return remotes, refs
def _parse(self, contents): remotes = OrderedDict() refs = {} end_remotes = False # Parse the file for line in contents.splitlines(): line = line.strip() if not line: if end_remotes: raise ConanException("Bad file format, blank line %s" % self._filename) end_remotes = True continue chunks = line.split() if not end_remotes: if len(chunks) == 2: # Retro compatibility ref, remote = chunks verify_ssl = "True" elif len(chunks) == 3: ref, remote, verify_ssl = chunks else: raise ConanException("Bad file format, wrong item numbers in line '%s'" % line) verify_ssl = get_bool_from_text_value(verify_ssl) remotes[ref] = (remote, verify_ssl) else: ref, remote = chunks refs[ref] = remote return remotes, refs