예제 #1
0
파일: main.py 프로젝트: thomasvs/dad
    def addOptions(self):
        # FIXME: is this the right place ?
        log.init()
        # from dad.configure import configure
        log.debug("dad", "This is dad version %s (%s)", "0.0.0", "0")
        #    configure.version, configure.revision)

        self.parser.add_option('-v', '--version',
                          action="store_true", dest="version",
                          help="show version information")
예제 #2
0
파일: gentest.py 프로젝트: thomasvs/dad
def main():
    log.init()

    # this rebinds and makes it break in views
    # db = couchdb.CouchDB('localhost', dbName='dad')
    db = couchdb.CouchDB('localhost')
    dadDB = daddb.DADDB(db, 'dad')
    d = slice(dadDB)
    d.addCallback(lambda _: reactor.stop())
    return d
예제 #3
0
파일: consistency.py 프로젝트: thomasvs/dad
def main():
    log.init()

    server = 'localhost'
    if len(sys.argv) > 1:
        server = sys.argv[1]

    dbName = 'dad'
    if len(sys.argv) > 2:
        dbName = sys.argv[2]

    # this rebinds and makes it break in views
    # db = couchdb.CouchDB('localhost', dbName='dad')
    log.debug('main', 'binding to couchdb %r', server)
    db = couchdb.CouchDB(server)
    log.debug('main', 'checking database %r', dbName)
    d = check(db, dbName)
    d.addCallback(lambda _: reactor.stop())
    return d
예제 #4
0
파일: online.py 프로젝트: thomasvs/dad
def main():
    log.init()
    server = 'localhost'
    if len(sys.argv) > 1:
        server = sys.argv[1]

    dbName = 'dad'
    if len(sys.argv) > 2:
        dbName = sys.argv[2]

    # this rebinds and makes it break in views
    # db = couchdb.CouchDB('localhost', dbName='dad')
    db = cachedb.CachingCouchDB(server)
    dadDB = daddb.DADDB(db, dbName)

    d = defer.Deferred()
    
    # get Volume and Directory into the cache so that we don't do a lot
    # of parallel lookups for them
    d.addCallback(lambda _: dadDB.viewDocs(
        'directory-lookup', couch.Directory, include_docs=True))
    d.addCallback(lambda _: log.debug('online', '%d directories', len(list(_))))
    d.addCallback(lambda _: dadDB.viewDocs(
        'volumes', couch.Volume, include_docs=True))
    d.addCallback(lambda _: log.debug('online', '%d volumes', len(list(_))))

    # now check stuff
    # audiofiles first, so we seed the cache before checking tracks
    d.addCallback(lambda _: audiofiles(dadDB))
    d.addCallback(lambda _: tracks(dadDB))
    d.addCallback(lambda _: slices(dadDB))

    d.addCallback(lambda _: reactor.stop())

    def eb(f):
        print 'ERROR: ', log.getFailureMessage(f)
        reactor.stop()
    d.addErrback(eb)

    d.callback(None)
    return d
예제 #5
0
파일: daemon.py 프로젝트: thomasvs/dad
def main():
    import optparse

    log.init()

    parser = optparse.OptionParser()

    parser.add_option('-s', '--slave',
        action="store_true", dest="slave",
        help="start as a slave to the daemon")

    options, args = parser.parse_args(sys.argv[1:])

    print 'running reactor'

    if not options.slave:
        reactor.callLater(0, mainMaster)
    else:
        reactor.callLater(0, mainSlave)

    reactor.run()
예제 #6
0
파일: trackloader.py 프로젝트: thomasvs/dad
                    print 'INFO: but no attack/decay'
                    if not slice.attack:
                        slice.attack = tm.attack
                    if not slice.decay:
                        slice.decay = tm.decay
                    if not opts.dryrun:
                        print "INFO: Storing slice attack/decay"
                        slice.store(cdb)
                    else:
                        print "INFO: Dry run, not storing slice attack/decay"

            #return

class OptionParser(optparse.OptionParser):
    standard_option_list = couchs.couchdb_option_list + \
        [
            optparse.Option('-d', '--dry-run',
                action="store_true", dest="dryrun",
                help="Do not change database (defaults to %default)",
                default=False),
        ]
                
if __name__ == '__main__':
    log.init()

    parser = OptionParser()
    opts, args = parser.parse_args(sys.argv[1:])
    
    for path in args:
        load(opts, path)
예제 #7
0
파일: playlist.py 프로젝트: thomasvs/dad
def main():
    log.init()

    parser = optparse.OptionParser()

    parser.add_option('-c', '--category',
        action="store", dest="category",
        help="category to make playlist for",
        default="Good")

    parser.add_option('-a', '--above',
        action="store", dest="above",
        help="lower bound for scores",
        default="0.7")
    parser.add_option('-b', '--below',
        action="store", dest="below",
        help="upper bound for scores",
        default="1.0")

    parser.add_option('-l', '--limit',
        action="store", dest="limit",
        help="limit number of items",
        default=None)

    parser.add_option('-u', '--user',
        action="store", dest="user",
        help="user")



    opts, args = parser.parse_args(sys.argv)

    serverName = 'localhost'
    if len(args) > 1:
        serverName = args[1]

    dbName = 'dad'
    if len(args) > 2:
        dbName = args[2]

    # this rebinds and makes it break in views
    # db = couchdb.CouchDB('localhost', dbName='dad')
    server = couchdb.CouchDB(serverName)
    dadDB = daddb.DADDB(server, dbName)

    d = dadDB.getPlaylist(opts.user, opts.category,
        float(opts.above), float(opts.below),
        limit=opts.limit and int(opts.limit) or None)

    def showPaths(result):
        resultList = list(result)
        log.debug('playlist', 'got %r paths resolved', len(resultList))

        for succeeded, result in resultList:
            if not succeeded:
                print 'ERROR', result
            else:
                (track, slice, path, score, userId) = result
                print path.encode('utf-8')

    d.addCallback(showPaths)

    # stop at the end
    d.addCallback(lambda _: reactor.stop())
    d.addErrback(log.warningFailure, swallow=False)
    d.addErrback(lambda _: reactor.stop())

    return d