예제 #1
0
def go():

    global config

    # Set up the destination directory
    mymkdir(config['destdir'])
    os.chdir(config['destdir'])

    # Authenticate if we should
    if config.has_key('-a'):
        libphoto.authenticate(config['baseurl'],
            config['-a'], config['passwd'])

    if os.path.exists("index.xml"):
        if config.has_key('-f'):
            timefn(fetchIndex, "index fetch")
    else:
        timefn(fetchIndex, "index fetch")
    idx=timefn(parseIndex, "index parse")

    if not config.has_key('-p'):
        # Write out all of the pages and get images and stuff
        writePages(idx)

    # Write out the search index
    writeSearchIndex(idx)
예제 #2
0
파일: load-couch.py 프로젝트: dustin/photo
    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()