コード例 #1
0
ファイル: fileWriteTest.py プロジェクト: belenix/celeste
            "ContentType" : "text/plain",
            "ReplicationParameters" : replicationParams
        }
        celestefs.create(path, attrs=fileAttrs)

    #
    # Repeatedly ingest and fill the file, read it back to compare it with the
    # original, and truncate it.  (If profiling is enabled, each repetition
    # will append information to timingsFile.)
    #
    remainingRepetitions = repetitions
    while repetitions <= 0 or remainingRepetitions > 0:
        pCat = Popen(["/bin/cat", localFile], stdout=PIPE)
        pWrite = celestefs.pwrite(path, 0, stdin=pCat.stdout)
        pWrite.communicate()

        pRead = celestefs.pread(path, 0, -1, stdout=PIPE)
        pCmp = Popen(["/usr/bin/cmp", localFile, "-"], stdin=pRead.stdout,
            stdout=PIPE)
        pCmp.communicate()[0]

        if pCmp.returncode != 0:
            print "%s does not compare identical to %s; exiting" % \
                (path, localFile)

        celestefs.setLength(path, 0)

        remainingRepetitions = remainingRepetitions - 1

    sys.exit(0)
コード例 #2
0
ファイル: offsetTest.py プロジェクト: belenix/celeste
            print "mkfs(%s, %s) failed" % (name, name)
            exit(1)

    filename = "/" + name + "/" + "file"

    #
    # Create or truncate the test file, as approriate.
    #
    if not c.fileExists(filename):
        createAttrs = {
            # "BlockSize" : "3"
            # "BlockSize" : "16"
        }
        c.create(filename, contentType="text/plain", attrs=createAttrs)
    else:
        c.setLength(filename, 0)

    #
    # Write a sequence of characters that give clues to their offsets in the
    # file.
    #
    p = c.pwrite(filename)
    p.stdin.write("0123456789012345678901234567890123456789")
    p.communicate()

    #
    # See what we have so far.
    #
    p = c.pread(filename)
    output = p.communicate()[0]
    print '%s\'s contents: "%s"' % (filename, output)