def copy(self, reference, package_ids, username, channel, force=False): """ Copy or move conanfile (exported) and packages to another user and or channel @param reference: ConanFileReference containing the packages to be moved @param package_ids: list of ids or [] for all list @param username: Destination username @param channel: Destination channel @param remote: install only from that remote """ # It is necessary to make sure the sources are complete before proceeding remote_proxy = ConanProxy(self._client_cache, self._user_io, self._remote_manager, None) # Now we can actually copy conan_file_path = self._client_cache.conanfile(reference) conanfile = load_conanfile_class(conan_file_path) remote_proxy.complete_recipe_sources(reference, short_paths=conanfile.short_paths) copier = PackageCopier(self._client_cache, self._user_io, conanfile.short_paths) if not package_ids: packages = self._client_cache.packages(reference) if os.path.exists(packages): package_ids = os.listdir(packages) else: package_ids = [] copier.copy(reference, package_ids, username, channel, force)
def copy(self, reference, package_ids, username, channel, force=False): """ Copy or move conanfile (exported) and packages to another user and or channel @param reference: ConanFileReference containing the packages to be moved @param package_ids: list of ids or [] for all list @param username: Destination username @param channel: Destination channel @param remote: install only from that remote """ copier = PackageCopier(self._paths, self._user_io) package_ids = package_ids or os.listdir(self._paths.packages(reference)) copier.copy(reference, package_ids, username, channel, force)
def copy(self, reference, package_ids, username, channel, force=False): """ Copy or move conanfile (exported) and packages to another user and or channel @param reference: ConanFileReference containing the packages to be moved @param package_ids: list of ids or [] for all list @param username: Destination username @param channel: Destination channel @param remote: install only from that remote """ copier = PackageCopier(self._paths, self._user_io) package_ids = package_ids or os.listdir( self._paths.packages(reference)) copier.copy(reference, package_ids, username, channel, force)
def copy(self, reference, package_ids, username, channel, force=False): """ Copy or move conanfile (exported) and packages to another user and or channel @param reference: ConanFileReference containing the packages to be moved @param package_ids: list of ids or [] for all list @param username: Destination username @param channel: Destination channel @param remote: install only from that remote """ copier = PackageCopier(self._client_cache, self._user_io) if not package_ids: packages = self._client_cache.packages(reference) if os.path.exists(packages): package_ids = os.listdir(packages) else: package_ids = [] copier.copy(reference, package_ids, username, channel, force)
def copy(self, reference, package_ids, username, channel, force=False): """ Copy or move conanfile (exported) and packages to another user and or channel @param reference: ConanFileReference containing the packages to be moved @param package_ids: list of ids or [] for all list @param username: Destination username @param channel: Destination channel @param remote: install only from that remote """ # It is necessary to make sure the sources are complete before proceeding remote_proxy = ConanProxy(self._client_cache, self._user_io, self._remote_manager, None) remote_proxy.complete_recipe_sources(reference) # Now we can actually copy conan_file_path = self._client_cache.conanfile(reference) conanfile = load_conanfile_class(conan_file_path) copier = PackageCopier(self._client_cache, self._user_io, conanfile.short_paths) if not package_ids: packages = self._client_cache.packages(reference) if os.path.exists(packages): package_ids = os.listdir(packages) else: package_ids = [] copier.copy(reference, package_ids, username, channel, force)
def testCopier(self): output = TestBufferConanOutput() userio = MockedBooleanUserIO(True, out=output) paths = SimplePaths(temp_folder()) copier = PackageCopier(paths, userio) # Create some packages to copy reference = ConanFileReference.loads("Hello/0.1@lasote/testing") self._create_conanfile(reference, paths) self._create_package(reference, "0101001", paths) self._create_package(reference, "2222222", paths) # Copy all to destination copier.copy(reference, ["0101001", "2222222"], "lasote", "stable", force=False) new_reference = ConanFileReference.loads("Hello/0.1@lasote/stable") self._assert_conanfile_exists(new_reference, paths) self._assert_package_exists(new_reference, "0101001", paths) self._assert_package_exists(new_reference, "2222222", paths) self.assertIn( "Copied Hello/0.1@lasote/testing to Hello/0.1@lasote/stable", output) self.assertIn("Copied 0101001 to Hello/0.1@lasote/stable", output) self.assertIn("Copied 2222222 to Hello/0.1@lasote/stable", output) # Copy again, without force and answering yes output._stream.truncate(0) # Reset output copier.copy(reference, ["0101001", "2222222"], "lasote", "stable", force=False) self.assertIn( "Copied Hello/0.1@lasote/testing to Hello/0.1@lasote/stable", output) self.assertIn("Copied 0101001 to Hello/0.1@lasote/stable", output) self.assertIn("Copied 2222222 to Hello/0.1@lasote/stable", output) self.assertIn("'Hello/0.1@lasote/stable' already exist. Override?", output) self.assertIn("Package '2222222' already exist. Override?", output) self.assertIn("Package '0101001' already exist. Override?", output) # Now alter the origin and copy again to same destination and confirm the copy self._create_conanfile(reference, paths, "new content") self._create_package(reference, "0101001", paths, "new lib content") self._create_package(reference, "2222222", paths, "new lib content") output._stream.truncate(0) # Reset output copier.copy(reference, ["0101001", "2222222"], "lasote", "stable", force=False) conanfile_content = load( os.path.join(paths.export(new_reference), "conanfile.py")) self.assertEquals(conanfile_content, "new content") package_content = load( os.path.join( paths.package(PackageReference(new_reference, "0101001")), "package.lib")) self.assertEquals(package_content, "new lib content") # Now we are going to answer always NO to override output._stream.truncate(0) # Reset output userio = MockedBooleanUserIO(False, out=output) copier = PackageCopier(paths, userio) self._create_conanfile(reference, paths, "content22") self._create_package(reference, "0101001", paths, "newlib22") self._create_package(reference, "2222222", paths, "newlib22") copier.copy(reference, ["0101001", "2222222"], "lasote", "stable", force=False) conanfile_content = load( os.path.join(paths.export(new_reference), "conanfile.py")) self.assertEquals(conanfile_content, "new content") # Not content22 p_ref = PackageReference(new_reference, "0101001") package_content = load( os.path.join(paths.package(p_ref), "package.lib")) self.assertEquals(package_content, "new lib content") # Not newlib22 # If conanfile is not override it exist self.assertNotIn("Package '2222222' already exist. Override?", output) self.assertNotIn("Package '0101001' already exist. Override?", output) self.assertNotIn("Copied 0101001 to Hello/0.1@lasote/stable", output) self.assertNotIn("Copied 2222222 to Hello/0.1@lasote/stable", output) # Now override output._stream.truncate(0) # Reset output copier.copy(reference, ["0101001", "2222222"], "lasote", "stable", force=True) self.assertIn("Copied 0101001 to Hello/0.1@lasote/stable", output) self.assertIn("Copied 2222222 to Hello/0.1@lasote/stable", output) # Now copy just one package to another user/channel output._stream.truncate(0) # Reset output copier.copy(reference, ["0101001"], "pepe", "mychannel", force=True) self.assertIn("Copied 0101001 to Hello/0.1@pepe/mychannel", output) self.assertNotIn("Copied 2222222 to Hello/0.1@pepe/mychannel", output) new_reference = ConanFileReference.loads("Hello/0.1@pepe/mychannel") self._assert_package_exists(new_reference, "0101001", paths) self._assert_package_doesnt_exists(new_reference, "2222222", paths)
def testCopier(self): output = TestBufferConanOutput() userio = MockedBooleanUserIO(True, out=output) paths = SimplePaths(temp_folder()) copier = PackageCopier(paths, userio) # Create some packages to copy reference = ConanFileReference.loads("Hello/0.1@lasote/testing") self._create_conanfile(reference, paths) self._create_package(reference, "0101001", paths) self._create_package(reference, "2222222", paths) # Copy all to destination copier.copy(reference, ["0101001", "2222222"], "lasote", "stable", force=False) new_reference = ConanFileReference.loads("Hello/0.1@lasote/stable") self._assert_conanfile_exists(new_reference, paths) self._assert_package_exists(new_reference, "0101001", paths) self._assert_package_exists(new_reference, "2222222", paths) self.assertIn("Copied Hello/0.1@lasote/testing to Hello/0.1@lasote/stable", output) self.assertIn("Copied 0101001 to Hello/0.1@lasote/stable", output) self.assertIn("Copied 2222222 to Hello/0.1@lasote/stable", output) # Copy again, without force and answering yes output._stream.truncate(0) # Reset output copier.copy(reference, ["0101001", "2222222"], "lasote", "stable", force=False) self.assertIn("Copied Hello/0.1@lasote/testing to Hello/0.1@lasote/stable", output) self.assertIn("Copied 0101001 to Hello/0.1@lasote/stable", output) self.assertIn("Copied 2222222 to Hello/0.1@lasote/stable", output) self.assertIn("'Hello/0.1@lasote/stable' already exist. Override?", output) self.assertIn("Package '2222222' already exist. Override?", output) self.assertIn("Package '0101001' already exist. Override?", output) # Now alter the origin and copy again to same destination and confirm the copy self._create_conanfile(reference, paths, "new content") self._create_package(reference, "0101001", paths, "new lib content") self._create_package(reference, "2222222", paths, "new lib content") output._stream.truncate(0) # Reset output copier.copy(reference, ["0101001", "2222222"], "lasote", "stable", force=False) conanfile_content = load(os.path.join(paths.export(new_reference), "conanfile.py")) self.assertEquals(conanfile_content, "new content") package_content = load(os.path.join(paths.package(PackageReference(new_reference, "0101001")), "package.lib")) self.assertEquals(package_content, "new lib content") # Now we are going to answer always NO to override output._stream.truncate(0) # Reset output userio = MockedBooleanUserIO(False, out=output) copier = PackageCopier(paths, userio) self._create_conanfile(reference, paths, "content22") self._create_package(reference, "0101001", paths, "newlib22") self._create_package(reference, "2222222", paths, "newlib22") copier.copy(reference, ["0101001", "2222222"], "lasote", "stable", force=False) conanfile_content = load(os.path.join(paths.export(new_reference), "conanfile.py")) self.assertEquals(conanfile_content, "new content") # Not content22 p_ref = PackageReference(new_reference, "0101001") package_content = load(os.path.join(paths.package(p_ref), "package.lib")) self.assertEquals(package_content, "new lib content") # Not newlib22 # If conanfile is not override it exist self.assertNotIn("Package '2222222' already exist. Override?", output) self.assertNotIn("Package '0101001' already exist. Override?", output) self.assertNotIn("Copied 0101001 to Hello/0.1@lasote/stable", output) self.assertNotIn("Copied 2222222 to Hello/0.1@lasote/stable", output) # Now override output._stream.truncate(0) # Reset output copier.copy(reference, ["0101001", "2222222"], "lasote", "stable", force=True) self.assertIn("Copied 0101001 to Hello/0.1@lasote/stable", output) self.assertIn("Copied 2222222 to Hello/0.1@lasote/stable", output) # Now copy just one package to another user/channel output._stream.truncate(0) # Reset output copier.copy(reference, ["0101001"], "pepe", "mychannel", force=True) self.assertIn("Copied 0101001 to Hello/0.1@pepe/mychannel", output) self.assertNotIn("Copied 2222222 to Hello/0.1@pepe/mychannel", output) new_reference = ConanFileReference.loads("Hello/0.1@pepe/mychannel") self._assert_package_exists(new_reference, "0101001", paths) self._assert_package_doesnt_exists(new_reference, "2222222", paths)