Ejemplo n.º 1
0
def encrypt_file_chunked(cb, fp, pwd, serverconfig):
    """
    @type cb: str, unicode
    @type fp: str, unicode
    @type pwd: str, unicode
    @type serverconfig: ServerConfig
    @return: None
    """
    chunksize = 1048576 * 5
    cl, chunk_size = make_chunklist(fp, chunksize)
    num_chunks = len(cl)
    chunk_num = 0
    dec_crc = str(crc32_blob(fp=open(fp)))
    commit = []

    for cs in cl:
        chunk = read_chunk(fp, cs[0], cs[1])
        tf = get_named_temporary_file(False)
        tf.write(chunk)
        tf.close()
        seek_pos = cs[0]
        commit.append((serverconfig, cb.object_id, (pwd, tf.name, chunk_num, seek_pos, dec_crc, num_chunks, chunksize)))
        chunk_num += 1

    console("chunk_num", chunk_num)
Ejemplo n.º 2
0
def main2():
    """
    main
    """
    with Events() as e:
        e.event("walk")
        mylist = []

        # os.path.walk("/Volumes/bu/Dropbox (Active8)", walker, mylist)
        os.path.walk("/Users/rabshakeh/Dropbox (Active8)", walker, mylist)
        e.event("test files")
        items = {}

        for fp in mylist:
            console(fp, once=True)
            crc = crc32_blob(open(fp))

            if crc in items:
                items[crc].append(fp)
            else:
                items[crc] = [fp]

        for crc in items:
            if len(items[crc]) > 1:
                console(crc, len(items[crc]))
                for i in items[crc]:
                    console(i)

        console(len(items), len(mylist), len(mylist) - len(items))