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


Python defer.gatherResults方法代码示例

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


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

示例1: _getGitHubRepoProperties

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def _getGitHubRepoProperties(self, build):
        """
        Return a dictionary with GitHub related properties from `build`.
        """
        repoOwner, repoName, sha = yield defer.gatherResults([
            build.render(self._repoOwner),
            build.render(self._repoName),
            build.render(self._sha),
        ])

        if not repoOwner or not repoName:
            defer.returnValue({})

        if not sha:
            log.msg('GitHubStatus: No revision found.')
            defer.returnValue({})

        result = {
            'repoOwner': repoOwner,
            'repoName': repoName,
            'sha': sha,
            'targetURL': self._status.getURLForThing(build),
            'buildNumber': str(build.getNumber()),
        }
        defer.returnValue(result) 
开发者ID:llvm,项目名称:llvm-zorg,代码行数:27,代码来源:github.py

示例2: _repair_docs

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def _repair_docs(self, doclist, cmp_func, log_func):
        self.log.error("BUG -------------------------------------------------")
        self.log.error("There is more than one doc of type %s:"
                       % (doclist[0].content[KEY_TYPE_KEY],))

        doclist.sort(cmp=cmp_func, reverse=True)
        log_func(doclist[0])
        deferreds = []
        for doc in doclist[1:]:
            log_func(doc)
            d = self._soledad.delete_doc(doc)
            deferreds.append(d)

        self.log.error('Error repairing')
        self.log.error("BUG (please report above info) ----------------------")
        d = defer.gatherResults(deferreds, consumeErrors=True)
        d.addCallback(lambda _: doclist[0])
        return d 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:20,代码来源:openpgp.py

示例3: _buildKeyDict

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def _buildKeyDict(self, keys, actives):
        keydict = {
            fp2id(key.content[doc.KEY_FINGERPRINT_KEY]): KeyDocs(key, [])
            for key in keys}

        deferreds = []
        for active in actives:
            if KEY_ID_KEY in active.content:
                key_id = active.content[KEY_ID_KEY]
                if key_id not in keydict:
                    d = self._soledad.delete_doc(active)
                    deferreds.append(d)
                    continue
                keydict[key_id].active.append(active)

        d = gatherResults(deferreds)
        d.addCallback(lambda _: keydict)
        return d 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:20,代码来源:migrator.py

示例4: delete_all_keys

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def delete_all_keys(self, km):
        def delete_keys(keys):
            deferreds = []
            for key in keys:
                d = km._openpgp.delete_key(key)
                deferreds.append(d)
            return gatherResults(deferreds)

        def check_deleted(_, private):
            d = km.get_all_keys(private=private)
            d.addCallback(lambda keys: self.assertEqual(keys, []))
            return d

        deferreds = []
        for private in [True, False]:
            d = km.get_all_keys(private=private)
            d.addCallback(delete_keys)
            d.addCallback(check_deleted, private)
            deferreds.append(d)
        return gatherResults(deferreds) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:22,代码来源:__init__.py

示例5: _cbSelectWork

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def _cbSelectWork(self, mbox, cmdName, tag):
        """
        Callback for selectWork

        * patched to avoid conformance errors due to incomplete UIDVALIDITY
        line.
        * patched to accept deferreds for messagecount and recent count
        """
        if mbox is None:
            self.sendNegativeResponse(tag, 'No such mailbox')
            return
        if '\\noselect' in [s.lower() for s in mbox.getFlags()]:
            self.sendNegativeResponse(tag, 'Mailbox cannot be selected')
            return

        d1 = defer.maybeDeferred(mbox.getMessageCount)
        d2 = defer.maybeDeferred(mbox.getRecentCount)
        d3 = defer.maybeDeferred(mbox.getUIDNext)
        return defer.gatherResults([d1, d2, d3]).addCallback(
            self.__cbSelectWork, mbox, cmdName, tag) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:22,代码来源:server.py

