예제 #1
0
파일: cube.py 프로젝트: AaronZhangL/mining
def cube_post(mongodb, slug=None):
    ret = post(mongodb, collection, opt={'status': False})
    try:
        cube = json.loads(ret)
        process.delay(cube)
    except TypeError:
        pass

    return ret
예제 #2
0
def cube_post(mongodb, slug=None):
    ret = post(mongodb, collection, opt={'status': False})
    try:
        cube = json.loads(ret)
        process.delay(cube)
    except TypeError:
        pass

    return ret
예제 #3
0
def rules(cube,
          scheduler_type='minutes',
          scheduler_interval=59,
          dashboard=None):
    if scheduler_type:
        scheduler_type = cube.get('scheduler_type', 'minutes')
    if scheduler_interval:
        scheduler_interval = cube.get('scheduler_interval', 59)

    log_it("START REGISTER", "bin-scheduler")
    log_it("cube: {}".format(cube.get('slug')), "bin-scheduler")
    log_it("type: {}".format(scheduler_type), "bin-scheduler")
    log_it("interval: {}".format(scheduler_interval), "bin-scheduler")
    log_it("END REGISTER", "bin-scheduler")

    t = {}
    if scheduler_type == 'minutes':
        env = schedule.every(int(scheduler_interval))
        t = env.minutes
    elif scheduler_type == 'hour':
        env = schedule.every()
        t = env.hour
    elif scheduler_type == 'day':
        env = schedule.every()
        t = env.day
    else:
        return False

    jobn = cube.get("slug")
    try:
        t.do(job, cube=cube)
        if dashboard:
            jobn = u"{}-{}".format(cube.get("slug"), dashboard)
        onrun[jobn] = env
        register.append(jobn)
        if cube.get('run') != 'run':
            process.delay(cube)
    except Exception, e:
        if jobn in register:
            register.remove(jobn)
        if onrun.get(jobn):
            del onrun[jobn]
        log_it("ERROR {}: {}".format(cube.get('slug'), e))
예제 #4
0
def rules(cube, scheduler_type='minutes', scheduler_interval=59,
          dashboard=None):
    if scheduler_type:
        scheduler_type = cube.get('scheduler_type', 'minutes')
    if scheduler_interval:
        scheduler_interval = cube.get('scheduler_interval', 59)

    log_it("START REGISTER", "bin-scheduler")
    log_it("cube: {}".format(cube.get('slug')), "bin-scheduler")
    log_it("type: {}".format(scheduler_type), "bin-scheduler")
    log_it("interval: {}".format(scheduler_interval), "bin-scheduler")
    log_it("END REGISTER", "bin-scheduler")

    t = {}
    if scheduler_type == 'minutes':
        env = schedule.every(int(scheduler_interval))
        t = env.minutes
    elif scheduler_type == 'hour':
        env = schedule.every()
        t = env.hour
    elif scheduler_type == 'day':
        env = schedule.every()
        t = env.day
    else:
        return False

    jobn = cube.get("slug")
    try:
        t.do(job, cube=cube)
        if dashboard:
            jobn = u"{}-{}".format(cube.get("slug"), dashboard)
        onrun[jobn] = env
        register.append(jobn)
        if cube.get('run') != 'run':
            process.delay(cube)
    except Exception, e:
        if jobn in register:
            register.remove(jobn)
        if onrun.get(jobn):
            del onrun[jobn]
        log_it("ERROR {}: {}".format(cube.get('slug'), e))
예제 #5
0
def job(cube):
    log_it("START JOB: {}".format(cube.get('slug')), "bin-scheduler")
    process.delay(cube)
    log_it("END JOB: {}".format(cube.get('slug')), "bin-scheduler")
예제 #6
0
파일: cube.py 프로젝트: AaronZhangL/mining
def cube_put(mongodb, slug=None):
    ret = put(mongodb, collection, slug, opt={'status': False})
    cube = json.loads(ret)
    process.delay(cube)
    return ret
예제 #7
0
def cube_put(mongodb, slug=None):
    ret = put(mongodb, collection, slug, opt={'status': False})
    cube = json.loads(ret)
    process.delay(cube)
    return ret
예제 #8
0
def job(cube):
    log_it("START JOB: {}".format(cube.get('slug')), "bin-scheduler")
    process.delay(cube)
    log_it("END JOB: {}".format(cube.get('slug')), "bin-scheduler")