Esempio n. 1
0
def writeSetContentsCB(fs):
    try:
        with ruv.unstashingFS(fs) as (vat, sc):
            assert isinstance(sc, SetContents)
            size = intmask(fs.c_result)
            if size > 0:
                sc.written(size)
            elif size < 0:
                msg = ruv.formatError(size).decode("utf-8")
                sc.fail(u"libuv error: %s" % msg)
    except:
        print "Exception in writeSetContentsCB"
Esempio n. 2
0
File: files.py Progetto: dckc/typhon
def writeSetContentsCB(fs):
    try:
        with ruv.unstashingFS(fs) as (vat, sc):
            assert isinstance(sc, SetContents)
            size = intmask(fs.c_result)
            if size > 0:
                sc.written(size)
            elif size < 0:
                msg = ruv.formatError(size).decode("utf-8")
                sc.fail(u"libuv error: %s" % msg)
    except:
        print "Exception in writeSetContentsCB"
Esempio n. 3
0
File: files.py Progetto: dckc/typhon
def writeCB(fs):
    try:
        with ruv.unstashingFS(fs) as (vat, drain):
            assert isinstance(drain, FileDrain)
            size = intmask(fs.c_result)
            if size > 0:
                drain.written(size)
            elif size < 0:
                msg = ruv.formatError(size).decode("utf-8")
                drain.abort(u"libuv error: %s" % msg)
    except:
        print "Exception in writeCB"
Esempio n. 4
0
def writeCB(fs):
    try:
        with ruv.unstashingFS(fs) as (vat, drain):
            assert isinstance(drain, FileDrain)
            size = intmask(fs.c_result)
            if size > 0:
                drain.written(size)
            elif size < 0:
                msg = ruv.formatError(size).decode("utf-8")
                drain.abort(u"libuv error: %s" % msg)
    except:
        print "Exception in writeCB"
Esempio n. 5
0
def writeFileCB(fs):
    try:
        with ruv.unstashingFS(fs) as (vat, sink):
            assert isinstance(sink, FileSink)
            size = intmask(fs.c_result)
            if size > 0:
                # XXX backpressure drain.written(size)
                pass
            elif size < 0:
                msg = ruv.formatError(size).decode("utf-8")
                sink.abort(StrObject(u"libuv error: %s" % msg))
    except:
        print "Exception in writeFileCB"
Esempio n. 6
0
File: files.py Progetto: dckc/typhon
def openSetContentsCB(fs):
    try:
        fd = intmask(fs.c_result)
        with ruv.unstashingFS(fs) as (vat, sc):
            assert isinstance(sc, SetContents)
            if fd < 0:
                msg = ruv.formatError(fd).decode("utf-8")
                sc.fail(u"Couldn't open file fount: %s" % msg)
                # Done with fs.
                ruv.fsDiscard(fs)
            else:
                sc.startWriting(fd, fs)
    except:
        print "Exception in openSetContentsCB"
Esempio n. 7
0
def openSetContentsCB(fs):
    try:
        fd = intmask(fs.c_result)
        with ruv.unstashingFS(fs) as (vat, sc):
            assert isinstance(sc, SetContents)
            if fd < 0:
                msg = ruv.formatError(fd).decode("utf-8")
                sc.fail(u"Couldn't open file fount: %s" % msg)
                # Done with fs.
                ruv.fsDiscard(fs)
            else:
                sc.startWriting(fd, fs)
    except:
        print "Exception in openSetContentsCB"
Esempio n. 8
0
def readFileCB(fs):
    size = intmask(fs.c_result)
    with ruv.unstashingFS(fs) as (vat, source):
        assert isinstance(source, FileSource)
        with scopedVat(vat):
            if size > 0:
                data = charpsize2str(source._buf.c_base, size)
                source.deliver(data)
            elif size < 0:
                msg = ruv.formatError(size).decode("utf-8")
                source.abort(u"libuv error: %s" % msg)
            else:
                # EOF.
                source.complete()
Esempio n. 9
0
File: files.py Progetto: dckc/typhon
def readCB(fs):
    # Does *not* invoke user code.
    try:
        size = intmask(fs.c_result)
        with ruv.unstashingFS(fs) as (vat, fount):
            assert isinstance(fount, FileFount)
            # Done with fs, but don't free it; it belongs to the fount.
            if size > 0:
                data = charpsize2str(fount.buf.c_base, size)
                fount.receive(data)
            elif size < 0:
                msg = ruv.formatError(size).decode("utf-8")
                fount.abort(u"libuv error: %s" % msg)
            else:
                fount.stop(u"End of file")
    except:
        print "Exception in readCB"
Esempio n. 10
0
def readCB(fs):
    # Does *not* invoke user code.
    try:
        size = intmask(fs.c_result)
        with ruv.unstashingFS(fs) as (vat, fount):
            assert isinstance(fount, FileFount)
            # Done with fs, but don't free it; it belongs to the fount.
            if size > 0:
                data = charpsize2str(fount.buf.c_base, size)
                fount.receive(data)
            elif size < 0:
                msg = ruv.formatError(size).decode("utf-8")
                fount.abort(u"libuv error: %s" % msg)
            else:
                fount.stop(u"End of file")
    except:
        print "Exception in readCB"