示例#1
0
def set_saved_dir(file_pathe:FilePathe):
    try:
        saved_dir = file_pathe.path
        get_mothership(router).set_saved_dir(saved_dir)
        return return_success(f"saved_dir set to ({saved_dir})")
    except Exception as e:
        raise raised_exception("failed to set (saved_dir)", e)
示例#2
0
def stop_scheduled_jobs():
    try:
        assert get_continuous(router).is_running(), "should be running when trying to stop"
        get_continuous(router).stop_running_continuously()
        return return_success("stopped running")
    except Exception as e:
        raise raised_exception("failed to stop running", e)
示例#3
0
def get_saved_dir():
    try:
        saved_dir = get_mothership(router).get_saved_dir()
        file_pathe = FilePathe(path=saved_dir)
        return return_success(file_pathe)
    except Exception as e:
        raise raised_exception("failed to get (saved_dir)", e)
示例#4
0
def remove_action(action_name: str):
    try:
        get_mothership(router).remove_action(action_name=action_name)
        return return_success(
            f"action ({action_name}) was successfully removed")
    except Exception as e:
        raise raised_exception(f"failed to remove action ({action_name})", e)
示例#5
0
def start_scheduled_jobs():
    try:
        assert not get_continuous(router).is_running(), "should not be running when trying to start"
        get_continuous(router).run_continuously()
        return return_success("started running")
    except Exception as e:
        raise raised_exception("failed to start running", e)
示例#6
0
def add_scheduler(scheduler_name:str, scheduler=Depends(resolve_scheduler)):
    try:
        assert scheduler, f"couldn't resolve class for scheduler ({scheduler_name})"
        get_mothership(router).add_scheduler(scheduler_name=scheduler_name, scheduler=scheduler)
        return return_success(f"scheduler ({scheduler_name}) was successfully added")
    except Exception as e:
        raise raised_exception(f"failed to add scheduler ({scheduler_name})", e)
示例#7
0
def get_action(action_name: str):
    try:
        action = get_mothership(router).get_action(action_name=action_name)
        return return_success(action)
    except Exception as e:
        raise raised_exception(
            f"failed to retrieve the action ({action_name})", e)
示例#8
0
def add_action(action_name: str, action=Depends(resolve_action)):
    try:
        assert action, f"couldn't resolve class for action ({action_name})"
        get_mothership(router).add_action(action_name=action_name,
                                          action=action)
        return return_success(f"action ({action_name}) was successfully added")
    except Exception as e:
        raise raised_exception(f"failed to add action ({action_name})", e)
示例#9
0
def update_action(action_name: str, dictionary: dict):
    try:
        get_mothership(router).update_action(action_name=action_name,
                                             dictionary=dictionary)
        return return_success(
            f"action ({action_name}) was successfully updated")
    except Exception as e:
        raise raised_exception(f"failed to update action ({action_name})", e)
示例#10
0
def unschedule_action(action_name: str):
    try:
        get_mothership(router).unschedule_action(action_name=action_name)
        return return_success(
            f"action ({action_name}) was successfully unscheduled")
    except Exception as e:
        raise raised_exception(f"failed to unschedule action ({action_name})",
                               e)
示例#11
0
def execute_action(action_name: str):
    try:
        result = get_mothership(router).execute_action(action_name=action_name)
        return return_success({
            'msg': f"action ({action_name}) was successfully executed",
            'result': result
        })
    except Exception as e:
        raise raised_exception(f"failed to execute action ({action_name})", e)
示例#12
0
def load_from_name(name:str):
    try:
        return return_success(get_mothership(router).load_from_name(name))
    except Exception as e:
        raise raised_exception(f"failed to retrieve the Mothership from ({name})", e)
示例#13
0
def execute_scheduler_actions(scheduler_name:str):
    try:
        result = get_mothership(router).execute_scheduler_actions(scheduler_name=scheduler_name)
        return return_success({'msg': f"scheduler ({scheduler_name}) actions were successfully executed", 'result':result})
    except Exception as e:
        raise raised_exception(f"failed to execute scheduler ({scheduler_name}) actions", e)
示例#14
0
def update_scheduler(scheduler_name:str, dictionary:dict):
    try:
        get_mothership(router).update_scheduler(scheduler_name=scheduler_name, dictionary=dictionary)
        return return_success(f"scheduler ({scheduler_name}) was successfully updated")
    except Exception as e:
        raise raised_exception(f"failed to update scheduler ({scheduler_name})", e)
示例#15
0
def reschedule_all_schedulers():
    try:
        get_mothership(router).reschedule_all_schedulers()
        return return_success("all schedulers were successfully unscheduled")
    except Exception as e:
        raise raised_exception("failed to unschedule all schedulers", e)
示例#16
0
def unschedule_scheduler(scheduler_name:str):
    try:
        get_mothership(router).unschedule_scheduler(scheduler_name=scheduler_name)
        return return_success(f"scheduler ({scheduler_name}) was successfully unscheduled")
    except Exception as e:
        raise raised_exception(f"failed to unschedule scheduler ({scheduler_name})", e)
示例#17
0
def job_count():
    try:
        return return_success({'job_count':get_continuous(router).job_count()})
    except Exception as e:
        raise raised_exception("failed to get job count", e)
示例#18
0
def clear_mothership():
    try:
        get_mothership(router).clear_all()
        return return_success("mothership cleared")
    except Exception as e:
        raise raised_exception("failed to clear the Mothership", e)
示例#19
0
def load():
    try:
        return return_success(get_mothership(router).load_current())
    except Exception as e:
        raise raised_exception("failed to retrieve the Mothership", e)
示例#20
0
def save():
    try:
        get_mothership(router).save_current()
        return return_success(f"mothership saved to current")
    except Exception as e:
        raise raised_exception("failed to save the Mothership", e)
示例#21
0
def get_scheduler(scheduler_name:str):
    try:
        scheduler = get_mothership(router).get_scheduler(scheduler_name=scheduler_name)
        return return_success(scheduler)
    except Exception as e:
        raise raised_exception(f"failed to retrieve the scheduler ({scheduler_name})", e)
示例#22
0
def save_to_name(name:str):
    try:
        get_mothership(router).save_to_name(name)
        return return_success(f"mothership saved to ({name})")
    except Exception as e:
        raise raised_exception(f"failed to save the Mothership to ({name})", e)
示例#23
0
def schedule_action(scheduler_name:str, action_name:str):
    try:
        get_mothership(router).schedule_action(scheduler_name=scheduler_name, action_name=action_name)
        return return_success(f"action ({action_name}) was successfully scheduled ({scheduler_name})")
    except Exception as e:
        raise raised_exception(f"failed to schedule ({scheduler_name}) action ({action_name})", e)