Ejemplo n.º 1
0
    :ui_name status: Job status
    :default status: Dummy status

    :param desc: Dummy job description
    :type desc: kbtypes.Unicode
    :ui_name desc: Job description
    :default desc: Dummy job description

    :param complete: Dummy job est. completion
    :type complete: kbtypes.Unicode
    :ui_name complete: Dummy completion time (timestamp)
    :default complete: 2020-04-03T08:56:32+0000
    
    :rtype: kbtypes.Unicode
    :return: job info
    """
    meth.stages = 2
    meth.advance("Creating dummy job")

    ujs = UserAndJobState(url=service.URLS.user_and_job_state,
                          token=meth.token)
    progress = {'ptype': 'none'}
    job_info = ujs.create_and_start_job(meth.token, status, desc, progress,
                                        complete)

    meth.advance("Done!")
    return json.dumps(job_info)


finalize_service()
Ejemplo n.º 2
0
    """Run a Perl command. Maybe. 
    
    :return: A string
    :rtype: kbtypes.Unicode
    """
    meth.stages = 2  # for reporting progress
    meth.advance("Starting...")

    from IPython import get_ipython
    ipy = get_ipython()

    meth.advance("Running")
    ipy.run_cell_magic('perl', 
                       '--out perl_lines', 
                       'use JSON;'
                       'my $token = $ENV{"KB_AUTH_TOKEN"};'
                       'my @arr = ("foo", "bar", "baz");'
                       'my $foo;'
                       '$foo->{"what"}=\@arr;'
                       '$foo->{"token"}=$token;'
                       'print encode_json($foo);')
    
    res = ipy.user_variables(['perl_lines'])['perl_lines']['data']['text/plain'][1:-1]
    res = json.loads(res)
    return json.dumps({'lines' : res})



# Finalize (registers service)
finalize_service()