예제 #1
0
def get_autosplit(media_path):
    file = ltoUtil.get_filename(media_path)
    path = ltoUtil.get_path(media_path)
    extn = ltoUtil.get_file_extn(media_path)
    suffix = int(media_path[-6:-4])
    next_suffix = '%02d' % (suffix +1)
    new_file = file[:-6]+next_suffix+'.'+extn
    new_path = path[:-2]+next_suffix
    new_media_path = new_path + '/' + new_file
    if os.path.exists(new_media_path):
        return True
    return False
예제 #2
0
def generate_par2_tar(config, new_filepath):
    par2_redundancy = config.getint('Par2', 'redundancy')
    par2_numfiles = config.getint('Par2', 'num_files')
    par2_memory = config.getint('Par2', 'memory')
    
    fn = ltoUtil.get_filename(new_filepath)
    path = ltoUtil.get_path(new_filepath)
    
    print 'Generating PAR2 files for '+fn+'\n'
    p = subprocess.Popen('par2 create -r'+str(par2_redundancy)+' -m'+str(par2_memory)+' -n'+str(par2_numfiles)+' '+new_filepath, shell=True)
    sts = os.waitpid(p.pid, 0)
    par2files = []
    for f in os.listdir(path):
        if str(f).startswith(fn) and str(f).endswith('.par2'):
            par2files.append(f)
            
    par2filesstr = string.join(par2files, ' ')
    p = subprocess.Popen('tar -c --format='+ltoUtil.get_tar_format(config)+' -C '+path+' -f '+new_filepath+'.par2.tar '+par2filesstr, shell=True)
    sts = os.waitpid(p.pid, 0)
    for p in par2files:
        os.remove(os.path.join(path, p))