Exemplo n.º 1
0
def log_in(user, password):
    global login_user, login_password, login_session

    if is_logged():
        return True

    # NOTE: This request uses the provided login/password pair to
    # access the web service. It requires Digest authentication. It
    # will fail if the pair is not valid.
    #
    try:
        xmlrpc = XMLServerDigest.XmlRpcServer(OWS_WEB_LOGIN, user, password)
        session = xmlrpc.is_logged()
        if session:
            login_user = user
            login_password = password
            login_session = session
            CTK.cfg["admin!ows!login!user"] = user
            CTK.cfg["admin!ows!login!password"] = password
            return True
    except:
        CTK.util.print_exception()
        return None

    return False
Exemplo n.º 2
0
def ProudUsers_Apply():
    # Collect domains
    domains = []

    for v in CTK.cfg.keys('vserver'):
        domains.append (CTK.cfg.get_val('vserver!%s!nick'%(v)))

        for d in CTK.cfg.keys('vserver!%s!match!domain'%(v)):
            domains.append (CTK.cfg.get_val('vserver!%s!match!domain!%s'%(v, d)))

        for d in CTK.cfg.keys('vserver!%s!match!regex'%(v)):
            domains.append (CTK.cfg.get_val('vserver!%s!match!regex!%s'%(v, d)))

    # Send the list
    try:
        xmlrpc = XMLServerDigest.XmlRpcServer (OWS_PROUD)
        xmlrpc.add_domains_to_review(domains)

    except xmlrpclib.ProtocolError, err:
        details  = "Error code:    %d\n" % err.errcode
        details += "Error message: %s\n" % err.errmsg
        details += "Headers: %s\n"       % err.headers

        return '<p>%s</p>'            %(_(PROUS_DIALOG_ERROR1))    + \
               '<p><pre>%s</pre></p>' %(CTK.escape_html(details))  + \
               '<p>%s</p>'            %(_(PROUS_DIALOG_ERROR2))
Exemplo n.º 3
0
def _get_configs():
    del (CTK.cfg['tmp!backup!retrieve'])

    try:
        xmlrpc = XMLServerDigest.XmlRpcServer(OWS_BACKUP, OWS_Login.login_user,
                                              OWS_Login.login_password)
        configs = xmlrpc.list_extended()
        configs.reverse()
    except socket.error, (value, message):
        CTK.cfg['tmp!backup!retrieve!type'] = 'socket'
        CTK.cfg['tmp!backup!retrieve!error'] = message
        return None
Exemplo n.º 4
0
        def __call__(self):
            comment = CTK.post.get_val('comment')
            config = CTK.cfg.serialize()

            del (CTK.cfg['tmp!backup!save'])

            try:
                xmlrpc = XMLServerDigest.XmlRpcServer(OWS_BACKUP,
                                                      OWS_Login.login_user,
                                                      OWS_Login.login_password)
                ret = xmlrpc.upload(CTK.util.to_unicode(config),
                                    CTK.util.to_unicode(comment))
            except socket.error, (value, message):
                CTK.cfg['tmp!backup!save!type'] = 'socket'
                CTK.cfg['tmp!backup!save!error'] = message
                return {'ret': 'error', 'error': message}
Exemplo n.º 5
0
        def __call__(self):
            version = CTK.post.get_val('version')

            del (CTK.cfg['tmp!backup!restore'])

            try:
                xmlrpc = XMLServerDigest.XmlRpcServer(OWS_BACKUP,
                                                      OWS_Login.login_user,
                                                      OWS_Login.login_password)
                cfg_str = xmlrpc.download(version)
                cfg = CTK.Config()

                cfg._parse(cfg_str)
                CTK.cfg.root = copy.deepcopy(cfg.root)
            except socket.error, (value, message):
                CTK.cfg['tmp!backup!restore!type'] = 'socket'
                CTK.cfg['tmp!backup!restore!error'] = message
                return {'ret': 'error', 'error': message}