Пример #1
0
def fetchIndex():
    global config
    print "Beginning index fetch"
    destdir=config['destdir']
    f=libphoto.fetchIndex(config['baseurl'], config.get('-u'))
    fout=open("index.xml", "w")
    shutil.copyfileobj(f, fout)
    f.close()
    fout.close()
Пример #2
0
def __makeIndex(fn):
    f=libphoto.fetchIndex(base)

    fout=gzip.GzipFile(fn + ".tmp", "w")

    shutil.copyfileobj(f, fout)
    fout.close()
    f.close()

    os.rename(fn + ".tmp", fn)
Пример #3
0
    def run(self):
        while True:
            p, dbname, docid, rev = Q.get()
            self.save_attachments(p, dbname, docid, rev)
            Q.task_done()

if __name__ == '__main__':
    base, u=sys.argv[1:]
    fn = 'index.xml'

    pw=os.getenv('PHOTO_PW')
    if pw is None:
        pw=getpass.getpass()

    url = 'http://localhost:5984/'
    c = couchdb.Server(url, full_commit=False)

    libphoto.authenticate(base, u, pw)

    libphoto.parseIndex(libphoto.fetchIndex(base), Parser(c, base))

    threads = [ImageWorker(url, base) for w in range(N_THREADS)]

    Q.join()

    for db in c:
        print "Compacting", db
        c[db].compact()