コード例 #1
0
ファイル: connections.py プロジェクト: flyapen/UgFlu
def parsePBConnectionInfoRecent(managerString, use_ssl=True,
                                defaultPort=configure.defaultSSLManagerPort):
    """The same as L{flumotion.common.connection.parsePBConnectionInfo},
    but fills in missing information from the recent connections cache
    if possible.
    @param managerString: manager string we should connect to
    @type managerString: string
    @param use_ssl: True if we should use ssl
    @type use_ssl: bool
    @param defaultPort: default port to use
    @type defaultPort: int
    @returns: connection info
    @rtype: a L{PBConnectionInfo}
    """
    recent = getRecentConnections()
    if not managerString:
        if recent:
            return recent[0].info
        else:
            raise OptionError('No string given and no recent '
                              'connections to use')

    info = parsePBConnectionInfo(managerString, username=None,
                                 password=None,
                                 port=defaultPort,
                                 use_ssl=use_ssl)

    def compatible(i1, i2):
        if i1.port and i1.port != i2.port:
            return False
        if i1.use_ssl != i2.use_ssl:
            return False
        a1, a2 = i1.authenticator, i2.authenticator
        if a1.username and a1.username != a2.username:
            return False
        if a1.password and a1.password != a2.password:
            return False
        return True

    if not info.authenticator.username:
        for c in recent:
            recent = c.info
            if compatible(info, recent):
                info.authenticator.username = recent.authenticator.username
                info.authenticator.password = recent.authenticator.password
                break
    elif not info.authenticator.password:
        for c in recent:
            recent = c.info
            if compatible(info, recent):
                info.authenticator.password = recent.authenticator.password
                break
    if not (info.authenticator.username and info.authenticator.password):
        raise OptionError('You are connecting to %s for the '
                          'first time; please specify a user and '
                          'password (e.g. user:test@%s).'
                          % (managerString, managerString))
    else:
        return info
コード例 #2
0
ファイル: greeter.py プロジェクト: zaheerm/Flumotion
 def _on_spawner_finished(self, spawner, state):
     # because of the ugly call-by-reference passing of state,
     # we have to update the existing dict, not re-bind with state =
     state["connectionInfo"] = parsePBConnectionInfo(
         "localhost", username="******", password="******", port=spawner.getPort(), use_ssl=True
     )
     state.update(dict(confDir=spawner.getConfDir(), logDir=spawner.getLogDir(), runDir=spawner.getRunDir()))
     self._finished("start_new_success")
コード例 #3
0
ファイル: greeter.py プロジェクト: flyapen/UgFlu
 def on_next(self, state):
     for k, v in self.authenticate.get_state().items():
         state[k] = v
     state['connectionInfo'] = parsePBConnectionInfo(
         state['host'],
         username=state['user'],
         password=state['passwd'],
         port=state['port'],
         use_ssl=not state['use_insecure'])
     return '*finished*'
コード例 #4
0
ファイル: greeter.py プロジェクト: faroncoder/flumotion
 def on_next(self, state):
     for k, v in self.authenticate.get_state().items():
         state[k] = v
     state['connectionInfo'] = parsePBConnectionInfo(
         state['host'],
         username=state['user'],
         password=state['passwd'],
         port=state['port'],
         use_ssl=not state['use_insecure'])
     return '*finished*'
コード例 #5
0
ファイル: greeter.py プロジェクト: offlinehacker/flumotion
 def on_next(self, state):
     for k, v in self.authenticate.get_state().items():
         state[k] = v
     state["connectionInfo"] = parsePBConnectionInfo(
         state["host"],
         username=state["user"],
         password=state["passwd"],
         port=state["port"],
         use_ssl=not state["use_insecure"],
     )
     return "*finished*"
コード例 #6
0
ファイル: greeter.py プロジェクト: ApsOps/flumotion-orig
 def _on_spawner_finished(self, spawner, state):
     # because of the ugly call-by-reference passing of state,
     # we have to update the existing dict, not re-bind with state =
     state['connectionInfo'] = parsePBConnectionInfo(
         'localhost',
         username='******',
         password='******',
         port=spawner.getPort(),
         use_ssl=True)
     state.update(dict(confDir=spawner.getConfDir(),
                       logDir=spawner.getLogDir(),
                       runDir=spawner.getRunDir()))
     state['managerSpawner'] = spawner
     self._finished('start_new_success')
