當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。