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


Python server.UploadPackHandler类代码示例

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


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

示例1: upload_pack

def upload_pack(path=".", inf=sys.stdin, outf=sys.stdout):
    """Upload a pack file after negotiating its contents using smart protocol.

    :param path: Path to the repository
    :param inf: Input stream to communicate with client
    :param outf: Output stream to communicate with client
    """
    backend = FileSystemBackend()
    def send_fn(data):
        outf.write(data)
        outf.flush()
    proto = Protocol(inf.read, send_fn)
    handler = UploadPackHandler(backend, [path], proto)
    # FIXME: Catch exceptions and write a single-line summary to outf.
    handler.handle()
    return 0
开发者ID:PKRoma,项目名称:dulwich,代码行数:16,代码来源:porcelain.py

示例2: UploadPackHandlerTestCase

class UploadPackHandlerTestCase(TestCase):
    def setUp(self):
        self._handler = UploadPackHandler(None, None, None)

    def test_set_client_capabilities(self):
        try:
            self._handler.set_client_capabilities([])
        except GitProtocolError:
            self.fail()

        try:
            self._handler.set_client_capabilities([
                'multi_ack', 'side-band-64k', 'thin-pack', 'ofs-delta'])
        except GitProtocolError:
            self.fail()

    def test_set_client_capabilities_error(self):
        self.assertRaises(GitProtocolError,
                          self._handler.set_client_capabilities,
                          ['weird_ack_level', 'ofs-delta'])
        try:
            self._handler.set_client_capabilities(['include-tag'])
        except GitProtocolError:
            self.fail()
开发者ID:abderrahim,项目名称:dulwich,代码行数:24,代码来源:test_server.py

示例3: setUp

 def setUp(self):
     super(UploadPackHandlerTestCase, self).setUp()
     self._repo = MemoryRepo.init_bare([], {})
     backend = DictBackend({b'/': self._repo})
     self._handler = UploadPackHandler(
       backend, [b'/', b'host=lolcathost'], TestProto())
开发者ID:ardumont,项目名称:dulwich,代码行数:6,代码来源:test_server.py

示例4: UploadPackHandlerTestCase

class UploadPackHandlerTestCase(TestCase):

    def setUp(self):
        super(UploadPackHandlerTestCase, self).setUp()
        self._repo = MemoryRepo.init_bare([], {})
        backend = DictBackend({b'/': self._repo})
        self._handler = UploadPackHandler(
          backend, [b'/', b'host=lolcathost'], TestProto())

    def test_progress(self):
        caps = self._handler.required_capabilities()
        self._handler.set_client_capabilities(caps)
        self._handler.progress(b'first message')
        self._handler.progress(b'second message')
        self.assertEqual(b'first message',
                         self._handler.proto.get_received_line(2))
        self.assertEqual(b'second message',
                         self._handler.proto.get_received_line(2))
        self.assertRaises(IndexError, self._handler.proto.get_received_line, 2)

    def test_no_progress(self):
        caps = list(self._handler.required_capabilities()) + [b'no-progress']
        self._handler.set_client_capabilities(caps)
        self._handler.progress(b'first message')
        self._handler.progress(b'second message')
        self.assertRaises(IndexError, self._handler.proto.get_received_line, 2)

    def test_get_tagged(self):
        refs = {
            b'refs/tags/tag1': ONE,
            b'refs/tags/tag2': TWO,
            b'refs/heads/master': FOUR,  # not a tag, no peeled value
            }
        # repo needs to peel this object
        self._repo.object_store.add_object(make_commit(id=FOUR))
        self._repo.refs._update(refs)
        peeled = {
            b'refs/tags/tag1': b'1234' * 10,
            b'refs/tags/tag2': b'5678' * 10,
            }
        self._repo.refs._update_peeled(peeled)

        caps = list(self._handler.required_capabilities()) + [b'include-tag']
        self._handler.set_client_capabilities(caps)
        self.assertEqual({b'1234' * 10: ONE, b'5678' * 10: TWO},
                          self._handler.get_tagged(refs, repo=self._repo))

        # non-include-tag case
        caps = self._handler.required_capabilities()
        self._handler.set_client_capabilities(caps)
        self.assertEqual({}, self._handler.get_tagged(refs, repo=self._repo))
开发者ID:ardumont,项目名称:dulwich,代码行数:51,代码来源:test_server.py

示例5: setUp

 def setUp(self):
     self._backend = DictBackend({"/": BackendRepo()})
     self._handler = UploadPackHandler(self._backend,
             ["/", "host=lolcathost"], None, None)
     self._handler.proto = TestProto()
