Exemple #1
0
def execute(optlist,args):
    path = '../../data'
    logpath = '/tmp/indium.log'
    alt = False
    arg = False
    mode = None
    
    for (opt,val) in optlist:
        if opt in ('-c','-d','-g','-s','-r','-F'):
            mode = opt
            arg = True
        elif opt == '-p':
            path = val
        elif opt == '-a':
            alt = True
        elif opt == '-l':
            logpath = val
            
        if opt == '-r':
            arg = False
    
    script = sys.argv[0]
    if arg:
        file = args[0]
    
    os.chdir(os.path.dirname(script))
    setup_logging(logpath)
    
    if mode == None:
        usage()
    
    logging.getLogger('indium').info("optlist=%s args='%s'" % (optlist,args))
    
    if mode == '-c':
        process_calendar.process_calendar(path,file)
    elif mode == '-d':
        process_details.process_details(path,file)
    elif mode == '-g':
        process_details.generate_calendar(path,file)
    elif mode == '-s':
        process_details.process_spreadsheet(path,file,alt)
    elif mode == '-r':
        process_details.process_all(path)
    elif mode == '-F':
        generate_feeds.generate_feeds(path,args,alt)
    else:
        usage()
Exemple #2
0
def execute(optlist, args):
    path = '../../data'
    logpath = '/tmp/indium.log'
    alt = False
    arg = False
    mode = None

    for (opt, val) in optlist:
        if opt in ('-c', '-d', '-g', '-s', '-r', '-F'):
            mode = opt
            arg = True
        elif opt == '-p':
            path = val
        elif opt == '-a':
            alt = True
        elif opt == '-l':
            logpath = val

        if opt == '-r':
            arg = False

    script = sys.argv[0]
    if arg:
        file = args[0]

    os.chdir(os.path.dirname(script))
    setup_logging(logpath)

    if mode == None:
        usage()

    logging.getLogger('indium').info("optlist=%s args='%s'" % (optlist, args))

    if mode == '-c':
        process_calendar.process_calendar(path, file)
    elif mode == '-d':
        process_details.process_details(path, file)
    elif mode == '-g':
        process_details.generate_calendar(path, file)
    elif mode == '-s':
        process_details.process_spreadsheet(path, file, alt)
    elif mode == '-r':
        process_details.process_all(path)
    elif mode == '-F':
        generate_feeds.generate_feeds(path, args, alt)
    else:
        usage()
Exemple #3
0
def process_calendar(path,id):
    logger = logging.getLogger('indium')    
    # Detect changs and news and farm off to relevant method
    cal_fn = os.path.join(path,"cal_%s.json" % id)
    cal = json.load(file(cal_fn))
    (cd,new) = caldata.CalData.from_json(cal)
    changed = set()
    for r in new:
        changed.add(process_new_rectangle(path,cd,r))    
    rs = cd.all_individual_rectangles()
    for (cid,rs) in cd.each_course_individual_rectangles():
        if len(rs):
            if update_details(path,cid,rs):
                changed.add(cid)
    # run corresponding details process to update calendar
    for cid in changed:
        logger.info("  regenerating %s" % cid)
        process_details.process_details(path,cid)
def process_calendar(path, id):
    logger = logging.getLogger('indium')
    # Detect changs and news and farm off to relevant method
    cal_fn = os.path.join(path, "cal_%s.json" % id)
    cal = json.load(file(cal_fn))
    (cd, new) = caldata.CalData.from_json(cal)
    changed = set()
    for r in new:
        changed.add(process_new_rectangle(path, cd, r))
    rs = cd.all_individual_rectangles()
    for (cid, rs) in cd.each_course_individual_rectangles():
        if len(rs):
            if update_details(path, cid, rs):
                changed.add(cid)
    # run corresponding details process to update calendar
    for cid in changed:
        logger.info("  regenerating %s" % cid)
        process_details.process_details(path, cid)