Example #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()
Example #2
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
Example #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()