def migrate_and_get_paths(base_folder, out, manager, storage_folder=None): # Init paths paths = ConanPaths(base_folder, storage_folder, out) # Migration system migrator = ClientMigrator(paths, Version(CLIENT_VERSION), out, manager) migrator.migrate() # Init again paths, migration could change config paths = ConanPaths(base_folder, storage_folder, out) return paths
def __init__(self, base_folder=None, current_folder=None, servers=None, users=None, client_version=CLIENT_VERSION, min_server_compatible_version=MIN_SERVER_COMPATIBLE_VERSION): """ storage_folder: Local storage path current_folder: Current execution folder servers: dict of {remote_name: TestServer} logins is a list of (user, password) for auto input in order if required==> [("lasote", "mypass"), ("other", "otherpass")] """ self.users = users or {"default": [(TESTING_REMOTE_PRIVATE_USER, TESTING_REMOTE_PRIVATE_PASS)]} self.servers = servers or {} self.client_version = Version(str(client_version)) self.min_server_compatible_version = Version(str(min_server_compatible_version)) self.base_folder = base_folder or temp_folder() # Define storage_folder, if not, it will be read from conf file & pointed to real user home self.storage_folder = os.path.join(self.base_folder, ".conan", "data") self.paths = ConanPaths(self.base_folder, self.storage_folder, TestBufferConanOutput()) self.default_settings(get_env("CONAN_COMPILER", "gcc"), get_env("CONAN_COMPILER_VERSION", "4.8"), get_env("CONAN_LIBCXX", "libstdc++")) self.init_dynamic_vars() save(self.paths.registry, "") registry = RemoteRegistry(self.paths.registry, TestBufferConanOutput()) for name, server in self.servers.items(): registry.add(name, server.fake_url) logger.debug("Client storage = %s" % self.storage_folder) self.current_folder = current_folder or temp_folder()
def setUp(self): self.conan_reference = ConanFileReference.loads( "openssl/2.0.3@lasote/testing") self.package_reference = PackageReference(self.conan_reference, "123123123") self.remote_client = MockRemoteClient() self.output = TestBufferConanOutput() self.paths = ConanPaths(temp_folder(), None, self.output) self.remotes = [("default", "url1"), ("other", "url2"), ("last", "url3")] self.manager = RemoteManager(self.paths, self.remotes, self.remote_client, self.output)
def get_command(): def instance_remote_manager(paths): requester = requests.Session() requester.proxies = paths.conan_config.proxies # Verify client version against remotes version_checker_requester = VersionCheckerRequester( requester, Version(CLIENT_VERSION), Version(MIN_SERVER_COMPATIBLE_VERSION), out) # To handle remote connections rest_api_client = RestApiClient(out, requester=version_checker_requester) # To store user and token localdb = LocalDB(paths.localdb) # Wraps RestApiClient to add authentication support (same interface) auth_manager = ConanApiAuthManager(rest_api_client, user_io, localdb) # Handle remote connections remote_manager = RemoteManager(paths, auth_manager, out) return remote_manager if hasattr(sys.stdout, "isatty") and sys.stdout.isatty(): import colorama colorama.init() color = True else: color = False out = ConanOutput(sys.stdout, color) user_io = UserIO(out=out) user_folder = os.getenv("CONAN_USER_HOME", conan_expand_user("~")) try: # To capture exceptions in conan.conf parsing paths = ConanPaths(user_folder, None, out) # obtain a temp ConanManager instance to execute the migrations remote_manager = instance_remote_manager(paths) manager = ConanManager(paths, user_io, ConanRunner(), remote_manager) paths = migrate_and_get_paths(user_folder, out, manager) except Exception as e: out.error(str(e)) sys.exit(True) # Get the new command instance after migrations have been done manager = instance_remote_manager(paths) command = Command(paths, user_io, ConanRunner(), manager) return command