def __openRepository(self, serverIdx, resetDir, configValues, serverCache,
            serverName, sslCertAndKey, singleWorker):

        if serverCache is None:
            serverCache = self.servers
        server = serverCache.getCachedServer(serverIdx)
        SQLserver = sqlharness.start()
        if server is None:
            newServer = True
            server = serverCache.startServer(
                    # ServerCache
                    SQLserver=SQLserver,
                    key=serverIdx,
                    serverName=serverName,
                    singleWorker=singleWorker,
                    resetDir=resetDir,
                    # ConaryServer
                    sslCertAndKey=sslCertAndKey,
                    withCache=True,
                    configValues=configValues,
                    )
            # We keep this open to stop others from reusing the port; tell the
            # code which tracks fd leaks so this doesn't reported
            if getattr(server, 'socket', None):
                self._expectedFdLeak(server.socket.fileno())
        else:
            newServer = False
            server.setNeedsReset()

        # make sure map is up to date
        self.cfg.repositoryMap.update(serverCache.getMap())

        # FIXME
        #serverPath, serverClass, serverDir, proxyClass, proxyPath = \
        #                    serverCache.getServerClass('CONARY_SERVER', useSSL)
        #if newServer and proxyPath:
        #    # if we're using a proxy, (re)start it with the right server map
        #    proxyDir = os.path.dirname(self.reposDir) + '/proxy'
        #    contents = ContentStore(proxyDir + '/contents')
        #    if self.proxy:
        #        self.proxy.stop()

        #    if proxies is None and _httpProxy is not None:
        #        # No proxies were specified, and we have an HTTP proxy. Use it
        #        # for the Conary proxy
        #        d = lambda: 1
        #        _httpProxy.updateConfig(d)
        #        pp = d.proxy
        #    else:
        #        pp = proxies

        #    self.proxy = proxyClass('proxy', None,
        #                            contents, proxyPath, None,
        #                            proxyDir, resources.get_path(),
        #                            self.cfg.repositoryMap,
        #                            None, proxies = pp)
        #    self.proxy.start()
        #    global _proxy
        #    _proxy = self.proxy

        #if self.proxy:
        #    self.proxy.updateConfig(self.cfg)
        #elif _httpProxy:
        #    _httpProxy.updateConfig(self.cfg)

        client = conaryclient.ConaryClient(self.cfg)
        repos = client.getRepos()

        label = versions.Label(server.getName() % "%s@rpl:linux")

        ## There may be other things that were not fully started yet, like HTTP
        ## caches and so on. We'll now try an end-to-end connection.

        #ready = False
        #count = 0
        #while count < 500:
        #    try:
        #        repos.troveNames(label)
        #        ready = True
        #        break
        #    except repo_errors.OpenError:
        #        pass

        #    time.sleep(0.01)
        #    count += 1
        #if not ready:
        #    #import epdb, sys
        #    #epdb.post_mortem(sys.exc_info()[2])

        #    try:
        #        self.stopRepository(serverIdx)
        #    except:
        #        pass
        #    raise RuntimeError('unable to open networked repository: %s'
        #                       %str(e))

        if server.needsPGPKey and not server.configValues.get('readOnlyRepository'):
            ascKey = open(resources.get_archive('key.asc'), 'r').read()
            repos.addNewAsciiPGPKey(label, 'test', ascKey)
            server.clearNeedsPGPKey()
        return repos
dataset/ETHPy150Open sassoftware/conary/conary_test/rephelp.py/RepositoryHelper.__openRepository/swapped operands of `%`