本文整理汇总了Python中CONFIG类的典型用法代码示例。如果您正苦于以下问题:Python CONFIG类的具体用法?Python CONFIG怎么用?Python CONFIG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CONFIG类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rmdir_nonempty
def test_rmdir_nonempty(self):
# Remove any prexisting blockstore.
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
# Create the filesystem
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSSIZE,
bsargs)
self.fs = utp.FileSystem.mkfs(CONFIG.FSTYPE, self.bs, "", "",
CONFIG.UNAME, CONFIG.GNAME, CONFIG.FSARGS)
# Create a directory.
self.fs.fs_mkdir("/top", 0555, CONFIG.UNAME, CONFIG.GNAME)
# Create a file.
self.fs.fs_mknod("/top/inside", 0666, 0, CONFIG.UNAME, CONFIG.GNAME)
# Shouldn't be able to rmdir the directory.
try:
self.fs.fs_rmdir("/top");
assert False
except OSError, ex:
assert ex.errno == ENOTEMPTY
示例2: test_unlink
def test_unlink(self):
print "Remove any prexisting blockstore."
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
print "Create the filesystem"
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSSIZE,
bsargs)
self.fs = utp.FileSystem.mkfs(CONFIG.FSTYPE, self.bs, "", "",
CONFIG.UNAME, CONFIG.GNAME, CONFIG.FSARGS)
print "Create a file"
self.fs.fs_mknod("/bar", 0666, 0, CONFIG.UNAME, CONFIG.GNAME)
print "Create a directory"
self.fs.fs_mkdir("/foo", 0555, CONFIG.UNAME, CONFIG.GNAME)
print "Now we should be able to stat the file."
st = self.fs.fs_getattr("/bar");
print "Now we should be able to stat the dir."
st = self.fs.fs_getattr("/foo");
print "Shouldn't be able to unlink the directory."
try:
self.fs.fs_unlink("/foo");
assert False
except OSError, ex:
assert ex.errno == EISDIR
print "Should be able to unlink the file."
示例3: setup_class
def setup_class(self):
self.bspath = "fs_getattr_01.bs"
# Remove any prexisting blockstore.
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
# Create the filesystem
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSSIZE,
bsargs)
self.fs = utp.FileSystem.mkfs(CONFIG.FSTYPE, self.bs, "", "",
CONFIG.UNAME, CONFIG.GNAME, CONFIG.FSARGS)
# Make a directory.
self.fs.fs_mkdir("/foo", 0755, CONFIG.UNAME, CONFIG.GNAME)
# Make a file.
self.fs.fs_mknod("/foo/bar", 0666, 0, CONFIG.UNAME, CONFIG.GNAME)
# Now we unmount the filesystem.
self.fs.fs_umount()
self.bs.bs_close()
# Now mount it again.
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.open(CONFIG.BSTYPE, "rootbs", bsargs)
self.fs = utp.FileSystem.mount(CONFIG.FSTYPE, self.bs,
"", "", CONFIG.FSARGS)
示例4: test_rmdir
def test_rmdir(self):
# Remove any prexisting blockstore.
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
# Create the filesystem
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSSIZE,
bsargs)
self.fs = utp.FileSystem.mkfs(CONFIG.FSTYPE, self.bs, "", "",
CONFIG.UNAME, CONFIG.GNAME, CONFIG.FSARGS)
# Create a file.
self.fs.fs_mknod("/bar", 0666, 0, CONFIG.UNAME, CONFIG.GNAME)
# Create a directory.
self.fs.fs_mkdir("/foo", 0555, CONFIG.UNAME, CONFIG.GNAME)
# Now we should be able to stat the file.
st = self.fs.fs_getattr("/bar");
# Now we should be able to stat the dir.
st = self.fs.fs_getattr("/foo");
# Shouldn't be able to rmdir the file.
try:
self.fs.fs_rmdir("/bar");
assert False
except OSError, ex:
assert ex.errno == ENOTDIR
示例5: test_symlink
def test_symlink(self):
# Remove any prexisting blockstore.
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
# Create the filesystem
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSSIZE,
bsargs)
self.fs = utp.FileSystem.mkfs(CONFIG.FSTYPE, self.bs, "", "",
CONFIG.UNAME, CONFIG.GNAME, CONFIG.FSARGS)
# Create a directory.
self.fs.fs_mkdir("/foo", 0555, CONFIG.UNAME, CONFIG.GNAME)
# Create a file.
self.fs.fs_mknod("/foo/bar", 0666, 0, CONFIG.UNAME, CONFIG.GNAME)
# Open the file.
self.fs.fs_open("/foo/bar", O_RDWR)
# Write some bytes into the file.
self.fs.fs_write("/foo/bar", buffer("testdata"))
# Check clash w/ existing file.
try:
self.fs.fs_symlink("/blahblah", "/foo/bar");
assert False
except OSError, ex:
assert ex.errno == EEXIST
示例6: setup_class
def setup_class(self):
self.bspath = "bs_refresh_01"
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSSIZE,
CONFIG.BSARGS(self.bspath))
示例7: test_read
def test_read(self):
# Remove any prexisting blockstore.
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
# Create the filesystem
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE, "rootbs", CONFIG.BSSIZE, bsargs)
self.fs = utp.FileSystem.mkfs(CONFIG.FSTYPE, self.bs, "", "", CONFIG.UNAME, CONFIG.GNAME, CONFIG.FSARGS)
# Create a file.
self.fs.fs_mknod("/foo", 0666, 0, CONFIG.UNAME, CONFIG.GNAME)
# Write some data into the file.
self.fs.fs_write("/foo", buffer("testdata"))
# Now we should be able to stat the file.
st = self.fs.fs_getattr("/foo")
assert S_ISREG(st[ST_MODE])
assert st[ST_SIZE] == 8
# Now try and read 4096 bytes.
buf = self.fs.fs_read("/foo", 4096)
assert str(buf) == "testdata"
# Now try and read 4097 bytes.
buf = self.fs.fs_read("/foo", 4097)
assert str(buf) == "testdata"
# Now we unmount the filesystem.
self.fs.fs_umount()
self.bs.bs_close()
# Now mount it again.
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.open(CONFIG.BSTYPE, "rootbs", bsargs)
self.fs = utp.FileSystem.mount(CONFIG.FSTYPE, self.bs, "", "", CONFIG.FSARGS)
# We should be able to stat the same file.
st = self.fs.fs_getattr("/foo")
assert S_ISREG(st[ST_MODE])
assert st[ST_SIZE] == 8
# We should be able to read the data.
self.fs.fs_open("/foo", O_RDONLY)
buf = self.fs.fs_read("/foo", 4096)
assert str(buf) == "testdata"
# We should be able to read the data.
self.fs.fs_open("/foo", O_RDONLY)
buf = self.fs.fs_read("/foo", 4097)
assert str(buf) == "testdata"
# WORKAROUND - py.test doesn't correctly capture the DTOR logging.
self.bs.bs_close()
self.bs = None
self.fs = None
示例8: teardown_class
def teardown_class(self):
# WORKAROUND - py.test doesn't correctly capture the DTOR logging.
olvl = utp.FileSystem.loglevel(-1)
self.bs.bs_close()
self.bs = None
self.fs = None
utp.FileSystem.loglevel(olvl)
CONFIG.remove_bs(self.bspath)
示例9: setup_class
def setup_class(self):
self.bspath = "fs_rename_01.bs"
# Remove any prexisting blockstore.
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
# Create the filesystem
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE, "rootbs", CONFIG.BSSIZE, bsargs)
self.fs = utp.FileSystem.mkfs(CONFIG.FSTYPE, self.bs, "", "", CONFIG.UNAME, CONFIG.GNAME, CONFIG.FSARGS)
示例10: test_persistence
def test_persistence(self):
# Remove any prexisting blockstore.
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
# Create the filesystem
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSSIZE,
bsargs)
self.fs = utp.FileSystem.mkfs(CONFIG.FSTYPE, self.bs, "", "",
CONFIG.UNAME, CONFIG.GNAME, CONFIG.FSARGS)
# Create a diretory.
self.fs.fs_mkdir("/foo", 0755, CONFIG.UNAME, CONFIG.GNAME)
# Create a file in the directory.
self.fs.fs_mknod("/foo/bar", 0666, 0, CONFIG.UNAME, CONFIG.GNAME)
# Now we should be able to stat the directory.
st = self.fs.fs_getattr("/foo");
assert S_ISDIR(st[ST_MODE])
# Now we should be able to stat the file.
st = self.fs.fs_getattr("/foo/bar");
assert S_ISREG(st[ST_MODE])
# Now we unmount the filesystem.
self.fs.fs_umount()
self.bs.bs_close()
# Now mount it again.
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.open(CONFIG.BSTYPE,
"rootbs",
bsargs)
self.fs = utp.FileSystem.mount(CONFIG.FSTYPE, self.bs,
"", "", CONFIG.FSARGS)
# Now we should be able to stat the directory.
st = self.fs.fs_getattr("/foo");
assert S_ISDIR(st[ST_MODE])
# We should be able to stat the same file.
st = self.fs.fs_getattr("/foo/bar");
assert S_ISREG(st[ST_MODE])
# WORKAROUND - py.test doesn't correctly capture the DTOR logging.
self.bs.bs_close()
self.bs = None
self.fs = None
示例11: detect_token
def detect_token(self, token):
"""
Identifies (classifies, validates) tokens.
:param token: Token
:return: None
:raises: ScannerException
"""
if token in CONFIG.RESERVED_WORDS:
logging.debug('reserved word:{0}'.format(token))
self.add_to_pif(code=CONFIG.CODIFICATION_MAP[token], index=-1)
return
elif CONFIG.match_int_constant(token):
logging.debug('integer constant:{0}'.format(token))
st_index = self.add_to_st(token=token, constant=True)
self.add_to_pif(code=CONFIG.CODIFICATION_MAP['constant'], index=st_index)
return
elif CONFIG.match_char_constant(token):
logging.debug('character constant:{0}'.format(token))
st_index = self.add_to_st(token=token.split('\'')[1], constant=True)
self.add_to_pif(code=CONFIG.CODIFICATION_MAP['constant'], index=st_index)
return
elif token in CONFIG.SEPARATORS:
logging.debug('separator:{0}'.format(token))
self.add_to_pif(code=CONFIG.CODIFICATION_MAP[token], index=-1)
return
elif token in CONFIG.ARITHMETIC_OPERATORS:
logging.debug('arithmetic operator:{0}'.format(token))
self.add_to_pif(code=CONFIG.CODIFICATION_MAP[token], index=-1)
return
elif token in CONFIG.COMPARATORS:
logging.debug('comparator:{0}'.format(token))
self.add_to_pif(code=CONFIG.CODIFICATION_MAP[token], index=-1)
return
elif CONFIG.match_identifier(token):
logging.debug('identifier:{0}'.format(token))
st_index = self.add_to_st(token=token, constant=False)
self.add_to_pif(code=CONFIG.CODIFICATION_MAP['identifier'], index=st_index)
return
# Token couldn't be identified, raise exception
raise ScannerException('Syntax error: {0}'.format(token))
示例12: test_statfs
def test_statfs(self):
# Remove any prexisting blockstore.
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
# Create the filesystem
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSSIZE,
bsargs)
self.fs = utp.FileSystem.mkfs(CONFIG.FSTYPE, self.bs, "", "",
CONFIG.UNAME, CONFIG.GNAME, CONFIG.FSARGS)
BLKSZ = 4 * 1024
BLKSUSED = 2
stvfs = self.fs.fs_statfs()
assert stvfs.f_bsize == BLKSZ
assert stvfs.f_blocks == CONFIG.BSSIZE / BLKSZ
assert stvfs.f_bfree == (CONFIG.BSSIZE / BLKSZ) - BLKSUSED
assert stvfs.f_bavail == (CONFIG.BSSIZE / BLKSZ) - BLKSUSED
# Now we unmount the filesystem.
self.fs.fs_umount()
self.bs.bs_close()
# Now mount it again.
bsargs = CONFIG.BSARGS(self.bspath)
self.bs = utp.BlockStore.open(CONFIG.BSTYPE, "rootbs", bsargs)
self.fs = utp.FileSystem.mount(CONFIG.FSTYPE, self.bs,
"", "", CONFIG.FSARGS)
stvfs = self.fs.fs_statfs()
assert stvfs.f_bsize == BLKSZ
assert stvfs.f_blocks == CONFIG.BSSIZE / BLKSZ
assert stvfs.f_bfree == (CONFIG.BSSIZE / BLKSZ) - BLKSUSED
assert stvfs.f_bavail == (CONFIG.BSSIZE / BLKSZ) - BLKSUSED
# WORKAROUND - py.test doesn't correctly capture the DTOR logging.
self.bs.bs_close()
self.bs = None
self.fs = None
示例13: test_data_single_child
def test_data_single_child(self):
print "test_data_single_child"
bspath1 = "vbs_data_01_c1"
CONFIG.unmap_bs("child1")
CONFIG.remove_bs(bspath1)
self.bs1 = utp.BlockStore.create(CONFIG.BSTYPE,
"child1",
CONFIG.BSSIZE,
CONFIG.BSARGS(bspath1))
CONFIG.unmap_bs("rootbs")
self.vbs = utp.BlockStore.open("VBS",
"rootbs",
("child1",))
print "Put a block of data."
key1 = buffer("key1")
val1 = buffer("val1")
self.vbs.bs_block_put(key1, val1)
print "Retrieve the block."
blk1 = self.vbs.bs_block_get(key1)
assert blk1 == val1
print "Test block that doesn't exist."
key2 = buffer("key2")
py.test.raises(utp.NotFoundError, self.vbs.bs_block_get, key2)
print "Close and reopen everything."
self.vbs.bs_close()
self.bs1.bs_close()
self.bs1 = utp.BlockStore.open(CONFIG.BSTYPE,
"child1",
CONFIG.BSARGS(bspath1))
self.vbs = utp.BlockStore.open("VBS",
"rootbs",
("child1",))
print "Retrieve the block."
blk1 = self.vbs.bs_block_get(key1)
assert blk1 == val1
print "Test block that doesn't exist."
key2 = buffer("key2")
py.test.raises(utp.NotFoundError, self.vbs.bs_block_get, key2)
print "Close for good."
self.vbs.bs_close()
self.vbs = None
self.bs1.bs_close()
CONFIG.remove_bs(bspath1)
示例14: test_furthest_on_single_w_miss
def test_furthest_on_single_w_miss(self):
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSSIZE,
CONFIG.BSARGS(self.bspath))
# Insert a single SHE.
node = utp.SignedHeadEdge(("fsid", "rootref", 0, time.time() * 1e6, 0, 0))
self.bs.bs_head_insert(node)
# Furthest should miss w/ bad key.
miss = (buffer("fsid"), buffer("notref"))
shes = self.bs.bs_head_furthest(miss)
assert lenhack(shes) == 0
# Reopen the blockstore.
self.bs.bs_close()
self.bs = utp.BlockStore.open(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSARGS(self.bspath))
# Furthest should miss w/ bad key.
miss = (buffer("fsid"), buffer("notref"))
shes = self.bs.bs_head_furthest(miss)
assert lenhack(shes) == 0
# Close the blockstore.
self.bs.bs_close()
CONFIG.remove_bs(self.bspath)
示例15: test_follow_on_single_w_miss
def test_follow_on_single_w_miss(self):
CONFIG.unmap_bs("rootbs")
CONFIG.remove_bs(self.bspath)
self.bs = utp.BlockStore.create(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSSIZE,
CONFIG.BSARGS(self.bspath))
# Insert a single SHE.
node = utp.SignedHeadEdge(("fsid", "rootref", 0, time.time() * 1e6, 0, 0))
self.bs.bs_head_insert(node)
# Follow should miss w/ bad key.
miss = (buffer("fsid"), buffer("notref"))
py.test.raises(utp.NotFoundError, self.bs.bs_head_follow, miss)
# Reopen the blockstore.
self.bs.bs_close()
self.bs = utp.BlockStore.open(CONFIG.BSTYPE,
"rootbs",
CONFIG.BSARGS(self.bspath))
# Follow should miss w/ bad key.
miss = (buffer("fsid"), buffer("notref"))
py.test.raises(utp.NotFoundError, self.bs.bs_head_follow, miss)
# Close the blockstore.
self.bs.bs_close()
CONFIG.remove_bs(self.bspath)