Exemplo n.º 1
0
    def __install(self, config):
        remove_common_prefix = (config.has('remove_common_prefix') and
                                config.is_affirmative('remove_common_prefix'))
        destination = config.get(
            'target', self.directory.install_directory(self.feature_name))
        url_type = config.get('type', config.get('url'))
        try:
            if url_type.endswith("tar.gz") or url_type.endswith(
                    "tar.bz2") or url_type.endswith("tar"):
                lib.extract_targz(config.get('url'),
                                  destination,
                                  remove_common_prefix=remove_common_prefix)

            elif config.get('type', config.get('url')).endswith("zip"):
                lib.extract_zip(config.get('url'),
                                destination,
                                remove_common_prefix=remove_common_prefix)

            elif config.get('type', config.get('url')).endswith("dmg"):
                if not system.is_osx():
                    self.logger.warn(
                        "Non OSX based distributions can not install a dmg!")
                else:
                    lib.extract_dmg(config.get('url'),
                                    destination,
                                    remove_common_prefix=remove_common_prefix)
        except ExtractException:
            self.logger.warn("Unable to extract file for feature %s" %
                             self.feature_name)
Exemplo n.º 2
0
 def test_zip(self):
     """ Test if the zip extract works """
     TEST_URI = "http://testme.com/test.zip"
     httpretty.register_uri(httpretty.GET, TEST_URI,
                            body=open("./test_data/test_zip.zip", 'rb').read())
     test_dir = tempfile.mkdtemp()
     try:
         lib.extract_zip(TEST_URI, test_dir, remove_common_prefix=True)
         assert os.path.exists(os.path.join(test_dir, "sprinter"))
         assert os.path.isdir(os.path.join(test_dir, "sprinter"))
     finally:
         shutil.rmtree(test_dir)
Exemplo n.º 3
0
 def test_zip(self):
     """ Test if the zip extract works """
     TEST_URI = "http://testme.com/test.zip"
     httpretty.register_uri(httpretty.GET, TEST_URI,
                            body=open("./test_data/test_zip.zip", 'rb').read())
     test_dir = tempfile.mkdtemp()
     try:
         lib.extract_zip(TEST_URI, test_dir, remove_common_prefix=True)
         assert os.path.exists(os.path.join(test_dir, "sprinter"))
         assert os.path.isdir(os.path.join(test_dir, "sprinter"))
     finally:
         shutil.rmtree(test_dir)
Exemplo n.º 4
0
 def test_zip_with_overwrite(self):
     """ Test if the zip extract works, and overwrites """
     TEST_URI = "http://testme.com/test.zip"
     httpretty.register_uri(httpretty.GET, TEST_URI,
                            body=open("./test_data/test_zip.zip").read())
     test_dir = tempfile.mkdtemp()
     try:
         os.mkdir(os.path.join(test_dir, "sprinter"))
         lib.extract_zip(TEST_URI, test_dir, remove_common_prefix=True)
         assert not os.path.exists(os.path.join(test_dir, "sprinter", "sprinter"))
         lib.extract_zip(TEST_URI, test_dir, remove_common_prefix=True, overwrite=True)
         assert os.path.exists(os.path.join(test_dir, "sprinter", "formulas"))
     finally:
         shutil.rmtree(test_dir)
Exemplo n.º 5
0
    def __install(self, config):
        remove_common_prefix = config.has("remove_common_prefix") and config.is_affirmative("remove_common_prefix")
        destination = config.get("target", self.directory.install_directory(self.feature_name))
        try:
            if config.get("type", config.get("url")).endswith("tar.gz"):
                lib.extract_targz(config.get("url"), destination, remove_common_prefix=remove_common_prefix)

            elif config.get("type", config.get("url")).endswith("zip"):
                lib.extract_zip(config.get("url"), destination, remove_common_prefix=remove_common_prefix)

            elif config.get("type", config.get("url")).endswith("dmg"):
                if not self.system.isOSX():
                    self.logger.warn("Non OSX based distributions can not install a dmg!")
                else:
                    lib.extract_dmg(config.get("url"), destination, remove_common_prefix=remove_common_prefix)
        except ExtractException:
            self.logger.warn("Unable to extract file for feature %s" % self.feature_name)
Exemplo n.º 6
0
    def __install(self, config):
        remove_common_prefix = (config.has('remove_common_prefix') and
                                config.is_affirmative('remove_common_prefix'))
        url_type = config.get('type', config.get('url'))
        try:
            if url_type.endswith("tar.gz") or url_type.endswith("tar.bz2") or url_type.endswith("tar"):
                lib.extract_targz(config.get('url'), self._get_destination(),
                                  remove_common_prefix=remove_common_prefix)

            elif config.get('type', config.get('url')).endswith("zip"):
                lib.extract_zip(config.get('url'), self._get_destination(),
                                remove_common_prefix=remove_common_prefix)

            elif config.get('type', config.get('url')).endswith("dmg"):
                if not system.is_osx():
                    self.logger.warn("Non OSX based distributions can not install a dmg!")
                else:
                    lib.extract_dmg(config.get('url'), self._get_destination(),
                                    remove_common_prefix=remove_common_prefix)
        except ExtractException:
            self.logger.warn("Unable to extract file for feature %s" % self.feature_name)