Ejemplo n.º 1
0
def unzip(site,
          username=None,
          host=None,
          zip_path=None,
          force=False,
          output_dir=None,
          **kwargs):

    # get zip file
    zip_file = download(site, username, host, zip_path, force)

    if output_dir is None:
        output_dir = settings.JAHIA_DATA_PATH

    try:
        return unzip_one(output_dir, site, zip_file)

    except Exception as err:
        logging.error("%s - unzip - Could not unzip file - Exception: %s",
                      site, err)
Ejemplo n.º 2
0
    def test_unzipped_files_existing(self):

        unzip_path = unzip_one(output_dir=self.OUTPUT_DIR,
                               site_name=self.TEST_JAHIA_SITE,
                               zip_file=self.TEST_FILE)

        TEST_JAHIA_SITE_PATH = os.path.join(self.OUTPUT_DIR,
                                            self.TEST_JAHIA_SITE)
        unzip_path_expected = os.path.join(TEST_JAHIA_SITE_PATH,
                                           self.TEST_JAHIA_SITE)

        assert unzip_path == unzip_path_expected

        # test if the file on-site.zip exists
        assert os.path.isfile(unzip_path + ".zip")

        # test if the directory on-site/ exists
        assert os.path.isdir(unzip_path)

        # some cleaning
        shutil.rmtree(TEST_JAHIA_SITE_PATH)