本文整理汇总了Python中pymogile.Client.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Client.delete方法的具体用法?Python Client.delete怎么用?Python Client.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymogile.Client
的用法示例。
在下文中一共展示了Client.delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import delete [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
示例2: test_delete
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import delete [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)
示例3: test_list_keys
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import delete [as 别名]
def test_list_keys():
keys = ["spam", "egg", "ham"]
domain = "test:list_keys:%s:%s:%s" % (random.random(), time.time(), TEST_NS)
moga.create_domain(domain)
mogc = Client(domain, HOSTS)
for k in keys:
mogc.store_content(k, k)
try:
files = mogc.list_keys()
assert len(files) == 3
files = mogc.list_keys(limit=1)
assert len(files) == 1
files = mogc.list_keys(prefix='sp')
assert len(files) == 1
finally:
for k in keys:
mogc.delete(k)
moga.delete_domain(domain)
示例4: MogilefsStorage
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import delete [as 别名]
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
s = MogilefsStorage(domain='privatemedia', container='documents', base_url='/documents/', trackers=['127.0.0.1:7001'])
s.exists('six/2011/justone.pdf')
s.save(u'epic.txt', ContentFile('my epic content. now with a content file'))
s.save(u'ëpîc.txt', u'my epic content with ümlauts.')
s.save(s.get_available_name(s.get_valid_name(u'ëpîc.txt')), 'my epic content with umlauts.')
示例5: Storage
# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import delete [as 别名]
class Storage(BaseStorage):
def __init__(self, context):
BaseStorage.__init__(self, context)
domain = self.context.config.MOGILEFS_STORAGE_DOMAIN
trackers = self.context.config.MOGILEFS_STORAGE_TRACKERS
self.storage = Client(domain=domain, trackers=trackers)
def __key_for(self, url):
return 'thumbor-crypto-%s' % url
def __detector_key_for(self, url):
return 'thumbor-detector-%s' % url
def put(self, path, bytes):
fp = self.storage.new_file(path)
fp.write(bytes)
fp.close()
return path
def put_crypto(self, path, data):
if not self.context.config.STORES_CRYPTO_KEY_FOR_EACH_IMAGE:
return
if not self.context.server.security_key:
raise RuntimeError("""STORES_CRYPTO_KEY_FOR_EACH_IMAGE can't be True
if no SECURITY_KEY specified""")
key = self.__key_for(path)
fp = self.storage.new_file(key)
fp.write(self.context.server.security_key)
fp.close()
return key
def put_detector_data(self, path, data):
key = self.__detector_key_for(path)
fp = self.storage.new_file(key)
fp.write(dumps(data))
fp.close()
return key
def get_crypto(self, path):
if not self.context.config.STORES_CRYPTO_KEY_FOR_EACH_IMAGE:
return None
crypto = self.storage.get_file_data(self.__key_for(path))
if not crypto:
return None
return crypto
def get_detector_data(self, path):
data = self.storage.get_file_data(self.__detector_key_for(path))
if not data:
return None
return loads(data)
def get(self, path):
return self.storage.get_file_data(path) is not None
def exists(self, path):
return self.storage.keys(path) is not None
def remove(self, path):
if not self.exists(path):
return
return self.storage.delete(path)