Esempio n. 1
0
def getRecentConnections():
    """
    Fetches a list of recently used connections
    @returns: recently used connections
    @rtype: list of L{RecentConnection}
    """

    def _parseConnection(filename):
        tree = minidom.parse(filename)
        state = {}
        for childNode in tree.documentElement.childNodes:
            if (childNode.nodeType != Node.TEXT_NODE and
                childNode.nodeType != Node.COMMENT_NODE):
                state[childNode.nodeName] = childNode.childNodes[0].wholeText
        state['port'] = int(state['port'])
        state['use_insecure'] = (state['use_insecure'] != '0')
        authenticator = Authenticator(username=state['user'],
                                      password=state['passwd'])
        return PBConnectionInfo(state['host'], state['port'],
                                not state['use_insecure'],
                                authenticator)

    recentFilenames = _getRecentFilenames()
    recentConnections = []
    for filename in sorted(recentFilenames, reverse=True):
        try:
            state = _parseConnection(filename)
            recentConnections.append(
                RecentConnection(str(state),
                                 filename=filename,
                                 info=state))
        except Exception, e:
            log.warning('connections', 'Error parsing %s: %r', filename, e)
Esempio n. 2
0
    def _populateSizes(self, sizes):
        # Set sizes before populating the values, since
        # it trigger size_changed which depends on this
        # to be set
        self._sizes = sizes

        values = []
        for w, h in sorted(sizes.keys(), reverse=True):
            values.append(['%d x %d' % (w, h), (w, h)])
        self.size.prefill(values)
Esempio n. 3
0
def getRecentConnections():
    """
    Fetches a list of recently used connections
    @returns: recently used connections
    @rtype: list of L{RecentConnection}
    """

    recentFilenames = _getRecentFilenames()
    recentConnections = []
    for filename in sorted(recentFilenames, reverse=True):
        try:
            state = _parseSingleConnectionFile(filename)
            recentConnections.append(RecentConnection(str(state), filename=filename, info=state))
        except Exception, e:
            log.warning("connections", "Error parsing %s: %r", filename, e)