开发者ID:tmc,项目名称:dulwich,代码行数:5,代码来源:test_server.py

示例6: UploadPackHandlerTestCase

class UploadPackHandlerTestCase(TestCase):

    def setUp(self):
        self._backend = DictBackend({"/": BackendRepo()})
        self._handler = UploadPackHandler(self._backend,
                ["/", "host=lolcathost"], None, None)
        self._handler.proto = TestProto()

    def test_progress(self):
        caps = self._handler.required_capabilities()
        self._handler.set_client_capabilities(caps)
        self._handler.progress('first message')
        self._handler.progress('second message')
        self.assertEqual('first message',
                         self._handler.proto.get_received_line(2))
        self.assertEqual('second message',
                         self._handler.proto.get_received_line(2))
        self.assertEqual(None, self._handler.proto.get_received_line(2))

    def test_no_progress(self):
        caps = list(self._handler.required_capabilities()) + ['no-progress']
        self._handler.set_client_capabilities(caps)
        self._handler.progress('first message')
        self._handler.progress('second message')
        self.assertEqual(None, self._handler.proto.get_received_line(2))

    def test_get_tagged(self):
        refs = {
            'refs/tags/tag1': ONE,
            'refs/tags/tag2': TWO,
            'refs/heads/master': FOUR,  # not a tag, no peeled value
            }
        peeled = {
            'refs/tags/tag1': '1234',
            'refs/tags/tag2': '5678',
            }

        class TestRepo(object):
            def get_peeled(self, ref):
                return peeled.get(ref, refs[ref])

        caps = list(self._handler.required_capabilities()) + ['include-tag']
        self._handler.set_client_capabilities(caps)
        self.assertEquals({'1234': ONE, '5678': TWO},
                          self._handler.get_tagged(refs, repo=TestRepo()))

        # non-include-tag case
        caps = self._handler.required_capabilities()
        self._handler.set_client_capabilities(caps)
        self.assertEquals({}, self._handler.get_tagged(refs, repo=TestRepo()))
开发者ID:tmc,项目名称:dulwich,代码行数:50,代码来源:test_server.py

示例7: setUp

 def setUp(self):
     self._handler = UploadPackHandler(None, None, None)
开发者ID:abderrahim,项目名称:dulwich,代码行数:2,代码来源:test_server.py

示例8: UploadPackHandlerTestCase

class UploadPackHandlerTestCase(TestCase):
    def setUp(self):
        super(UploadPackHandlerTestCase, self).setUp()
        self._repo = MemoryRepo.init_bare([], {})
        backend = DictBackend({"/": self._repo})
        self._handler = UploadPackHandler(backend, ["/", "host=lolcathost"], TestProto())

    def test_progress(self):
        caps = self._handler.required_capabilities()
        self._handler.set_client_capabilities(caps)
        self._handler.progress("first message")
        self._handler.progress("second message")
        self.assertEqual("first message", self._handler.proto.get_received_line(2))
        self.assertEqual("second message", self._handler.proto.get_received_line(2))
        self.assertRaises(IndexError, self._handler.proto.get_received_line, 2)

    def test_no_progress(self):
        caps = list(self._handler.required_capabilities()) + ["no-progress"]
        self._handler.set_client_capabilities(caps)
        self._handler.progress("first message")
        self._handler.progress("second message")
        self.assertRaises(IndexError, self._handler.proto.get_received_line, 2)

    def test_get_tagged(self):
        refs = {"refs/tags/tag1": ONE, "refs/tags/tag2": TWO, "refs/heads/master": FOUR}  # not a tag, no peeled value
        # repo needs to peel this object
        self._repo.object_store.add_object(make_commit(id=FOUR))
        self._repo.refs._update(refs)
        peeled = {"refs/tags/tag1": "1234" * 10, "refs/tags/tag2": "5678" * 10}
        self._repo.refs._update_peeled(peeled)

        caps = list(self._handler.required_capabilities()) + ["include-tag"]
        self._handler.set_client_capabilities(caps)
        self.assertEqual({"1234" * 10: ONE, "5678" * 10: TWO}, self._handler.get_tagged(refs, repo=self._repo))

        # non-include-tag case
        caps = self._handler.required_capabilities()
        self._handler.set_client_capabilities(caps)
        self.assertEqual({}, self._handler.get_tagged(refs, repo=self._repo))
开发者ID:jaraco,项目名称:dulwich,代码行数:39,代码来源:test_server.py


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