コード例 #1
0
ファイル: spawn_exec.py プロジェクト: GunioRobot/skywriting
def skypy_main():

    wc_source = skypy.spawn_exec(
        "grab", {
            "urls": ["http://www.gutenberg.org/cache/epub/4908/pg4908.html"],
            "version": 0
        }, 1)
    wc_input = skypy.deref_json(wc_source[0])  # Yields a single reference
    wc_result = skypy.spawn_exec("stdinout", {
        "inputs": [wc_input],
        "command_line": ["wc", "-c"]
    }, 1)
    return skypy.deref_json(wc_result[0])
コード例 #2
0
def java(class_name, input_refs, argv, jar_refs, num_outputs):
    return skypy.spawn_exec("java", {
        "inputs": input_refs,
        "class": class_name,
        "lib": jar_refs,
        "argv": argv
    }, num_outputs)
コード例 #3
0
ファイル: stream_consumer.py プロジェクト: ms705/ciel
import skypy
import sys

def skypy_main(run_seconds, async, direct):
    
    if async.find("true") != -1:
        may_stream = True
    else:
        may_stream = False
    if direct.find("true") != -1:
        try_direct = True
    else:
        try_direct = False
    tests_jar = skypy.package_lookup("java_tests")
    refs = skypy.spawn_exec("java", args={"inputs": [], "argv": [str(run_seconds)], "lib": [tests_jar], "class": "tests.JitteryProducer", "stream_output": True, "pipe_output": try_direct}, n_outputs=2)

    got_bytes = 0

    with skypy.deref_as_raw_file(refs[0], may_stream=may_stream, sole_consumer=try_direct, chunk_size=1048576) as file_in:
        while True:
            file_str = file_in.read(1048576)
            if len(file_str) == 0:
                break
            print >>sys.stderr, "Read", len(file_str), "bytes"
            got_bytes += len(file_str)
    with skypy.deref_as_raw_file(refs[1]) as n_bytes:
        byte_count = n_bytes.read()

    return "Producer wrote %s, I got %d starting with %s" % (byte_count, got_bytes, file_str[:20])
コード例 #4
0
ファイル: skyhout-kmeans.py プロジェクト: ms705/ciel
def java(class_name, input_refs, argv, jar_refs, num_outputs):
    return skypy.spawn_exec("java", {"inputs" : input_refs, "class" : class_name, "lib" : jar_refs, "argv" : argv}, num_outputs)
コード例 #5
0
ファイル: skyhout-kmeans.py プロジェクト: ms705/ciel
def grab(url):
    ref = (skypy.spawn_exec("grab", {"urls": [url], "version": 0}, 1))[0]
    return (skypy.deref_json(ref))
コード例 #6
0
ファイル: spawn_exec.py プロジェクト: ms705/ciel
def skypy_main():

    wc_source = skypy.spawn_exec("grab", {"urls":["http://www.gutenberg.org/cache/epub/4908/pg4908.html"], "version":0}, 1)
    wc_input = skypy.deref_json(wc_source[0]) # Yields a single reference
    wc_result = skypy.spawn_exec("stdinout", {"inputs": [wc_input], "command_line":["wc", "-c"]}, 1)
    return skypy.deref_json(wc_result[0])
コード例 #7
0
def grab(url):
    ref = (skypy.spawn_exec("grab", {"urls": [url], "version": 0}, 1))[0]
    return (skypy.deref_json(ref))
コード例 #8
0
import skypy
import sys


def skypy_main(run_seconds, async):

    if async .find("true") != -1:
        may_stream = True
    else:
        may_stream = False
    tests_jar = skypy.package_lookup("java_tests")
    refs = skypy.spawn_exec("java",
                            args={
                                "inputs": [],
                                "argv": [str(run_seconds)],
                                "lib": [tests_jar],
                                "class": "tests.JitteryProducer",
                                "stream_output": True
                            },
                            n_outputs=2)

    got_bytes = 0

    with skypy.deref_as_raw_file(refs[0],
                                 may_stream=may_stream,
                                 chunk_size=1048576) as file_in:
        while True:
            file_str = file_in.read(1048576)
            if len(file_str) == 0:
                break
            print >> sys.stderr, "Read", len(file_str), "bytes"