예제 #1
0
    def test_split_site_path(self):
        site = "localhost:/root/file.txt"
        malformed_site = "localhost/root/file.txt"  # mind a missing colon
        multicolon_site = "localhost:/root/file.txt:1"

        a, b = TransferClientFacade.split_site_path(site)
        assert a == 'localhost'
        assert b == '/root/file.txt'

        c, d = TransferClientFacade.split_site_path(malformed_site)
        assert d is None
        assert c is None

        e, f = TransferClientFacade.split_site_path(multicolon_site)
        assert e == 'localhost'
        assert f == '/root/file.txt:1'
예제 #2
0
    def _session_ok(self, site_path, token):
        """
        Check user session at a site.

        :param site_name: site to check
        :param token: user token
        :return:True or False
        """
        name, path = TransferClientFacade.split_site_path(site_path)
        if name is None:
            print "Malformed site path (should be sitename:path)"
            return None
        site_client, site_id = UserCommand._get_site_id(name, token)
        ok = False
        if site_id:
            ok = site_client.get_session_info(site_id)['ok']
            if not ok:
                print "Please log to the site %s first" % (name)
        else:
            print "site %s not found !" % (name)
        return ok