本文整理汇总了Python中pymogile.Client.get_paths方法的典型用法代码示例。如果您正苦于以下问题:Python Client.get_paths方法的具体用法?Python Client.get_paths怎么用?Python Client.get_paths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymogile.Client
的用法示例。
在下文中一共展示了Client.get_paths方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_delete(self):
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
client.new_file(key).write("SPAM")
paths = client.get_paths(key)
self.assertTrue(paths)
client.delete(key)
paths = client.get_paths(key)
self.assertFalse(paths)
示例2: test_delete
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_delete():
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
client.new_file(key).write("SPAM")
paths = client.get_paths(key)
assert paths
client.delete(key)
paths = client.get_paths(key)
assert not paths
示例3: test_rename
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_rename():
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
client.new_file(key).write(key)
paths = client.get_paths(key)
assert paths
newkey = 'test_file2_%s_%s' % (random.random(), time.time())
client.rename(key, newkey)
paths = client.get_paths(newkey)
assert paths
content = client.get_file_data(newkey)
assert content == key
示例4: test_rename
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_rename(self):
client = Client(TEST_NS, HOSTS)
key = "test_file_%s_%s" % (random.random(), time.time())
client.new_file(key).write(key)
paths = client.get_paths(key)
self.assertTrue(paths)
newkey = "test_file2_%s_%s" % (random.random(), time.time())
client.rename(key, newkey)
paths = client.get_paths(newkey)
self.assertTrue(paths)
content = client.get_file_data(newkey)
assert content == key
示例5: test_mkcol
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_mkcol():
client = Client(TEST_NS, HOSTS)
for x in xrange(0, 1000):
key = 'test_file_%s_%s_%d' % (random.random(), time.time(), x)
client.new_file(key).write("SPAM%s" % x)
paths = client.get_paths(key)
assert paths
示例6: test_mkcol
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_mkcol(self):
client = Client(TEST_NS, HOSTS)
for x in xrange(0, 10):
key = "test_file_%s_%s_%d" % (random.random(), time.time(), x)
client.new_file(key).write("SPAM%s" % x)
paths = client.get_paths(key)
self.assertTrue(paths)
示例7: test_new_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_new_file():
cl = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
with cl.new_file(key) as fp:
assert fp.__exit__
fp.write(key)
assert cl.get_paths(key)
assert cl.get_file_data(key) == key
示例8: test_append_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_append_file(self):
cl = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
cl.store_content(key, "SPAM")
self.assertTrue(cl.get_paths(key))
self.assertEqual("SPAM", cl.get_file_data(key))
fp = cl.edit_file(key)
self.assertTrue(fp)
fp.seek(4)
fp.write("HamEggs")
fp.close()
self.assertEqual("SPAMHamEggs", cl.get_file_data(key))
示例9: test_new_large_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_new_large_file():
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
fp = client.new_file(key, largefile=True)
assert fp is not None
for x in xrange(50):
fp.write("0123456789")
fp.close()
paths = client.get_paths(key)
#assert len(paths) > 1, "should exist in one ore more places"
assert paths
content = client.get_file_data(key)
assert content == "0123456789" * 50
示例10: test_new_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_new_file():
client = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
fp = client.new_file(key)
assert fp is not None
data = "0123456789" * 50
fp.write(data)
fp.close()
paths = client.get_paths(key)
#assert len(paths) > 1, "should exist in one ore more places"
assert paths
content = client.get_file_data(key)
assert content == data
示例11: test_edit_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def test_edit_file():
# TODO
# PASS
return
cl = Client(TEST_NS, HOSTS)
key = 'test_file_%s_%s' % (random.random(), time.time())
cl.store_content(key, "SPAM")
assert cl.get_paths(key)
assert cl.get_file_data(key) == "SPAM"
fp = cl.edit_file(key)
assert fp
fp.write("s")
fp.seek(2)
fp.write("a")
fp.close()
assert cl.get_file_data(key) == "sPaM"
示例12: Client
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
#-*- coding: utf-8 -*-
from pymogile import Client
c = Client(domain="privatemedia", trackers=['127.0.0.1:7001'])
cpub = Client(domain="publicmedia", trackers=['127.0.0.1:7001'])
# list keys
c.list_keys()
# create a file in mogilefs
f = c.new_file('foobar.txt')
f.write('hi, my name bar, foo bar.')
f.close()
# show paths
c.get_paths('foobar.txt')
c.get_paths('404.txt')
# get file data
c.get_file_data('404.txt')
c.get_file_data('foobar.txt')
# remove
c.delete('foobar.txt')
# django storage backend
from ogv_documents.storage.mogilefs import MogilefsStorage
from django.core.files.base import ContentFile
示例13: handle_uploaded_file
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import get_paths [as 别名]
def handle_uploaded_file(f):
buf = f.read()
filename = get_key(buf)
datastore = get_datastore()
fp = datastore.new_file(filename)
fp.write(buf)
fp.close()
return filename
def get_filedata(filename):
datastore = get_datastore()
return datastore.get_file_data(filename)
def get_key(buf):
m = md5()
m.update(buf)
return '%s.jpg' % m.hexdigest()
if __name__ == "__main__":
key = 'css.css'
datastore = Client(domain=settings.MOGILEFS_DOMAIN, trackers=settings.MOGILEFS_TRACKERS)
fp = datastore.new_file('/var/djangotest/name.txt')
fp.write(key)
fp.close()
print datastore.get_paths(key)
print datastore.get_paths('/var/djangotest/name.txt')