def load_db(): try: (confcache, confycache, authcache, papercache, pacache) = load_logger("r") cursor = connection.cursor() confcache.logtodb(cursor) confycache.logtodb(cursor) papercache.logtodb(cursor) authcache.logtodb(cursor) pacache.logtodb(cursor) transaction.commit() except Exception, e: transaction.rollback() raise
import sys, os from dblogging import load_logger import time import re ROOT = os.path.abspath('%s/../..' % os.path.abspath(os.path.dirname(__file__))) sys.path.append(ROOT) os.environ['DJANGO_SETTINGS_MODULE'] = 'confo.settings' from django.core.management import setup_environ from confo import settings setup_environ(settings) from confo.home.models import * (confcache, confycache, authcache, papercache, pacache) = load_logger("w") class FormatError(Exception): def __init__(self, message): self.message = message def process_paper(paperinfo): try: year = int(paperinfo["year"][0]) title = paperinfo["title"][0] confname = paperinfo["booktitle"][0] authors = paperinfo.get("author", []) except KeyError, e: raise FormatError("unable to get key '" + e.message + "'") if year < 1910 or year > 2020: raise FormatError("bad paper year")