コード例 #1
0
ファイル: test_fileIO.py プロジェクト: norro/ecto
def test_fileO(Scheduler, file_like_object, realfile=False):
    global cards, filetext
    plasm = ecto.Plasm()
    printer = ecto_test.FileO(file=ecto.ostream(file_like_object))
    dealer = ecto.Dealer(tendril=printer.inputs.at('input'), iterable=cards)
    plasm.connect(dealer['out'] >> printer['input'])
    sched = Scheduler(plasm)
    sched.execute()

    if not realfile:
        file_like_object.seek(0)
        result = ''.join([x for x in file_like_object])
        print result
        assert result == filetext
コード例 #2
0
def test_fileO(Scheduler, file_like_object, realfile=False):
    global cards, filetext
    plasm = ecto.Plasm()
    printer = ecto_test.FileO(file=ecto.ostream(file_like_object))
    dealer = ecto.Dealer(tendril=printer.inputs.at('input'), iterable=cards)
    plasm.connect(dealer['out'] >> printer['input'])
    sched = Scheduler(plasm)
    sched.execute()

    if not realfile:
        file_like_object.seek(0)
        result = ''.join([x for x in file_like_object])
        print result
        assert result == filetext
コード例 #3
0
ファイル: Stream.py プロジェクト: trinhtrannp/hcrdocker
def ecto_process(conn):
    import ecto
    from ecto_opencv.highgui import VideoCapture, imshow, FPSDrawer, ImageJpgWriter
    updator = ImageUpdator(conn=conn)
    video_cap = VideoCapture(video_device=0, width=1000, height=1000)
    fps = FPSDrawer()
    file = StringIO()
    writer = ImageJpgWriter(file=ecto.ostream(file))
    plasm = ecto.Plasm()
    plasm.connect(video_cap['image'] >> fps['image'],
                  fps['image'] >> writer['image'],
                  writer['file'] >> updator['ostream']
                  )
    sched = ecto.schedulers.Singlethreaded(plasm)
    sched.execute()
コード例 #4
0
def test_tendrils_serialization():
    t = ecto.Tendrils()
    t.declare("Hello",ecto.Tendril.createT('std::string'))

    t.declare("Woot",ecto.Tendril.createT('double'))
    t.Hello = 'World'
    t.Woot = math.pi
    ofs = StringIO()
    t.save(ecto.ostream(ofs))

    #grab the string
    ifs = StringIO(ofs.getvalue())

    t_ds = ecto.Tendrils()
    t_ds.load(ecto.istream(ifs))
    print 'loaded:'
    for key, val in t_ds.iteritems():
        print key, val.val
    assert t_ds.Woot == math.pi
    assert t_ds.Hello == 'World'
コード例 #5
0
def test_tendrils_serialization():
    t = ecto.Tendrils()
    t.declare("Hello", ecto.Tendril.createT('std::string'))

    t.declare("Woot", ecto.Tendril.createT('double'))
    t.Hello = 'World'
    t.Woot = math.pi
    ofs = StringIO()
    t.save(ecto.ostream(ofs))

    #grab the string
    ifs = StringIO(ofs.getvalue())

    t_ds = ecto.Tendrils()
    t_ds.load(ecto.istream(ifs))
    print 'loaded:'
    for key, val in t_ds.iteritems():
        print key, val.val
    assert t_ds.Woot == math.pi
    assert t_ds.Hello == 'World'