def zipFile(source):
    """Compress file under zip mode
        when compress failed with return source path
    :param source: source file path
    :return: zip file path
    """
    # source = source.decode('UTF-8')
    target = source[0:source.rindex(".")] + '.zip'
    try:
        with zipfile.ZipFile(target, 'w') as zip_file:
            zip_file.write(source, source[source.startswith('/'):], zipfile.ZIP_DEFLATED)
            zip_file.close()
            __cps_rate__(source, target)
    except IOError as e:
        logger.error('Compress file[%s] with zip mode failed. Case: %s', source, str(e))
        target = source

    return target
def zipFile ( source ) : target = source [ 0 : source . rindex ( "." ) ] + '.zip' try : with zipfile . ZipFile ( target , 'w' ) as zip_file : zip_file . write ( source , source [ source . startswith ( '/' ) : ] , zipfile . ZIP_DEFLATED ) zip_file . close ( ) __cps_rate__ ( source , target ) except IOError as e : logger . error ( 'Compress file[%s] with zip mode failed. Case: %s' , source , str ( e ) ) target = source return target
Compress file under zip mode
        when compress failed with return source path
    :param source: source file path
    :return: zip file path