Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)

        def compress_file(file_path, compress_path):
    seven_zip = get_7zip_path()
    if seven_zip:
        process = Popen([seven_zip,
                        'a', '-tgzip',
                         #'-mx=9', '-mfb=257', '-mpass=15',
                         compress_path, file_path],
                        stdout=PIPE, stderr=PIPE)
        output, _ = process.communicate()
        retcode = process.poll()
        if retcode:
            LOG.error('Failed to compress file "%s" as "%s": %s', file_path, compress_path, str(output))
            return False
        else:
            return True
    else:
        cache_dir = dirname(compress_path)
        if not isdir(cache_dir):
            os.makedirs(cache_dir)
        try:
            with GzipFile(compress_path, mode='wb', compresslevel=9) as gzipfile:
                with open(file_path, 'rb') as f:
                    gzipfile.write(f.read())
        except IOError as e:
            LOG.error(str(e))
            return False
        LOG.warning('Using Python for GZip compression, install 7zip for optimal performance')
        return True
        


src/t/u/turbulenz_local-1.1.4/turbulenz_local/middleware/gzipcompress.py   turbulenz_local(Download)
# pylint: enable=F0401
 
from turbulenz_local.tools import compress_file
 
 
                source_mtime, source_size = _get_file_stats(game_file_path)
                if cached_mtime < source_mtime:
                    if not compress_file(game_file_path, cached_game_file_path):
                        start_response(start_response_args['status'], start_response_args['headers'])
                        return response

src/t/u/turbulenz_local-HEAD/turbulenz_local/middleware/gzipcompress.py   turbulenz_local(Download)
# pylint: enable=F0401
 
from turbulenz_local.tools import compress_file
 
 
                source_mtime, source_size = _get_file_stats(game_file_path)
                if cached_mtime < source_mtime:
                    if not compress_file(game_file_path, cached_game_file_path):
                        start_response(start_response_args['status'], start_response_args['headers'])
                        return response