예제 #1
0
    def test_when_there_is_password(self):

        with closing(NamedTemporaryFile(suffix='.zip')) as zipped_file:
            with TempDir() as folder:
                self.create_folder_content(folder)
                ZipCompressor.compress(folder, zipped_file.name, password='******')

            with TempDir() as folder:
                with closing(ZipFile(zipped_file.name)) as zf:
                    zf.extractall(path=folder, pwd='ok')
                    self.check_folder_content(folder)
예제 #2
0
    def test_when_no_password(self):

        with TempDir() as folder:
            self.create_folder_content(folder)

            with closing(NamedTemporaryFile(suffix='.zip')) as zf:
                ZipCompressor.compress(folder, zf.name)

                with TempDir() as folder:
                    ZipCompressor.uncompress(zf.name, folder)
                    self.check_folder_content(folder)
    def test_when_no_password(self):

        with TempDir() as folder:
            self.create_folder_content(folder)

            with closing(NamedTemporaryFile(suffix='.zip')) as zf:
                ZipCompressor.compress(folder, zf.name)

                with TempDir() as folder:
                    ZipCompressor.uncompress(zf.name, folder)
                    self.check_folder_content(folder)
    def test_when_there_is_password(self):

        with closing(NamedTemporaryFile(suffix='.zip')) as zipped_file:
            with TempDir() as folder:
                self.create_folder_content(folder)
                ZipCompressor.compress(folder, zipped_file.name, password='******')

            with TempDir() as folder:
                with closing(ZipFile(zipped_file.name)) as zf:
                    zf.extractall(path=folder, pwd='ok')
                    self.check_folder_content(folder)
예제 #5
0
    def test_uncompress_with_password(self):

        with closing(NamedTemporaryFile(suffix='.zip')) as zipped_file:
            with TempDir() as folder:
                self.create_folder_content(folder)
                ZipCompressor.compress(folder, zipped_file.name, 'apple')

            with TempDir() as folder:
                ZipCompressor.uncompress(zipped_file.name,
                                         folder,
                                         password='******')
                self.check_folder_content(folder)
    def test_uncompress_with_password(self):

        with closing(NamedTemporaryFile(suffix='.zip')) as zipped_file:
            with TempDir() as folder:
                self.create_folder_content(folder)
                ZipCompressor.compress(folder, zipped_file.name, 'apple')

            with TempDir() as folder:
                ZipCompressor.uncompress(
                    zipped_file.name,
                    folder,
                    password='******'
                )
                self.check_folder_content(folder)
예제 #7
0
    def test_when_no_password(self):

        zipped_file = os.path.join('/tmp', uuid.uuid1().hex + '.zip')

        with TempDir() as folder:
            self.create_folder_content(folder)
            ZipCompressor.compress(folder, zipped_file)

        with TempDir() as folder:
            with closing(open(os.devnull, 'w')) as null:
                subprocess.check_call(['unzip', zipped_file, '-d', folder],
                                      stdout=null,
                                      stderr=null)
                self.check_folder_content(folder)

        os.unlink(zipped_file)
def main():

    arg_parser = init_arg_parser()
    args = arg_parser.parse_args()

    with TempDir() as tempdir:
        key_names = download_logs_of_a_date(args.date, tempdir)

        if len(key_names) == 0:
            logger.warn('Cannot find any log on %s', args.date)
            return

        with closing(NamedTemporaryFile(suffix='.zip')) as zip_file:
            ZipCompressor.compress(tempdir, zip_file.name)
            upload_to_s3(zip_file.name, args.date)

        delete_logs(key_names)
예제 #9
0
def main():

    arg_parser = init_arg_parser()
    args = arg_parser.parse_args()

    with TempDir() as tempdir:
        key_names = download_logs_of_a_date(args.date, tempdir)

        if not key_names:
            logger.warn('Cannot find any log on %s', args.date)
            return

        with closing(NamedTemporaryFile(suffix='.zip')) as zip_file:
            ZipCompressor.compress(tempdir, zip_file.name)
            upload_to_s3(zip_file.name, args.date)

        delete_logs(key_names)
    def test_when_no_password(self):

        zipped_file = os.path.join('/tmp', uuid.uuid1().hex + '.zip')

        with TempDir() as folder:
            self.create_folder_content(folder)
            ZipCompressor.compress(folder, zipped_file)

        with TempDir() as folder:
            with closing(open(os.devnull, 'w')) as null:
                subprocess.check_call(
                    ['unzip', zipped_file, '-d', folder],
                    stdout=null,
                    stderr=null
                )
                self.check_folder_content(folder)

        os.unlink(zipped_file)