Ejemplo n.º 1
0
def main(args):
    wiki.init()

    wikidata = wiki.load()

    print "Running..."
    while True:
        requests = get_requests()
        if len(requests):
            print "Got %s requests: " % len(requests), requests
        reads, writes = moses(requests)

        # process writes before reads so readers get the latest data
        for write in writes:
            if write['txt'].startswith('!'):
                set_command(write['txt'][1:], write)
            else:
                wiki.write(write, wikidata)
            
        wiki.dump(wikidata)

        for read in reads:
            if read['txt'].startswith('!'):
                run_command(read['txt'][1:], read)
            else:
                wiki.read(read, wikidata)

        time.sleep(3)
Ejemplo n.º 2
0
def main(args):
    wiki.init()

    wikidata = wiki.load()

    print "Running..."
    while True:
        requests = get_requests()
        if len(requests):
            print "Got %s requests: " % len(requests), requests
        reads, writes = moses(requests)

        # process writes before reads so readers get the latest data
        for write in writes:
            wiki.write(write, wikidata)
            
        wiki.dump(wikidata)

        for read in reads:
            wiki.read(read, wikidata)

        time.sleep(3)