示例6: _get_config_for_all_services

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def _get_config_for_all_services(self, session):
        if session is None:
            provider_cert = self._get_ca_cert_path()
            session = Session(Anonymous(), self.api_uri, provider_cert)

        services_dict = self._load_provider_configs()
        configs_path = self._get_configs_path()
        with open(configs_path) as jsonf:
            services_dict = Record(**json.load(jsonf)).services
        pending = []
        base = self._disco.get_base_uri()
        for service in self._provider_config.services:
            if service in self.SERVICES_MAP.keys():
                for subservice in self.SERVICES_MAP[service]:
                    uri = base + str(services_dict[subservice])
                    path = self._get_service_config_path(subservice)
                    d = session.fetch_provider_configs(
                        uri, path, method='GET')
                    pending.append(d)
        return defer.gatherResults(pending) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:22,代码来源:config.py

示例7: testDelete

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def testDelete(self):
        """
        Test whether we can delete mailboxes
        """
        def add_mailbox():
            return self.server.theAccount.addMailbox('test-delete/me')

        def login():
            return self.client.login(TEST_USER, TEST_PASSWD)

        def delete():
            return self.client.delete('test-delete/me')

        acc = self.server.theAccount.account

        d1 = self.connected.addCallback(add_mailbox)
        d1.addCallback(strip(login))
        d1.addCallbacks(strip(delete), self._ebGeneral)
        d1.addCallbacks(self._cbStopClient, self._ebGeneral)
        d2 = self.loopback()
        d = defer.gatherResults([d1, d2])
        d.addCallback(lambda _: acc.list_all_mailbox_names())
        d.addCallback(lambda mboxes: self.assertEqual(
            set(mboxes), set(DEFAULT_MBOXES)))
        return d 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:27,代码来源:test_imap.py

示例8: testIllegalInboxDelete

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def testIllegalInboxDelete(self):
        """
        Test what happens if we try to delete the user Inbox.
        We expect that operation to fail.
        """
        self.stashed = None

        def login():
            return self.client.login(TEST_USER, TEST_PASSWD)

        def delete():
            return self.client.delete('inbox')

        def stash(result):
            self.stashed = result

        d1 = self.connected.addCallback(strip(login))
        d1.addCallbacks(strip(delete), self._ebGeneral)
        d1.addBoth(stash)
        d1.addCallbacks(self._cbStopClient, self._ebGeneral)
        d2 = self.loopback()
        d = defer.gatherResults([d1, d2])
        d.addCallback(lambda _: self.failUnless(isinstance(self.stashed,
                                                           failure.Failure)))
        return d 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:27,代码来源:test_imap.py

示例9: testRename

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def testRename(self):
        """
        Test whether we can rename a mailbox
        """
        def create_mbox():
            return self.server.theAccount.addMailbox('oldmbox')

        def login():
            return self.client.login(TEST_USER, TEST_PASSWD)

        def rename():
            return self.client.rename('oldmbox', 'newname')

        d1 = self.connected.addCallback(strip(create_mbox))
        d1.addCallback(strip(login))
        d1.addCallbacks(strip(rename), self._ebGeneral)
        d1.addCallbacks(self._cbStopClient, self._ebGeneral)
        d2 = self.loopback()
        d = defer.gatherResults([d1, d2])
        d.addCallback(lambda _:
                      self.server.theAccount.account.list_all_mailbox_names())
        d.addCallback(lambda mboxes:
                      self.assertItemsEqual(
                          mboxes, DEFAULT_MBOXES + ['newname']))
        return d 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:27,代码来源:test_imap.py

示例10: testHierarchicalRename

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def testHierarchicalRename(self):
        """
        Try to rename hierarchical mailboxes
        """
        acc = self.server.theAccount

        def add_mailboxes():
            return defer.gatherResults([
                acc.addMailbox('oldmbox/m1'),
                acc.addMailbox('oldmbox/m2')])

        def login():
            return self.client.login(TEST_USER, TEST_PASSWD)

        def rename():
            return self.client.rename('oldmbox', 'newname')

        d1 = self.connected.addCallback(strip(add_mailboxes))
        d1.addCallback(strip(login))
        d1.addCallbacks(strip(rename), self._ebGeneral)
        d1.addCallbacks(self._cbStopClient, self._ebGeneral)
        d2 = self.loopback()
        d = defer.gatherResults([d1, d2])
        d.addCallback(lambda _: acc.account.list_all_mailbox_names())
        return d.addCallback(self._cbTestHierarchicalRename) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:27,代码来源:test_imap.py

