예제 #1
0
def initialize_annex_keys(session, find_output_filename):
    filename = find_output_filename
    keys = set()
    with file(filename) as infile:
        while True:
            try:
                line = infile.next()
            except StopIteration:
                break
            data = gitannex.parse_json_line(line, convert_to_unicode=True, verbose_warning=True)
            keys.add(data["key"])
    for k in keys:
        dbk = AnnexKey()
        dbk.name = k
        session.add(dbk)
    print "added %d keys" % len(keys)
    print datetime.now()
    session.commit()
    print "successful commit", datetime.now()
예제 #2
0
파일: gitannex.py 프로젝트: umeboshi2/tenyu
 def populate_files(self):
     proc = self.pmgr.make_find_proc()
     count = 0
     while proc.returncode is None:
         try:
             line = proc.stdout.next()
             count +=1
         except StopIteration:
             break
         data = gitannex.parse_json_line(
             line,
             convert_to_unicode=True,
             verbose_warning=True)
         key = data['key']
         dbkey = self.keymgr.get_by_name(key)
         if dbkey is None:
             dbkey = self.keymgr.add_key(key)
         self.add_file(data, dbkey.id)
     if proc.returncode:
         msg = "find proc returned %d" % proc.returncode
         raise RuntimeError, msg
예제 #3
0
def add_files(session, keylookup, find_output_filename):
    with file(find_output_filename) as infile:
        count = 0
        current = datetime.now()
        while True:
            try:
                line = infile.next()
                count += 1
            except StopIteration:
                break
            data = gitannex.parse_json_line(line, convert_to_unicode=True, verbose_warning=True)
            commit = False
            add_file_to_database(session, keylookup, data)
            if not count % 5000:
                commit = True
                print "Committing %d files" % count
                now = datetime.now()
                print "Diff", now - current
                current = now
                session.commit()
        print "%d files added." % count
        session.commit()
        print datetime.now()