def setUp(self): self.conan_reference = ConanFileReference.loads( "openssl/2.0.3@lasote/testing") self.package_reference = PackageReference(self.conan_reference, "123123123") self.tmp_dir = temp_folder() read_perms = [("*/*@*/*", "*")] write_perms = [] authorizer = BasicAuthorizer(read_perms, write_perms) self.fake_url = "http://url" updown_auth_manager = JWTUpDownAuthManager("secret", timedelta(seconds=200)) adapter = DiskAdapter(self.fake_url, self.tmp_dir, updown_auth_manager) self.paths = SimplePaths(self.tmp_dir) self.file_manager = FileManager(self.paths, adapter) self.service = ConanService(authorizer, self.file_manager, "lasote") files = hello_source_files("test") save_files(self.paths.export(self.conan_reference), files) self.conan_digest = FileTreeManifest.create( self.paths.export(self.conan_reference)) conan_digest_path = os.path.join( self.paths.export(self.conan_reference), CONAN_MANIFEST) save(conan_digest_path, str(self.conan_digest)) files = hello_source_files("package") save_files(self.paths.package(self.package_reference), files)
def file_manager(self): # FIXME: Looks like a refactor, it doesnt fix here instance file_manager or # file_manager maybe should be injected in client and all the storage work # should be done there? disk_adapter = DiskAdapter("", self._paths.store, None) file_manager = FileManager(self._paths, disk_adapter) return file_manager
def get_file_manager(config, public_url=None, updown_auth_manager=None): store_adapter = config.store_adapter if store_adapter == "disk": public_url = public_url or config.public_url disk_controller_url = "%s/%s" % (public_url, "files") if not updown_auth_manager: raise Exception("Updown auth manager needed for disk controller (not s3)") adapter = DiskAdapter(disk_controller_url, config.disk_storage_path, updown_auth_manager) paths = SimplePaths(config.disk_storage_path) else: # Want to develop new adapter? create a subclass of # conans.server.store.file_manager.StorageAdapter and implement the abstract methods raise Exception("Store adapter not implemented! Change 'store_adapter' " "variable in server.conf file to one of the available options: 'disk' ") return FileManager(paths, adapter)
def basic_test2(self): # FIXME, for searches now uses file_service, not paths. So maybe move test to another place folder = temp_folder() paths = StorePaths(folder) os.chdir(paths.store) root_folder1 = "opencv/2.4.10/lasote/testing" conan_ref1 = ConanFileReference.loads("opencv/2.4.10@lasote/testing") artif_id1 = "awqfwf44we5f425fw" artif_id2 = "b5wc4q5frg45rgv1g" artif_id3 = "cf838regrg783g453" reg1 = "%s/%s" % (root_folder1, EXPORT_FOLDER) build1 = "%s/%s/%s" % (root_folder1, BUILD_FOLDER, artif_id1) artif1 = "%s/%s/%s" % (root_folder1, PACKAGES_FOLDER, artif_id1) artif2 = "%s/%s/%s" % (root_folder1, PACKAGES_FOLDER, artif_id2) artif3 = "%s/%s/%s" % (root_folder1, PACKAGES_FOLDER, artif_id3) os.makedirs(reg1) os.makedirs(build1) os.makedirs(artif1) os.makedirs(artif2) os.makedirs(artif3) all_artif = [ _artif for _artif in sorted(paths.conan_packages(conan_ref1)) ] self.assertEqual(all_artif, [artif_id1, artif_id2, artif_id3]) root_folder2 = "sdl/1.5/lasote/stable" conan_ref2 = ConanFileReference.loads("sdl/1.5@lasote/stable") os.makedirs("%s/%s" % (root_folder2, EXPORT_FOLDER)) root_folder3 = "assimp/0.14/phil/testing" conan_ref3 = ConanFileReference.loads("assimp/0.14@phil/testing") os.makedirs("%s/%s" % (root_folder3, EXPORT_FOLDER)) root_folder4 = "sdl/2.10/lasote/stable" conan_ref4 = ConanFileReference.loads("sdl/2.10@lasote/stable") os.makedirs("%s/%s" % (root_folder4, EXPORT_FOLDER)) root_folder5 = "SDL_fake/1.10/lasote/testing" conan_ref5 = ConanFileReference.loads("SDL_fake/1.10@lasote/testing") os.makedirs("%s/%s" % (root_folder5, EXPORT_FOLDER)) # Case insensitive searches disk_adapter = DiskAdapter("", paths.store, None) file_manager = FileManager(paths, disk_adapter) reg_conans = sorted( [str(_reg) for _reg in file_manager._exported_conans()]) self.assertEqual(reg_conans, [ str(conan_ref5), str(conan_ref3), str(conan_ref1), str(conan_ref2), str(conan_ref4) ]) reg_conans = sorted([ str(_reg) for _reg in file_manager._exported_conans(pattern="sdl*") ]) self.assertEqual(reg_conans, [str(conan_ref5), str(conan_ref2), str(conan_ref4)]) # Case sensitive search self.assertEqual( str( file_manager._exported_conans(pattern="SDL*", ignorecase=False)[0]), str(conan_ref5))
def basic_test2(self): # FIXME, for searches now uses file_service, not paths. So maybe move test to another place folder = temp_folder() paths = StorePaths(folder) os.chdir(paths.store) root_folder1 = "opencv/2.4.10/lasote/testing" conan_ref1 = ConanFileReference.loads("opencv/2.4.10@lasote/testing") artif_id1 = "awqfwf44we5f425fw" artif_id2 = "b5wc4q5frg45rgv1g" artif_id3 = "cf838regrg783g453" reg1 = "%s/%s" % (root_folder1, EXPORT_FOLDER) build1 = "%s/%s/%s" % (root_folder1, BUILD_FOLDER, artif_id1) artif1 = "%s/%s/%s" % (root_folder1, PACKAGES_FOLDER, artif_id1) artif2 = "%s/%s/%s" % (root_folder1, PACKAGES_FOLDER, artif_id2) artif3 = "%s/%s/%s" % (root_folder1, PACKAGES_FOLDER, artif_id3) os.makedirs(reg1) os.makedirs(build1) os.makedirs(artif1) os.makedirs(artif2) os.makedirs(artif3) all_artif = [_artif for _artif in sorted(paths.conan_packages(conan_ref1))] self.assertEqual(all_artif, [artif_id1, artif_id2, artif_id3]) root_folder2 = "sdl/1.5/lasote/stable" conan_ref2 = ConanFileReference.loads("sdl/1.5@lasote/stable") os.makedirs("%s/%s" % (root_folder2, EXPORT_FOLDER)) root_folder3 = "assimp/0.14/phil/testing" conan_ref3 = ConanFileReference.loads("assimp/0.14@phil/testing") os.makedirs("%s/%s" % (root_folder3, EXPORT_FOLDER)) root_folder4 = "sdl/2.10/lasote/stable" conan_ref4 = ConanFileReference.loads("sdl/2.10@lasote/stable") os.makedirs("%s/%s" % (root_folder4, EXPORT_FOLDER)) root_folder5 = "SDL_fake/1.10/lasote/testing" conan_ref5 = ConanFileReference.loads("SDL_fake/1.10@lasote/testing") os.makedirs("%s/%s" % (root_folder5, EXPORT_FOLDER)) # Case insensitive searches disk_adapter = DiskAdapter("", paths.store, None) file_manager = FileManager(paths, disk_adapter) reg_conans = sorted([str(_reg) for _reg in file_manager._exported_conans()]) self.assertEqual(reg_conans, [str(conan_ref5), str(conan_ref3), str(conan_ref1), str(conan_ref2), str(conan_ref4)]) reg_conans = sorted([str(_reg) for _reg in file_manager._exported_conans(pattern="sdl*")]) self.assertEqual(reg_conans, [str(conan_ref5), str(conan_ref2), str(conan_ref4)]) # Case sensitive search self.assertEqual(str(file_manager._exported_conans(pattern="SDL*", ignorecase=False)[0]), str(conan_ref5))