Esempio n. 1
0
def debug_instance(*args):
    worker = ScriptWorker('debug')
    root = worker.root
    print "worker contains script stuff. root is root"
    import pdb
    pdb.set_trace()
    worker.shutdown()
Esempio n. 2
0
def main(argv=sys.argv):
    worker = ScriptWorker('evolve')
    root = worker.root
    
    print 'Evolve site'
    print "\n"
    manager = ZODBEvolutionManager(root, evolve_packagename='voteit.core.evolve', sw_version=VERSION, initial_db_version=0)
    ver = manager.get_db_version()
    if ver < VERSION:
        evolve_to_latest(manager)
        print 'Evolved from %s to %s' % (ver, manager.get_db_version())
    else:
        print 'Already evolved to latest version'
    
    worker.shutdown()
Esempio n. 3
0
def update_catalog(*args):
    worker = ScriptWorker('update_catalog')
    
    cat = worker.root.catalog
    print "Clearing old data from catalog"
    cat.clear()
    
    updated_indexes = update_indexes(cat, reindex=False)
    if updated_indexes:
        print "The following indexes were added: %s" % ", ".join(updated_indexes)
    print "Performing reindex of catalog indexes and metadata. This might take some time."
    
    contents = find_all_base_content(worker.root)
    content_count = len(contents)
        
    #Note: There might be catalog aware models outside of this scope.
    #In that case, we need some way of finding them
    
    print "Found %s objects to update" % content_count
    
    i = 1
    p = 1
    for obj in contents:
        index_object(cat, obj)
        if p == 20:
            print "%s of %s done" % (i, content_count)
            p = 0
        i+=1
        p+=1
    
    print "Update complete - reindexed %s objects" % content_count
    print "Committing to database"
    transaction.commit()
    print "Done"
    
    worker.shutdown()
    
Esempio n. 4
0
def update_catalog(*args):
    worker = ScriptWorker("update_catalog")

    cat = worker.root.catalog
    print "Clearing old data from catalog"
    cat.clear()

    updated_indexes = update_indexes(cat, reindex=False)
    if updated_indexes:
        print "The following indexes were added: %s" % ", ".join(updated_indexes)
    print "Performing reindex of catalog indexes and metadata. This might take some time."

    contents = find_all_base_content(worker.root)
    content_count = len(contents)

    # Note: There might be catalog aware models outside of this scope.
    # In that case, we need some way of finding them

    print "Found %s objects to update" % content_count

    i = 1
    p = 1
    for obj in contents:
        index_object(cat, obj)
        if p == 20:
            print "%s of %s done" % (i, content_count)
            p = 0
        i += 1
        p += 1

    print "Update complete - reindexed %s objects" % content_count
    print "Committing to database"
    transaction.commit()
    print "Done"

    worker.shutdown()
Esempio n. 5
0
def crontick():

    worker = ScriptWorker('crontick')

    unixnow = timegm(utcnow().timetuple())

    #Find methods to execute and run them
    methods = _find_methods(worker)

    for method in methods:
        try:
            method(worker, unixnow)
            transaction.commit()
            print "=== Transaction for %s committed" % method
        except Exception, e:
            worker.logger.exception(e)
            transaction.abort()
            print "=== Transaction for %s aborted" % method
Esempio n. 6
0
def debug_instance(*args):
    worker = ScriptWorker('debug')
    root = worker.root
    print "worker contains script stuff. root is root"
    import pdb;pdb.set_trace()
    worker.shutdown()