Exemple #1
0
def insert_archive_entry_archive(session, archive_entry):
    tzfilename = make_archive_entry_zipfile(session, archive_entry)
    tzentries = parse_archive_file(tzfilename, sha256sum=True)
    os.remove(tzfilename)
    entry_id = archive_entry.id
    for entry in tzentries:
        pass
Exemple #2
0
def insert_archive_entry_archive_files(session, sha256sum=True,
                                       toplevel=True, rarfiles=False):
    entries = get_archive_entry_archive_files_query(session)
    for entry in entries:
        tzfilename = make_archive_entry_zipfile(session, entry)
        tzentries = parse_archive_file(tzfilename, sha256sum=True)
        os.remove(tzfilename)
Exemple #3
0
def insert_archive_file(session, afile, sha256sum=True,
                        archive_data=None, annexpath=None):
    archived = session.query(ArchiveFile).get(afile.id)
    if archived is None:
        print "need to archive", afile.name
        if archive_data is None:
            filename = afile.name
            if annexpath is not None:
                filename = os.path.join(annexpath, afile.name)
            entries = parse_archive_file(filename, sha256sum=sha256sum)
        else:
            entries = archive_data['entries']
    else:
        print "Archive should be available"
        return
    if archive_data is None:
        archive_type = get_archive_type(afile.name)
    else:
        archive_type = archive_data['archive_type']
    af = ArchiveFile()
    af.id = afile.id
    af.archive_type = archive_type
    session.add(af)
    for entry in entries:
        dbkey = get_archive_entry_key(session, entry, oldkey=True)
        #import pdb ; pdb.set_trace()
        dbobj = ArchiveEntry()
        populate_db_archive_entry(dbobj, entry, archive_type)
        dbobj.archive_id = afile.id
        dbobj.key_id = dbkey.id
        if archive_data is not None:
            dbobj.date_time = datetime.strptime(dbobj.date_time, dt_isoformat)
            for att in ['ctime', 'mtime', 'atime']:
                value = getattr(dbobj, att)
                if value  is not None: 
                    dt = datetime.strptime(value, dt_isoformat)
                    setattr(dbobj, att, dt)
        session.add(dbobj)
    session.commit()
    print "Successful commit of %s with %d entries" % (afile.name, len(entries))