def script_check(): d = request.json try: get_job_engine().validate_script(d.get('script')) return dict(status=defines.SUCCESS) except Exception as ex: response.status = defines.HTTP_STATUS_BAD_REQUEST return dict(status=defines.ERROR, reason=str(ex))
def job_retrieve(job_id): job_info = get_job_engine().jobs.get(job_id) if job_info is None: return _not_found_error("Job not found") data = dict(id=job_info.id, name=job_info.name, st=job_info.started_time_iso) return dict(status=D.SUCCESS, data=data)
def job_delete(job_id): job_info = get_job_engine().jobs.get(job_id) if job_info is None: return _not_found_error("Job not found") try: job_engine.cancel_job(job_id) finally: return dict(status=defines.SUCCESS, data=job_id)
def job_list(): jobs = get_job_engine().jobs.values() entries = [] for it in jobs: rec = dict(id=it.id, name=it.name, st=it.started_time_iso) entries.append(rec) return dict(data=entries, status=defines.SUCCESS)
def job_retrieve(job_id): job_info = get_job_engine().jobs.get(job_id) if job_info is None: return _not_found_error("Job not found") data = dict(id=job_info.id, name=job_info.name, st=job_info.started_time_iso) return dict(status=defines.SUCCESS, data=data)
def job_create(): _logger.debug("job_create") try: job_data = request.json except ValueError: response.status = defines.HTTP_STATUS_BAD_REQUEST return dict(status=defines.ERROR, reason='No valid JSON object.') if job_data is None: response.status = defines.HTTP_STATUS_BAD_REQUEST return dict(status=defines.ERROR, reason='No script provided.') try: job_id = get_job_engine().submit_job(job_data) return dict(status=defines.SUCCESS, data=job_id) except (ScriptSyntaxError, SyntaxError) as ex: response.status = defines.HTTP_STATUS_BAD_REQUEST return dict(status=defines.ERROR, reason=str(ex))
def job_create(): _logger.debug("job_create") try: job_data = request.json except ValueError: response.status = D.HTTP_STATUS_BAD_REQUEST return dict(status=D.ERROR, reason='No valid JSON object.') print("job_create: DATA: ", job_data) if job_data is None: response.status = D.HTTP_STATUS_BAD_REQUEST return dict(status=D.ERROR, reason='No script provided.') try: job_id = get_job_engine().submit_job(job_data) return dict(status=D.SUCCESS, data=job_id) except ScriptSyntaxError as ex: response.status = D.HTTP_STATUS_BAD_REQUEST return dict(status=D.ERROR, reason=ex.message)
from ava import data as stores from ava.job import Script from ava.job.errors import ScriptSyntaxError from .dispatcher import dispatcher from .service import require_auth, require_json, get_access_token from . import defines _logger = logging.getLogger(__name__) api = Bottle() dispatcher.mount('/api', api) job_engine = get_job_engine() def _not_found_error(reason='Resource not found.'): response.status = defines.HTTP_STATUS_NOT_FOUND return dict(status=defines.ERROR, reason=reason) @api.route("/ping") def ping(): """ Simple ping test """ return dict(status=defines.SUCCESS) @api.route("/auth")
from ava.job import get_job_engine from ava import data as stores from ava.job import Script from ava.job.errors import ScriptSyntaxError from .dispatcher import dispatcher from .service import require_auth, require_json, get_access_token from . import defines _logger = logging.getLogger(__name__) api = Bottle() dispatcher.mount('/api', api) job_engine = get_job_engine() def _not_found_error(reason='Resource not found.'): response.status = defines.HTTP_STATUS_NOT_FOUND return dict(status=defines.ERROR, reason=reason) @api.route("/ping") def ping(): """ Simple ping test """ return dict(status=defines.SUCCESS) @api.route("/auth")