• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pymogile.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: func

    def func(largefile):
        client = Client(TEST_NS, HOSTS)
        key = 'test_file_%s_%s' % (random.random(), time.time())
        fp = client.new_file(key, largefile=largefile)
        fp.write("spam")
        fp.close()

        try:
            fp.write("egg")
        except:
            pass
        else:
            assert False, "operation not permitted to closed file"

        try:
            fp.read()
        except:
            pass
        else:
            assert False, "operation not permitted to closed file"

        try:
            fp.seek(0)
        except:
            pass
        else:
            assert False, "operation not permitted to closed file"

        try:
            fp.tell()
        except:
            pass
        else:
            assert False, "operation not permitted to closed file"
开发者ID:pombredanne,项目名称:pymogile,代码行数:34,代码来源:test_client.py


示例2: test_file_like_object

  def test_file_like_object(self): 
    client = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())

    fp = client.new_file(key)
    fp.write("spam\negg\nham\n")

    fp.seek(0)
    line = fp.readline()
    self.assertEqual(line, "spam\n")
    line = fp.readline()
    
    self.assertEqual(line, "egg\n")
    line = fp.readline()
    
    self.assertEqual(line, "ham\n")
    
    line = fp.readline()
    self.assertEqual(line, '')

    fp.seek(0)
    lines = fp.readlines()
    self.assertEqual(lines, ["spam\n", "egg\n", "ham\n"])

    fp.close()
开发者ID:cypreess,项目名称:pymogile,代码行数:25,代码来源:test_client.py


示例3: test_mkcol

 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)
开发者ID:lananhbk168,项目名称:pymogile,代码行数:7,代码来源:test_client.py


示例4: test_mkcol

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
开发者ID:pombredanne,项目名称:pymogile,代码行数:7,代码来源:test_client.py


示例5: test_read_file

  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,代码行数:8,代码来源:test_client.py


示例6: test_read_file

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,代码行数:8,代码来源:test_client.py


示例7: test_rename_dupliate_key

  def test_rename_dupliate_key(self): 
    client = Client(TEST_NS, HOSTS)
    key1 = 'test_file_%s_%s' % (random.random(), time.time())
    key2 = 'key2:' + key1

    client.store_content(key1, key1)
    client.store_content(key2, key2)

    self.assertEqual(client.rename(key1, key2), False)
开发者ID:cypreess,项目名称:pymogile,代码行数:9,代码来源:test_client.py


示例8: test_read_file

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,代码行数:9,代码来源:test_with_statement.py


示例9: test_new_file

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
开发者ID:pombredanne,项目名称:pymogile,代码行数:10,代码来源:test_with_statement.py


示例10: test_store_content

  def test_store_content(self): 
    client = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())

    data = ''.join(random.choice("0123456789") for _ in xrange(8192 * 2))
    length = client.store_content(key, data)
    self.assertEqual(length, len(data))

    content = client.get_file_data(key)
    self.assertEqual(content, data)
开发者ID:cypreess,项目名称:pymogile,代码行数:10,代码来源:test_client.py


示例11: test_store_content

def test_store_content():
    client = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())

    data = ''.join(random.choice("0123456789") for x in xrange(8192 * 2))
    length = client.store_content(key, data)
    assert length == len(data)

    content = client.get_file_data(key)
    assert content == data
开发者ID:pombredanne,项目名称:pymogile,代码行数:10,代码来源:test_client.py


示例12: test_store_file

    def test_store_file(self):
        client = Client(TEST_NS, HOSTS)
        key = "test_file_%s_%s" % (random.random(), time.time())

        data = "".join(random.choice("0123456789") for _ in xrange(8192 * 2))
        fp = StringIO(data)
        length = client.store_file(key, fp)
        self.assertEqual(length, len(data))

        content = client.get_file_data(key)
        self.assertEqual(content, data)
开发者ID:lananhbk168,项目名称:pymogile,代码行数:11,代码来源:test_client.py


示例13: test_closed_file

  def test_closed_file(self):
    client = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())
    fp = client.new_file(key)
    fp.write("spam")
    fp.close()

    self.assertRaises(ValueError, fp.write, "egg")
    self.assertRaises(ValueError, fp.read)
    self.assertRaises(ValueError, fp.seek, 0)
    self.assertRaises(ValueError, fp.tell)
开发者ID:cypreess,项目名称:pymogile,代码行数:11,代码来源:test_client.py


示例14: test_readonly_file

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,代码行数:12,代码来源:test_client.py


示例15: test_rename_dupliate_key

def test_rename_dupliate_key():
    client = Client(TEST_NS, HOSTS)
    key1 = 'test_file_%s_%s' % (random.random(), time.time())
    key2 = 'key2:' + key1

    client.store_content(key1, key1)
    client.store_content(key2, key2)

    try:
        client.rename(key1, key2)
    except MogileFSError, e:
        pass
开发者ID:pombredanne,项目名称:pymogile,代码行数:12,代码来源:test_client.py


示例16: test_seek

    def test_seek(self):
        client = Client(TEST_NS, HOSTS)
        key = "test_file_%s_%s" % (random.random(), time.time())

        fp = client.new_file(key)
        fp.write("SPAM")
        fp.seek(1)
        self.assertEqual(fp.tell(), 1)

        fp.write("p")
        fp.close()
        self.assertEqual(client.get_file_data(key), "SpAM")
开发者ID:lananhbk168,项目名称:pymogile,代码行数:12,代码来源:test_client.py


示例17: test_seek_negative

  def test_seek_negative(self):
    client = Client(TEST_NS, HOSTS)
    key = 'test_file_%s_%s' % (random.random(), time.time())

    fp = client.new_file(key)
    fp.write("SPAM")
    fp.seek(-10)
    self.assertEqual(fp.tell(), 0)
    
    fp.write("s")
    fp.close()
    self.assertEqual(client.get_file_data(key), "sPAM")
开发者ID:cypreess,项目名称:pymogile,代码行数:12,代码来源:test_client.py


示例18: test_seek_read

  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,代码行数:13,代码来源:test_client.py


示例19: test_seek_read

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,代码行数:13,代码来源:test_client.py


示例20: prepare_photo_files

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,代码行数:14,代码来源:tasks.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pymol.finish_launching函数代码示例发布时间:2022-05-25
下一篇:
Python pymodule.ProcessOptions类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap