当前位置: 首页>>代码示例>>Python>>正文


Python Client.read_file方法代码示例

本文整理汇总了Python中pymogile.Client.read_file方法的典型用法代码示例。如果您正苦于以下问题:Python Client.read_file方法的具体用法?Python Client.read_file怎么用?Python Client.read_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymogile.Client的用法示例。


在下文中一共展示了Client.read_file方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_read_file

# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import read_file [as 别名]
def test_read_file():
    client = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())
    client.store_content(key, key)

    fp = client.read_file(key)
    assert fp is not None
    assert key == fp.read()
开发者ID:pombredanne,项目名称:pymogile,代码行数:10,代码来源:test_client.py

示例2: test_read_file

# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import read_file [as 别名]
  def test_read_file(self): 
    client = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())
    client.store_content(key, key)

    fp = client.read_file(key)
    self.assertNotEqual(fp, None)
    self.assertEqual(key, fp.read())
开发者ID:cypreess,项目名称:pymogile,代码行数:10,代码来源:test_client.py

示例3: test_read_file

# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import read_file [as 别名]
def test_read_file():
    cl = Client(TEST_NS, HOSTS)

    cl = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())
    cl.store_content(key, key)

    with cl.read_file(key) as fp:
        assert fp.read() == key
开发者ID:pombredanne,项目名称:pymogile,代码行数:11,代码来源:test_with_statement.py

示例4: test_readonly_file

# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import read_file [as 别名]
def test_readonly_file():
    client = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())
    client.store_content(key, "SPAM")

    fp = client.read_file(key)
    try:
        fp.write("egg")
    except:
        pass
    else:
        assert False, "operation not permitted to read-only file"
开发者ID:pombredanne,项目名称:pymogile,代码行数:14,代码来源:test_client.py

示例5: test_seek_read

# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import read_file [as 别名]
def test_seek_read():
    client = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())

    client.store_content(key, "0123456789")

    fp = client.read_file(key)
    fp.seek(1)
    assert fp.tell() == 1
    content = fp.read(3)

    assert content == "123"
    assert fp.tell() == 4
开发者ID:pombredanne,项目名称:pymogile,代码行数:15,代码来源:test_client.py

示例6: test_seek_read

# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import read_file [as 别名]
  def test_seek_read(self):
    client = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())

    client.store_content(key, "0123456789")

    fp = client.read_file(key)
    fp.seek(1)
    self.assertEqual(fp.tell(), 1)
    
    content = fp.read(3)
    assert content == "123"
    self.assertEqual(fp.tell(), 4)
开发者ID:cypreess,项目名称:pymogile,代码行数:15,代码来源:test_client.py

示例7: prepare_photo_files

# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import read_file [as 别名]
def prepare_photo_files(owner, nb):
    storage = Client(domain = settings.MOGILEFS_DOMAIN,
            trackers = settings.MOGILEFS_TRACKERS)
    #im = Image.open(path.join(settings.UNPROCESSED_PHOTOS_DIR, '%s.jpg' % id))
    f = storage.read_file(path.join(settings.UNPROCESSED_PHOTOS_DIR, '%s,%s.jpg' % (owner, nb)))
    im = Image.open(f)
    im.thumbnail((160, 160), Image.ANTIALIAS)

    tn = storage.new_file(path.join(settings.PROCESSED_PHOTOS_DIR, '%s,%s-160x160.jpg' % (owner, nb)))
    im.save(tn, 'JPEG')

    #sleep(20)
    photo = Photo.get(owner, nb)
    photo.ready()
开发者ID:savix,项目名称:jnp3,代码行数:16,代码来源:tasks.py

示例8: photo_thumbnail

# 需要导入模块: from pymogile import Client [as 别名]
# 或者: from pymogile.Client import read_file [as 别名]
def photo_thumbnail(request, owner, nb):
    storage = Client(domain = settings.MOGILEFS_DOMAIN,
            trackers = settings.MOGILEFS_TRACKERS)
    f = storage.read_file(path.join(settings.PROCESSED_PHOTOS_DIR, '%s,%s-160x160.jpg' % (owner, nb)))
    return HttpResponse(make_reader(f), content_type='image/jpeg')
开发者ID:savix,项目名称:jnp3,代码行数:7,代码来源:views.py


注:本文中的pymogile.Client.read_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。