Esempio n. 1
0
def main():
    store, opts, args = parse_args()
    if opts.debug:
        debuglevel = logging.DEBUG
    else:
        debuglevel = logging.INFO
    logging.basicConfig(format='%(message)s', level=debuglevel)
    print 'Importing messages from %s to database...' % opts.list_name
    mlist = get_mailinglist(opts.list_name, store.settings, opts)
    importer = DbImporter(mlist, store, opts)
    for mbfile in args:
        print "Importing from mbox file %s" % mbfile
        importer.from_mbox(mbfile)
        if opts.verbose:
            print '  %s emails are stored into the database' \
                  % store.get_list_size(opts.list_name)
    if not opts.no_sync_mailman:
        sync_mailman(store)
    store.commit()
Esempio n. 2
0
        debuglevel = logging.INFO
    logging.basicConfig(format='%(message)s', level=debuglevel)
    print 'Upgrading the database schema and populating ' \
          'the search index if necessary...'
    try:
        settings = get_settings_from_options(opts)
    except (StoreFromOptionsError, AttributeError), e:
        parser.error(e.args[0])
    try:
        store = get_store(settings, debug=opts.debug)
    except SchemaUpgradeNeeded:
        print "Upgrading the schema..."
        store, version = create_store(settings, debug=opts.debug)
        print "Done, the current schema version is %s." % version
        print "Synchonizing data from Mailman, this can take some time..."
        sync_mailman(store)
        store.commit()
        print "  ...done!"
    else:
        print "No schema upgrade needed."



#
# Manual Mailman sync
#

def sync_mailman_cmd():
    parser = OptionParser(usage="%prog -s settings_module [-f]")
    parser.add_option("-s", "--settings", default="settings",
                      help="the Python path to a Django-like settings module")