示例11: testCapability

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def testCapability(self):
        caps = {}

        def getCaps():
            def gotCaps(c):
                caps.update(c)
                self.server.transport.loseConnection()
            return self.client.getCapabilities().addCallback(gotCaps)

        d1 = self.connected
        d1.addCallback(
            strip(getCaps)).addErrback(self._ebGeneral)

        d = defer.gatherResults([self.loopback(), d1])
        expected = {'IMAP4rev1': None, 'NAMESPACE': None, 'LITERAL+': None,
                    'IDLE': None}
        d.addCallback(lambda _: self.assertEqual(expected, caps))
        return d 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:20,代码来源:test_imap.py

示例12: testCapabilityWithAuth

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def testCapabilityWithAuth(self):
        caps = {}
        self.server.challengers[
            'CRAM-MD5'] = cred.credentials.CramMD5Credentials

        def getCaps():
            def gotCaps(c):
                caps.update(c)
                self.server.transport.loseConnection()
            return self.client.getCapabilities().addCallback(gotCaps)
        d1 = self.connected.addCallback(
            strip(getCaps)).addErrback(self._ebGeneral)

        d = defer.gatherResults([self.loopback(), d1])

        expCap = {'IMAP4rev1': None, 'NAMESPACE': None,
                  'IDLE': None, 'LITERAL+': None,
                  'AUTH': ['CRAM-MD5']}

        d.addCallback(lambda _: self.assertEqual(expCap, caps))
        return d

    #
    # authentication
    # 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:27,代码来源:test_imap.py

示例13: testNamespace

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def testNamespace(self):
        """
        Test retrieving namespace
        """
        self.namespaceArgs = None

        def login():
            return self.client.login(TEST_USER, TEST_PASSWD)

        def namespace():
            def gotNamespace(args):
                self.namespaceArgs = args
                self._cbStopClient(None)
            return self.client.namespace().addCallback(gotNamespace)

        d1 = self.connected.addCallback(strip(login))
        d1.addCallback(strip(namespace))
        d1.addErrback(self._ebGeneral)
        d2 = self.loopback()
        d = defer.gatherResults([d1, d2])
        d.addCallback(lambda _: self.assertEqual(self.namespaceArgs,
                                                 [[['', '/']], [], []]))
        return d 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:25,代码来源:test_imap.py

示例14: testFailedStatus

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def testFailedStatus(self):
        """
        Test failed status command with a non-existent mailbox
        """
        def login():
            return self.client.login(TEST_USER, TEST_PASSWD)

        def status():
            return self.client.status(
                'root/nonexistent', 'MESSAGES', 'UIDNEXT', 'UNSEEN')

        def statused(result):
            self.statused = result

        def failed(failure):
            self.failure = failure

        self.statused = self.failure = None
        d1 = self.connected.addCallback(strip(login))
        d1.addCallbacks(strip(status), self._ebGeneral)
        d1.addCallbacks(statused, failed)
        d1.addCallbacks(self._cbStopClient, self._ebGeneral)
        d2 = self.loopback()
        return defer.gatherResults([d1, d2]).addCallback(
            self._cbTestFailedStatus) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:27,代码来源:test_imap.py

示例15: test_create_many

# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import gatherResults [as 别名]
def test_create_many(self):

        store = self._soledad
        w1 = CounterWrapper()
        w2 = CounterWrapper(counter=1)
        w3 = CounterWrapper(counter=2)
        w4 = CounterWrapper(counter=3)
        w5 = CounterWrapper(counter=4)

        d1 = [w1.create(store),
              w2.create(store),
              w3.create(store),
              w4.create(store),
              w5.create(store)]

        d = defer.gatherResults(d1)
        d.addCallback(lambda _: store.get_all_docs())
        d.addCallback(partial(self.assert_num_docs, 5))
        return d 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:21,代码来源:test_soledad_adaptor.py


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