Exemplo n.º 1
0
def search_for_remote_path(sshconfighost, match, usesudo):
    """ Depending on the given match, it performs a search on the remote
        server for a match and returns all absolute paths which match.

    ..  note:: Currently only path segments match :(
    ..  note:: If the match is an absolute path, the result will be one
               item which is the given match.

    :param sshconfighost: str - host to connect to
    :param match: str (can be regular expression)
    :param usesudo: boolean. If sudo should be used to find a remote
                    path.
    :rtype: iterable
    """
    if match.startswith('/'):
        result = [zyklop.search.SearchResult(match, 0)]
    else:
        sftpclient = zyklop.ssh.create_fake_sftpclient(
            sshconfighost,
            match,
            use_sudo=usesudo)
        search = zyklop.search.Search(
            '/', match,
            zyklop.search.ParamikoChildNodeProvider(sftpclient))
        result = search.findall()
    return result
Exemplo n.º 2
0
    def test_findall(self, fake_find):
        fake_find.return_value = None

        search = zyklop.search.Search('/', 'dummy', object)
        self.assertListEqual([], list(search.findall()))