예제 #1
0
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))
예제 #2
0
파일: webapi.py 프로젝트: sampot/eavatar-me
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))
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
파일: webapi.py 프로젝트: sampot/eavatar-me
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)
예제 #6
0
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)
예제 #7
0
파일: webapi.py 프로젝트: sampot/eavatar-me
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)
예제 #8
0
파일: webapi.py 프로젝트: sampot/eavatar-me
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)
예제 #9
0
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))
예제 #10
0
파일: webapi.py 프로젝트: sampot/eavatar-me
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))
예제 #11
0
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)
예제 #12
0
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)
예제 #13
0
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")
예제 #14
0
파일: webapi.py 프로젝트: sampot/eavatar-me
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")