Ejemplo n.º 1
0
    def test_export_a_new_version(self):
        self._create_packages_and_builds()
        # Export an update of the same conans

        conan2 = TestClient(self.conan.base_folder)
        files2 = cpp_hello_conan_files("Hello0", "0.1")
        files2[CONANFILE] = "# insert comment\n %s" % files2[CONANFILE]
        conan2.save(files2)
        conan2.run("export lasote/stable")

        reg_path3 = conan2.paths.export(self.conan_ref)
        digest3 = FileTreeManifest.loads(load(conan2.paths.digestfile_conanfile(self.conan_ref)))

        self.assertIn('A new conanfile.py version was exported', conan2.user_io.out)
        self.assertIn('%s: conanfile.py exported to local storage' % str(self.conan_ref),
                      self.conan.user_io.out)
        self.assertIn('%s: Folder: %s' % (str(self.conan_ref), reg_path3), self.conan.user_io.out)

        self.assertTrue(os.path.exists(reg_path3))

        for name in files2.keys():
            self.assertTrue(os.path.exists(os.path.join(reg_path3, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': 'bc3405da4bb0b51a3b9f05aca71e58c8',
                         'conanfile.py': 'c5889ea6485599c7a0cae02b54270b35',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, digest3.file_sums)
Ejemplo n.º 2
0
    def test_export_a_new_version(self):
        self._create_packages_and_builds()
        # Export an update of the same conans

        conan2 = TestClient(self.conan.base_folder)
        files2 = cpp_hello_conan_files("Hello0", "0.1")
        files2[CONANFILE] = "# insert comment\n %s" % files2[CONANFILE]
        conan2.save(files2)
        conan2.run("export lasote/stable")

        reg_path3 = conan2.paths.export(self.conan_ref)
        digest3 = FileTreeManifest.loads(load(conan2.paths.digestfile_conanfile(self.conan_ref)))

        self.assertIn('%s: A new conanfile.py version was exported' % str(self.conan_ref),
                      self.conan.user_io.out)
        self.assertIn('%s: Folder: %s' % (str(self.conan_ref), reg_path3), self.conan.user_io.out)

        self.assertTrue(os.path.exists(reg_path3))

        for name in list(files2.keys()):
            self.assertTrue(os.path.exists(os.path.join(reg_path3, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': '52546396c42f16be3daf72ecf7ab7143',
                         'conanfile.py': 'ad17cf00b3142728b03ac37782b9acd9',
                         'executable': '68b329da9893e34099c7d8ad5cb9c940',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, digest3.file_sums)
Ejemplo n.º 3
0
    def test_export_the_same_code(self):
        file_list = self._create_packages_and_builds()
        # Export the same conans

        conan2 = TestClient(self.conan.base_folder)
        files2 = cpp_hello_conan_files("Hello0", "0.1")
        conan2.save(files2)
        conan2.run("export lasote/stable")
        reg_path2 = conan2.paths.export(self.conan_ref)
        digest2 = FileTreeManifest.loads(load(conan2.paths.digestfile_conanfile(self.conan_ref)))

        self.assertNotIn('A new Conan version was exported', conan2.user_io.out)
        self.assertNotIn('Cleaning the old builds ...', conan2.user_io.out)
        self.assertNotIn('Cleaning the old packs ...', conan2.user_io.out)
        self.assertNotIn('All the previous packs were cleaned', conan2.user_io.out)
        self.assertIn('%s: conanfile.py exported to local storage' % str(self.conan_ref),
                      self.conan.user_io.out)
        self.assertIn('%s: Folder: %s' % (str(self.conan_ref), reg_path2), self.conan.user_io.out)
        self.assertTrue(os.path.exists(reg_path2))

        for name in files2.keys():
            self.assertTrue(os.path.exists(os.path.join(reg_path2, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': 'bc3405da4bb0b51a3b9f05aca71e58c8',
                         'conanfile.py': 'f21a98d974e9294b0d709070042c6e78',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, digest2.file_sums)

        for f in file_list:
            self.assertTrue(os.path.exists(f))
Ejemplo n.º 4
0
    def test_rel_path(self):
        base_folder = temp_folder()
        source_folder = os.path.join(base_folder, "source")
        current_folder = os.path.join(base_folder, "current")
        os.makedirs(current_folder)
        client = TestClient(current_folder=current_folder)
        files = cpp_hello_conan_files("Hello0", "0.1")
        conan_ref = ConanFileReference("Hello0", "0.1", "lasote", "stable")
        client.save(files, path=source_folder)
        client.run("export lasote/stable --path=../source")
        reg_path = client.paths.export(conan_ref)
        manif = FileTreeManifest.loads(load(client.paths.digestfile_conanfile(conan_ref)))

        self.assertIn('%s: A new conanfile.py version was exported' % str(conan_ref),
                      client.user_io.out)
        self.assertIn('%s: Folder: %s' % (str(conan_ref), reg_path), client.user_io.out)
        self.assertTrue(os.path.exists(reg_path))

        for name in list(files.keys()):
            self.assertTrue(os.path.exists(os.path.join(reg_path, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': '52546396c42f16be3daf72ecf7ab7143',
                         'conanfile.py': '355949fbf0b4fc32b8f1c5a338dfe1ae',
                         'executable': '68b329da9893e34099c7d8ad5cb9c940',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, manif.file_sums)
Ejemplo n.º 5
0
    def test_tree_manifest(self):
        tmp_dir = temp_folder()
        files = {"one.ext": "aalakjshdlkjahsdlkjahsdljkhsadljkhasljkdhlkjashd",
                 "path/to/two.txt": "asdas13123",
                 "two.txt": "asdasdasdasdasdasd",
                 "folder/damn.pyc": "binarythings",
                 "folder/damn.pyo": "binarythings2",
                 "pythonfile.pyc": "binarythings3"}
        for filename, content in files.items():
            save(os.path.join(tmp_dir, filename), content)

        manifest = FileTreeManifest.create(tmp_dir)

        save(os.path.join(tmp_dir, "THEMANIFEST.txt"), str(manifest))

        readed_manifest = FileTreeManifest.loads(load(os.path.join(tmp_dir, "THEMANIFEST.txt")))

        self.assertEqual(readed_manifest.time, manifest.time)
        self.assertEqual(readed_manifest, manifest)
        # Not included the pycs or pyo
        self.assertEquals(set(manifest.file_sums.keys()),
                          set(["one.ext", "path/to/two.txt", "two.txt"]))

        for filepath, md5readed in manifest.file_sums.items():
            content = files[filepath]
            self.assertEquals(md5(content), md5readed)
Ejemplo n.º 6
0
    def test_export_the_same_code(self):
        file_list = self._create_packages_and_builds()
        # Export the same conans

        conan2 = TestClient(self.conan.base_folder)
        files2 = cpp_hello_conan_files("Hello0", "0.1")
        conan2.save(files2)
        conan2.run("export lasote/stable")
        reg_path2 = conan2.paths.export(self.conan_ref)
        digest2 = FileTreeManifest.loads(load(conan2.paths.digestfile_conanfile(self.conan_ref)))

        self.assertNotIn('A new Conan version was exported', conan2.user_io.out)
        self.assertNotIn('Cleaning the old builds ...', conan2.user_io.out)
        self.assertNotIn('Cleaning the old packs ...', conan2.user_io.out)
        self.assertNotIn('All the previous packs were cleaned', conan2.user_io.out)
        self.assertIn('conanfile.py exported as %s in %s'
                      % (self.conan_ref, reg_path2), conan2.user_io.out)
        self.assertTrue(os.path.exists(reg_path2))

        for name in files2.keys():
            self.assertTrue(os.path.exists(os.path.join(reg_path2, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': '310d65b60943b879286cf8839cf9ba08',
                         'conanfile.py': '4df4b5266ad6d5d55cbdd0a8b12c9d1a',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, digest2.file_sums)

        for f in file_list:
            self.assertTrue(os.path.exists(f))
Ejemplo n.º 7
0
    def test_export_a_new_version(self):
        self._create_packages_and_builds()
        # Export an update of the same conans

        conan2 = TestClient(self.conan.base_folder)
        files2 = cpp_hello_conan_files("Hello0", "0.1")
        files2[CONANFILE] = "# insert comment\n %s" % files2[CONANFILE]
        conan2.save(files2)
        conan2.run("export lasote/stable")

        reg_path3 = conan2.paths.export(self.conan_ref)
        digest3 = FileTreeManifest.loads(load(conan2.paths.digestfile_conanfile(self.conan_ref)))

        self.assertIn('A new conanfile.py version was exported', conan2.user_io.out)
        # self.assertIn('All the previous packs were cleaned', conan2.user_io.out)
        self.assertIn('conanfile.py exported as %s in %s'
                      % (self.conan_ref, reg_path3), conan2.user_io.out)

        self.assertTrue(os.path.exists(reg_path3))

        for name in files2.keys():
            self.assertTrue(os.path.exists(os.path.join(reg_path3, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': '310d65b60943b879286cf8839cf9ba08',
                         'conanfile.py': '5a2c6e2d6b39638b7d8560786d7935a3',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, digest3.file_sums)
Ejemplo n.º 8
0
    def test_path(self):
        base_folder = temp_folder()
        source_folder = os.path.join(base_folder, "source")
        current_folder = os.path.join(base_folder, "current")
        client = TestClient(current_folder=current_folder)
        files = cpp_hello_conan_files("Hello0", "0.1")
        conan_ref = ConanFileReference("Hello0", "0.1", "lasote", "stable")
        conanfile = files.pop("conanfile.py")
        client.save(files, path=source_folder)
        conanfile = conanfile.replace("exports = '*'", 'exports = "../source*"')

        client.save({"conanfile.py": conanfile})
        client.run("export lasote/stable")
        reg_path = client.paths.export(conan_ref)
        manif = FileTreeManifest.loads(load(client.paths.digestfile_conanfile(conan_ref)))

        self.assertIn('%s: A new conanfile.py version was exported' % str(conan_ref),
                      client.user_io.out)
        self.assertIn('%s: Folder: %s' % (str(conan_ref), reg_path), client.user_io.out)
        self.assertTrue(os.path.exists(reg_path))

        for name in ['conanfile.py', 'conanmanifest.txt', 'source/main.cpp',
                     'source/executable', 'source/hello.cpp', 'source/CMakeLists.txt',
                     'source/helloHello0.h']:
            self.assertTrue(os.path.exists(os.path.join(reg_path, name)))

        expected_sums = {'source/hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'source/main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'source/CMakeLists.txt': '52546396c42f16be3daf72ecf7ab7143',
                         'conanfile.py': '3ac566eb5b2e4df4417003f0e606e237',
                         'source/executable': '68b329da9893e34099c7d8ad5cb9c940',
                         'source/helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, manif.file_sums)
Ejemplo n.º 9
0
    def test_basic(self):
        current_folder = temp_folder()
        source_folder = os.path.join(current_folder, "source")
        client = TestClient(current_folder=current_folder)
        files = cpp_hello_conan_files("Hello0", "0.1")
        conan_ref = ConanFileReference("Hello0", "0.1", "lasote", "stable")
        client.save(files, path=source_folder)
        client.run("export lasote/stable --path=source")
        reg_path = client.paths.export(conan_ref)
        manif = FileTreeManifest.loads(load(client.paths.digestfile_conanfile(conan_ref)))

        self.assertIn('%s: A new conanfile.py version was exported' % str(conan_ref),
                      client.user_io.out)
        self.assertIn('%s: Folder: %s' % (str(conan_ref), reg_path), client.user_io.out)
        self.assertTrue(os.path.exists(reg_path))

        for name in list(files.keys()):
            self.assertTrue(os.path.exists(os.path.join(reg_path, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': 'bc3405da4bb0b51a3b9f05aca71e58c8',
                         'conanfile.py': '5632cf850a7161388ab24f42b9bdb3fd',
                         'executable': '68b329da9893e34099c7d8ad5cb9c940',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, manif.file_sums)
Ejemplo n.º 10
0
def undo_imports(current_path, output):
    manifest_path = os.path.join(current_path, IMPORTS_MANIFESTS)
    try:
        manifest_content = load(manifest_path)
    except:
        raise ConanException("Cannot load file %s" % manifest_path)

    try:
        manifest = FileTreeManifest.loads(manifest_content)
    except:
        raise ConanException("Wrong manifest file format %s" % manifest_path)

    not_removed = 0
    files = manifest.files()
    for filepath in files:
        if not os.path.exists(filepath):
            output.warn("File doesn't exist: %s" % filepath)
            continue
        try:
            os.remove(filepath)
        except:
            output.error("Cannot remove file (open or busy): %s" % filepath)
            not_removed += 1

    if not_removed:
        raise ConanException("Cannot remove %s or more imported files" % not_removed)

    output.success("Removed %s imported files" % (len(files)))
    try:
        os.remove(manifest_path)
        output.success("Removed imports manifest file: %s" % manifest_path)
    except:
        raise ConanException("Cannot remove manifest file (open or busy): %s" % manifest_path)
Ejemplo n.º 11
0
    def test_export_the_same_code(self):
        file_list = self._create_packages_and_builds()
        # Export the same conans

        conan2 = TestClient(self.conan.base_folder)
        files2 = cpp_hello_conan_files("Hello0", "0.1")
        conan2.save(files2)
        conan2.run("export lasote/stable")
        reg_path2 = conan2.paths.export(self.conan_ref)
        digest2 = FileTreeManifest.loads(load(conan2.paths.digestfile_conanfile(self.conan_ref)))

        self.assertNotIn('A new Conan version was exported', conan2.user_io.out)
        self.assertNotIn('Cleaning the old builds ...', conan2.user_io.out)
        self.assertNotIn('Cleaning the old packs ...', conan2.user_io.out)
        self.assertNotIn('All the previous packs were cleaned', conan2.user_io.out)
        self.assertIn('%s: A new conanfile.py version was exported' % str(self.conan_ref),
                      self.conan.user_io.out)
        self.assertIn('%s: Folder: %s' % (str(self.conan_ref), reg_path2), self.conan.user_io.out)
        self.assertTrue(os.path.exists(reg_path2))

        for name in list(files2.keys()):
            self.assertTrue(os.path.exists(os.path.join(reg_path2, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': '52546396c42f16be3daf72ecf7ab7143',
                         'conanfile.py': '355949fbf0b4fc32b8f1c5a338dfe1ae',
                         'executable': '68b329da9893e34099c7d8ad5cb9c940',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, digest2.file_sums)

        for f in file_list:
            self.assertTrue(os.path.exists(f))
Ejemplo n.º 12
0
 def _check_manifest(self):
     manifest_content = load(os.path.join(self.client.current_folder, IMPORTS_MANIFESTS))
     manifest = FileTreeManifest.loads(manifest_content)
     self.assertEqual(manifest.file_sums,
                      {os.path.join(self.client.current_folder, "file1.txt"):
                       "8b1a9953c4611296a827abf8c47804d7",
                       os.path.join(self.client.current_folder, "file2.txt"):
                       "f5a7924e621e84c9280a9a27e1bcb7f6"})
Ejemplo n.º 13
0
 def valid_digest(self, digest_path):
     if not os.path.exists(digest_path):
         return False
     expected_digest = FileTreeManifest.create(os.path.dirname(digest_path))
     del expected_digest.file_sums[CONAN_MANIFEST]  # Exclude the MANIFEST itself
     expected_digest.file_sums.pop(CONANFILE + "c", None)  # Exclude the CONANFILE.pyc
     expected_digest.file_sums.pop(".DS_Store", None)  # Exclude tmp in mac
     readed_digest = FileTreeManifest.loads(load(digest_path))
     return readed_digest.file_sums == expected_digest.file_sums
Ejemplo n.º 14
0
    def get_conan_digest(self, conan_reference):
        """Gets a FileTreeManifest from conans"""

        # Obtain the URLs
        url = "%s/conans/%s/digest" % (self._remote_api_url, "/".join(conan_reference))
        urls = self._get_json(url)

        # Get the digest
        contents = self.download_files(urls)
        contents = dict(contents)  # Unroll generator
        return FileTreeManifest.loads(contents[CONAN_MANIFEST])
Ejemplo n.º 15
0
    def get_conan_digest(self, conan_reference):
        """Gets a FileTreeManifest from conans"""

        # Obtain the URLs
        url = "%s/conans/%s/digest" % (self._remote_api_url, "/".join(conan_reference))
        urls = self._get_json(url)

        # Get the digest
        contents = self.download_files(urls)
        contents = {key: decode_text(value) for key, value in dict(contents).items()}  # Unroll generator and decode shas (plain text)
        return FileTreeManifest.loads(contents[CONAN_MANIFEST])
Ejemplo n.º 16
0
    def already_pyc_in_manifest_test(self):
        tmp_dir = temp_folder()
        save(os.path.join(tmp_dir, "man.txt"), "1478122267\nconanfile.pyc: "
                                               "2bcac725a0e6843ef351f4d18cf867ec\n"
                                               "conanfile.py: 2bcac725a0e6843ef351f4d18cf867ec",
                                               "conanfile.pyo: 2bcac725a0e6843ef351f4d18cf867ec")

        read_manifest = FileTreeManifest.loads(load(os.path.join(tmp_dir, "man.txt")))
        # Not included the pycs or pyo
        self.assertEquals(set(read_manifest.file_sums.keys()),
                          set(["conanfile.py"]))
Ejemplo n.º 17
0
def _init_export_folder(destination_folder):
    previous_digest = None
    try:
        if os.path.exists(destination_folder):
            if os.path.exists(os.path.join(destination_folder, CONAN_MANIFEST)):
                manifest_content = load(os.path.join(destination_folder, CONAN_MANIFEST))
                previous_digest = FileTreeManifest.loads(manifest_content)
            # Maybe here we want to invalidate cache
            rmdir(destination_folder)
        os.makedirs(destination_folder)
    except Exception as e:
        raise ConanException("Unable to create folder %s\n%s" % (destination_folder, str(e)))
    return previous_digest
Ejemplo n.º 18
0
    def _check(self, reference, manifest, remote, path):
        if os.path.exists(path):
            existing_manifest = FileTreeManifest.loads(load(path))
            if existing_manifest.file_sums == manifest.file_sums:
                self._log.append("Manifest for '%s': OK" % str(reference))
                return

        if self._verify:
            raise ConanException("Modified or new manifest '%s' detected.\n"
                                 "Remote: %s\nProject manifest doesn't match installed one"
                                 % (str(reference), remote))

        self._handle_add(reference, remote, manifest, path)
Ejemplo n.º 19
0
    def get_package_manifest(self, package_reference):
        """Gets a FileTreeManifest from a package"""

        # Obtain the URLs
        url = "%s/conans/%s/packages/%s/digest" % (self._remote_api_url,
                                                   "/".join(package_reference.conan),
                                                   package_reference.package_id)
        urls = self._get_file_to_url_dict(url)

        # Get the digest
        contents = self.download_files(urls)
        # Unroll generator and decode shas (plain text)
        contents = {key: decode_text(value) for key, value in dict(contents).items()}
        return FileTreeManifest.loads(contents[CONAN_MANIFEST])
Ejemplo n.º 20
0
    def _check(self, reference, manifest, remote, path):
        if os.path.exists(path):
            existing_manifest = FileTreeManifest.loads(load(path))
            if existing_manifest == manifest:
                self._log.append("Manifest for '%s': OK" % str(reference))
                return

        if self._verify:
            diff = existing_manifest.difference(manifest)
            error_msg = os.linesep.join("Mismatched checksum '%s' (manifest: %s, file: %s)"
                                        % (fname, h1, h2) for fname, (h1, h2) in diff.items())
            raise ConanException("Modified or new manifest '%s' detected.\n"
                                 "Remote: %s\nProject manifest doesn't match installed one\n%s"
                                 % (str(reference), remote, error_msg))

        self._handle_add(reference, remote, manifest, path)
Ejemplo n.º 21
0
    def test_basic(self):
        """ simple registration of a new conans
        """
        reg_path = self.conan.paths.export(self.conan_ref)
        manif = FileTreeManifest.loads(load(self.conan.paths.digestfile_conanfile(self.conan_ref)))

        self.assertIn('conanfile.py exported as %s.\nFolder: %s' % (self.conan_ref, reg_path),
                      self.conan.user_io.out)
        self.assertTrue(os.path.exists(reg_path))

        for name in self.files.keys():
            self.assertTrue(os.path.exists(os.path.join(reg_path, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': 'bc3405da4bb0b51a3b9f05aca71e58c8',
                         'conanfile.py': '79cdacbd40569a842fcd3ae5085b3cbf',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, manif.file_sums)
Ejemplo n.º 22
0
    def test_basic(self):
        """ simple registration of a new conans
        """
        reg_path = self.conan.paths.export(self.conan_ref)
        manif = FileTreeManifest.loads(load(self.conan.paths.digestfile_conanfile(self.conan_ref)))

        self.assertIn('conanfile.py exported as %s in %s' % (self.conan_ref, reg_path),
                      self.conan.user_io.out)
        self.assertTrue(os.path.exists(reg_path))

        for name in self.files.keys():
            self.assertTrue(os.path.exists(os.path.join(reg_path, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': '310d65b60943b879286cf8839cf9ba08',
                         'conanfile.py': '4df4b5266ad6d5d55cbdd0a8b12c9d1a',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, manif.file_sums)
Ejemplo n.º 23
0
    def test_basic(self):
        """ simple registration of a new conans
        """
        reg_path = self.conan.paths.export(self.conan_ref)
        manif = FileTreeManifest.loads(load(self.conan.paths.digestfile_conanfile(self.conan_ref)))

        self.assertIn('conanfile.py exported as %s in %s' % (self.conan_ref, reg_path),
                      self.conan.user_io.out)
        self.assertTrue(os.path.exists(reg_path))

        for name in self.files.keys():
            self.assertTrue(os.path.exists(os.path.join(reg_path, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': '06dc55633f00448bb528e191736a591b',
                         'conanfile.py': 'be0ef62b526bae06aceae66bc8eaf306',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, manif.file_sums)
Ejemplo n.º 24
0
    def test_tree_manifest(self):
        tmp_dir = temp_folder()
        files = {"one.ext": "aalakjshdlkjahsdlkjahsdljkhsadljkhasljkdhlkjashd",
                 "path/to/two.txt": "asdas13123",
                 "two.txt": "asdasdasdasdasdasd"}
        for filename, content in files.iteritems():
            save(os.path.join(tmp_dir, filename), content)

        manifest = FileTreeManifest.create(tmp_dir)

        save(os.path.join(tmp_dir, "THEMANIFEST.txt"), str(manifest))

        readed_manifest = FileTreeManifest.loads(load(os.path.join(tmp_dir, "THEMANIFEST.txt")))

        self.assertEquals(readed_manifest, manifest)

        for filepath, md5readed in manifest.file_sums.iteritems():
            content = files[filepath]
            self.assertEquals(md5(content), md5readed)
Ejemplo n.º 25
0
        def test_install_in(folder):
            client.current_folder = temp_folder()
            client.run("install Pkg/0.1@user/testing --install-folder=%s" % folder)

            self.assertIn("Pkg/0.1@user/testing deploy(): Copied 1 '.dll' file: mylib.dll",
                          client.out)
            self.assertIn("Pkg/0.1@user/testing deploy(): Copied 1 '.exe' file: myapp.exe",
                          client.out)
            deploy_manifest = FileTreeManifest.loads(load(os.path.join(client.current_folder,
                                                                       folder,
                                                                       "deploy_manifest.txt")))

            app = os.path.abspath(os.path.join(client.current_folder, folder, "myapp.exe"))
            if deploy_to_abs:
                lib = os.path.join(dll_folder, "mylib.dll")
            else:
                lib = os.path.abspath(os.path.join(client.current_folder, folder, "mylib.dll"))
            self.assertEqual(sorted([app, lib]),
                             sorted(deploy_manifest.file_sums.keys()))
            self.assertEqual(load(app), "myexe")
            self.assertEqual(load(lib), "mydll")
Ejemplo n.º 26
0
    def test_basic(self):
        """ simple registration of a new conans
        """
        reg_path = self.conan.paths.export(self.conan_ref)
        manif = FileTreeManifest.loads(load(self.conan.paths.digestfile_conanfile(self.conan_ref)))

        self.assertIn('%s: conanfile.py exported to local storage' % str(self.conan_ref),
                      self.conan.user_io.out)
        self.assertIn('%s: Folder: %s' % (str(self.conan_ref), reg_path), self.conan.user_io.out)
        self.assertTrue(os.path.exists(reg_path))

        for name in list(self.files.keys()):
            self.assertTrue(os.path.exists(os.path.join(reg_path, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': 'bc3405da4bb0b51a3b9f05aca71e58c8',
                         'conanfile.py': '5632cf850a7161388ab24f42b9bdb3fd',
                         'executable': '68b329da9893e34099c7d8ad5cb9c940',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, manif.file_sums)
Ejemplo n.º 27
0
    def test_basic(self):
        """ simple registration of a new conans
        """
        reg_path = self.conan.paths.export(self.conan_ref)
        manif = FileTreeManifest.loads(load(self.conan.paths.digestfile_conanfile(self.conan_ref)))

        self.assertIn('%s: A new conanfile.py version was exported' % str(self.conan_ref),
                      self.conan.user_io.out)
        self.assertIn('%s: Folder: %s' % (str(self.conan_ref), reg_path), self.conan.user_io.out)
        self.assertTrue(os.path.exists(reg_path))

        for name in list(self.files.keys()):
            self.assertTrue(os.path.exists(os.path.join(reg_path, name)))

        expected_sums = {'hello.cpp': '4f005274b2fdb25e6113b69774dac184',
                         'main.cpp': '0479f3c223c9a656a718f3148e044124',
                         'CMakeLists.txt': '52546396c42f16be3daf72ecf7ab7143',
                         'conanfile.py': '355949fbf0b4fc32b8f1c5a338dfe1ae',
                         'executable': '68b329da9893e34099c7d8ad5cb9c940',
                         'helloHello0.h': '9448df034392fc8781a47dd03ae71bdd'}
        self.assertEqual(expected_sums, manif.file_sums)
Ejemplo n.º 28
0
    def update_test(self, mode):
        self._create_code(mode)

        self.client.run("export lasote/testing")
        self.client.run("install Hello/0.1@lasote/testing --build=missing")
        self.client.run("upload Hello/0.1@lasote/testing --all")
        self.client.run('remove Hello/0.1@lasote/testing -f')
        self.client.run("install Hello/0.1@lasote/testing")

        # upload to remote again, the folder remains as installed
        self.client.run("install Hello/0.1@lasote/testing --update")
        self.assertIn("Hello/0.1@lasote/testing: Already installed!", self.client.user_io.out)
        self._check_export_installed_folder(mode)

        server_path = self.server.paths.export(self.reference)
        save(os.path.join(server_path, "license.txt"), "mylicense")
        manifest_path = os.path.join(server_path, "conanmanifest.txt")
        manifest = FileTreeManifest.loads(load(manifest_path))
        manifest.time += 1
        manifest.file_sums["license.txt"] = md5sum(os.path.join(server_path, "license.txt"))
        save(manifest_path, str(manifest))

        self.client.run("install Hello/0.1@lasote/testing --update")
        self._check_export_installed_folder(mode, updated=True)
Ejemplo n.º 29
0
    def _upload_recipe(self, ref, conanfile, retry, retry_wait, policy, remote,
                       remotes):

        current_remote_name = self._cache.package_layout(
            ref).load_metadata().recipe.remote

        if remote.name != current_remote_name:
            complete_recipe_sources(self._remote_manager, self._cache,
                                    conanfile, ref, remotes)

        conanfile_path = self._cache.package_layout(ref).conanfile()
        self._hook_manager.execute("pre_upload_recipe",
                                   conanfile_path=conanfile_path,
                                   reference=ref,
                                   remote=remote)

        t1 = time.time()
        the_files = self._compress_recipe_files(ref)

        with self._cache.package_layout(ref).update_metadata() as metadata:
            metadata.recipe.checksums = calc_files_checksum(the_files)

        local_manifest = FileTreeManifest.loads(
            load(the_files["conanmanifest.txt"]))

        remote_manifest = None
        if policy != UPLOAD_POLICY_FORCE:
            # Check SCM data for auto fields
            if hasattr(conanfile,
                       "scm") and (conanfile.scm.get("url") == "auto"
                                   or conanfile.scm.get("revision") == "auto"):
                raise ConanException(
                    "The recipe has 'scm.url' or 'scm.revision' with 'auto' "
                    "values. Use '--force' to ignore this error or export again "
                    "the recipe ('conan export' or 'conan create') in a "
                    "repository with no-uncommitted changes or by "
                    "using the '--ignore-dirty' option")

            remote_manifest = self._check_recipe_date(ref, remote,
                                                      local_manifest)
        if policy == UPLOAD_POLICY_SKIP:
            return ref

        files_to_upload, deleted = self._recipe_files_to_upload(
            ref, policy, the_files, remote, remote_manifest, local_manifest)

        if files_to_upload or deleted:
            self._remote_manager.upload_recipe(ref, files_to_upload, deleted,
                                               remote, retry, retry_wait)
            self._upload_recipe_end_msg(ref, remote)
        else:
            self._output.info("Recipe is up to date, upload skipped")
        duration = time.time() - t1
        log_recipe_upload(ref, duration, the_files, remote.name)
        self._hook_manager.execute("post_upload_recipe",
                                   conanfile_path=conanfile_path,
                                   reference=ref,
                                   remote=remote)

        # The recipe wasn't in the registry or it has changed the revision field only
        if not current_remote_name:
            with self._cache.package_layout(ref).update_metadata() as metadata:
                metadata.recipe.remote = remote.name

        return ref
Ejemplo n.º 30
0
 def _digests(self, digest_path):
     if not path_exists(digest_path, self.store):
         return None, None
     readed_digest = FileTreeManifest.loads(load(digest_path))
     expected_digest = FileTreeManifest.create(os.path.dirname(digest_path))
     return readed_digest, expected_digest
Ejemplo n.º 31
0
 def load_manifest(self, conan_reference):
     """conan_id = sha(zip file)"""
     assert isinstance(conan_reference, ConanFileReference)
     filename = self.digestfile_conanfile(conan_reference)
     return FileTreeManifest.loads(load(filename))
Ejemplo n.º 32
0
 def _digests(digest_path, exports_sources_folder=None):
     readed_digest = FileTreeManifest.loads(load(digest_path))
     expected_digest = FileTreeManifest.create(os.path.dirname(digest_path),
                                               exports_sources_folder)
     return readed_digest, expected_digest
Ejemplo n.º 33
0
    def _upload_recipe(self, ref, conanfile, retry, retry_wait, policy, remote,
                       remotes):

        current_remote_name = self._cache.package_layout(
            ref).load_metadata().recipe.remote

        if remote.name != current_remote_name:
            complete_recipe_sources(self._remote_manager, self._cache,
                                    conanfile, ref, remotes)

        conanfile_path = self._cache.package_layout(ref).conanfile()
        self._hook_manager.execute("pre_upload_recipe",
                                   conanfile_path=conanfile_path,
                                   reference=ref,
                                   remote=remote)

        t1 = time.time()
        cache_files = self._compress_recipe_files(ref)

        with self._cache.package_layout(ref).update_metadata() as metadata:
            metadata.recipe.checksums = calc_files_checksum(cache_files)

        local_manifest = FileTreeManifest.loads(
            load(cache_files["conanmanifest.txt"]))

        remote_manifest = None
        if policy != UPLOAD_POLICY_FORCE:
            # Check SCM data for auto fields
            if hasattr(conanfile,
                       "scm") and (conanfile.scm.get("url") == "auto"
                                   or conanfile.scm.get("revision") == "auto"
                                   or conanfile.scm.get("type") is None
                                   or conanfile.scm.get("url") is None
                                   or conanfile.scm.get("revision") is None):
                raise ConanException(
                    "The recipe contains invalid data in the 'scm' attribute"
                    " (some 'auto' values or missing fields 'type', 'url' or"
                    " 'revision'). Use '--force' to ignore this error or export"
                    " again the recipe ('conan export' or 'conan create') to"
                    " fix these issues.")

            remote_manifest = self._check_recipe_date(ref, remote,
                                                      local_manifest)
        if policy == UPLOAD_POLICY_SKIP:
            return ref

        files_to_upload, deleted = self._recipe_files_to_upload(
            ref, policy, cache_files, remote, remote_manifest, local_manifest)

        if files_to_upload or deleted:
            self._remote_manager.upload_recipe(ref, files_to_upload, deleted,
                                               remote, retry, retry_wait)
            self._upload_recipe_end_msg(ref, remote)
        else:
            self._output.info("Recipe is up to date, upload skipped")
        duration = time.time() - t1
        log_recipe_upload(ref, duration, cache_files, remote.name)
        self._hook_manager.execute("post_upload_recipe",
                                   conanfile_path=conanfile_path,
                                   reference=ref,
                                   remote=remote)

        # The recipe wasn't in the registry or it has changed the revision field only
        if not current_remote_name:
            with self._cache.package_layout(ref).update_metadata() as metadata:
                metadata.recipe.remote = remote.name

        return ref
Ejemplo n.º 34
0
 def load_manifest(self, conan_reference):
     '''conan_id = sha(zip file)'''
     filename = self.digestfile_conanfile(conan_reference)
     return FileTreeManifest.loads(load(filename))
Ejemplo n.º 35
0
 def load_digest(self, conan_reference):
     '''conan_id = sha(zip file)'''
     filename = os.path.join(self.export(conan_reference), CONAN_MANIFEST)
     return FileTreeManifest.loads(load(filename))
Ejemplo n.º 36
0
 def load_package_manifest(self, package_reference):
     '''conan_id = sha(zip file)'''
     filename = self.digestfile_package(package_reference, short_paths=None)
     return FileTreeManifest.loads(load(filename))
Ejemplo n.º 37
0
 def _digests(self, digest_path):
     if not path_exists(digest_path, self.store):
         return None, None
     readed_digest = FileTreeManifest.loads(load(digest_path))
     expected_digest = FileTreeManifest.create(os.path.dirname(digest_path))
     return readed_digest, expected_digest
Ejemplo n.º 38
0
 def _digests(self, digest_path):
     readed_digest = FileTreeManifest.loads(load(digest_path))
     expected_digest = FileTreeManifest.create(os.path.dirname(digest_path))
     return readed_digest, expected_digest
Ejemplo n.º 39
0
 def get_package_manifest(self, package_reference):
     url = self.conans_router.package_manifest(package_reference)
     content = self._get_remote_file_contents(url)
     return FileTreeManifest.loads(decode_text(content))
Ejemplo n.º 40
0
 def load_digest(self, conan_reference):
     '''conan_id = sha(zip file)'''
     filename = os.path.join(self.export(conan_reference), CONAN_MANIFEST)
     return FileTreeManifest.loads(load(filename))
Ejemplo n.º 41
0
 def get_conan_manifest(self, ref):
     url = self.conans_router.recipe_manifest(ref)
     content = self._get_remote_file_contents(url)
     return FileTreeManifest.loads(decode_text(content))