コード例 #7
0
ファイル: greeter.py プロジェクト: faroncoder/flumotion
 def _on_spawner_finished(self, spawner, state):
     # because of the ugly call-by-reference passing of state,
     # we have to update the existing dict, not re-bind with state =
     state['connectionInfo'] = parsePBConnectionInfo('localhost',
                                                     username='******',
                                                     password='******',
                                                     port=spawner.getPort(),
                                                     use_ssl=True)
     state.update(
         dict(confDir=spawner.getConfDir(),
              logDir=spawner.getLogDir(),
              runDir=spawner.getRunDir()))
     state['managerSpawner'] = spawner
     self._finished('start_new_success')
コード例 #8
0
def parsePBConnectionInfoRecent(managerString,
                                use_ssl=True,
                                defaultPort=configure.defaultSSLManagerPort):
    """The same as L{flumotion.common.connection.parsePBConnectionInfo},
    but fills in missing information from the recent connections cache or
    from the default user and password definitions file if possible.
    @param managerString: manager string we should connect to
    @type managerString: string
    @param use_ssl: True if we should use ssl
    @type use_ssl: bool
    @param defaultPort: default port to use
    @type defaultPort: int
    @returns: connection info
    @rtype: a L{PBConnectionInfo}
    """
    recent = getRecentConnections()
    if not managerString:
        if recent:
            return recent[0].info
        else:
            raise OptionError('No string given and no recent '
                              'connections to use')

    info = parsePBConnectionInfo(managerString,
                                 username=None,
                                 password=None,
                                 port=defaultPort,
                                 use_ssl=use_ssl)

    if not (info.authenticator.username and info.authenticator.password):
        recent_infos = [r.asConnectionInfo() for r in recent]
        updateFromConnectionList(info, recent_infos, match_glob=False)
    if not (info.authenticator.username and info.authenticator.password):
        defaults = getDefaultConnections()
        updateFromConnectionList(info, defaults, match_glob=True)
    if not (info.authenticator.username and info.authenticator.password):
        raise OptionError('You are connecting to %s for the '
                          'first time; please specify a user and '
                          'password (e.g. user:test@%s).' %
                          (managerString, managerString))
    else:
        return info
コード例 #9
0
def parsePBConnectionInfoRecent(managerString, use_ssl=True,
                                defaultPort=configure.defaultSSLManagerPort):
    """The same as L{flumotion.common.connection.parsePBConnectionInfo},
    but fills in missing information from the recent connections cache or
    from the default user and password definitions file if possible.
    @param managerString: manager string we should connect to
    @type managerString: string
    @param use_ssl: True if we should use ssl
    @type use_ssl: bool
    @param defaultPort: default port to use
    @type defaultPort: int
    @returns: connection info
    @rtype: a L{PBConnectionInfo}
    """
    recent = getRecentConnections()
    if not managerString:
        if recent:
            return recent[0].info
        else:
            raise OptionError('No string given and no recent '
                              'connections to use')

    info = parsePBConnectionInfo(managerString, username=None,
                                 password=None,
                                 port=defaultPort,
                                 use_ssl=use_ssl)

    if not (info.authenticator.username and info.authenticator.password):
        recent_infos = [r.asConnectionInfo() for r in recent]
        updateFromConnectionList(info, recent_infos, match_glob=False)
    if not (info.authenticator.username and info.authenticator.password):
        defaults = getDefaultConnections()
        updateFromConnectionList(info, defaults, match_glob=True)
    if not (info.authenticator.username and info.authenticator.password):
        raise OptionError('You are connecting to %s for the '
                          'first time; please specify a user and '
                          'password (e.g. user:test@%s).'
                          % (managerString, managerString))
    else:
        return info
コード例 #10
0
 def assertParseEquals(self, _in, out, **kwargs):
     self.assertEquals(str(connection.parsePBConnectionInfo(
         _in, **kwargs)), out)
コード例 #11
0
 def assertParseEquals(self, _in, out, **kwargs):
     self.assertEquals(str(connection.parsePBConnectionInfo(
         _in, **kwargs)), out)