def attemptConnectionMethods(self, methods, connectionID, From, to,
                                 protocolName, protocolFactory):
        attemptObjects = []
        for meth in methods:
            atts = meth.attempt(self, connectionID, From, to,
                                protocolName, protocolFactory)
            attemptObjects.extend(atts)

        attemptDeferreds = [att.startAttempt() for att in attemptObjects]

        d = defer.DeferredList(attemptDeferreds,
                              fireOnOneCallback=True,
                              fireOnOneErrback=False)
        def dontLogThat(e):
            e.trap(error.ConnectionLost, error.ConnectionDone)

        for attDef in attemptDeferreds:
            attDef.addErrback(dontLogThat)

        def _unfortunate_defer_hack(results):
            #Do you see what you've made me become?
            if isinstance(results, tuple):
                stuff = [(False, None)] * len(attemptObjects)
                stuff[results[1]] = (True, results[0])
                return stuff
            return results


        def gotResults(results):
            theResult = None
            anyResult = False
            for index, (success, result) in enumerate(results):
                if success:
                    # woohoo!  home free.
                    # XXX Cancel outstanding attempts, maybe.  They'll fail anyway,
                    # because the factory will return None from buildProtocol().
                    theResult = result
                    anyResult = True
                else:
                    attemptObjects[index].cancel()
            if anyResult:
                # theResult will be a SeparateConnectionTransport
                return theResult.subProtocol
            else:
                reason = Failure(AttemptsFailed([fobj for (f, fobj) in results]))
                return reason

        d.addCallback(_unfortunate_defer_hack)
        d.addCallback(gotResults)
        return d
dataset/ETHPy150Open twisted/vertex/vertex/q2q.py/Q2Q.attemptConnectionMethods/original