Example #1
0
def main():
    opts, args = parse_opts()
    cp = ConfigParser.ConfigParser()
    cp.read(opts.config)
    config_logging(cp, opts)

    if opts.cron > 0:
        random_sleep = random.randint(1, opts.cron)
        log.info("gratia-gold called from cron; sleeping for %d seconds." % \
            random_sleep)
        time.sleep(random_sleep)

    lockfile = cp.get("transaction", "lockfile")
    try:
        locking.exclusive_lock(lockfile)
    except Exception, e:
        log.exception("Caught an exception and the detail is: \n\"" + str(e) + "\" Exiting Now !")
        sys.exit(1)
Example #2
0
def main():
    opts, args = parse_opts()
    cp = ConfigParser.ConfigParser()
    cp.read(opts.config)
    config_logging(cp, opts)

    if opts.cron > 0:
        random_sleep = random.randint(1, opts.cron)
        log.info("gratia-xdmod called from cron; sleeping for %d seconds." % \
            random_sleep)
        time.sleep(random_sleep)

    lockfile = cp.get("transaction", "lockfile")
    locking.exclusive_lock(lockfile)
   
    iteration = 0
    job_count = 1
    while job_count > 0 and iteration < MAX_ITERATIONS:

        iteration = iteration + 1

        last_dbid = xdmod.get_last_dbid(cp)

        log.debug("Starting from DBID %d" % last_dbid)

        jobs = gratia.query_gratia(cp, last_dbid)

        job_count = 0
        for job in jobs:
            log.debug("Processing job: %s" % str(job))
            
            if not xdmod.add(cp, job):
                log.fatal("Fatal error inserting thew job in the XDMoD database - exiting!")
                return 1
            
            job_count += 1

    return 0