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


Python pymogile.Client类代码示例

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


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


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