Python xmlrpclib.Server() Examples

The following are 8 code examples of xmlrpclib.Server(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xmlrpclib , or try the search function .
Example #1
Source File: SpacewalkAPIClient.py    From katprep with GNU General Public License v3.0 6 votes vote down vote up
def __connect(self):
        """
        This function establishes a connection to Spacewalk.
        """
        #set api session and key
        try:
            self.api_session = Server(self.url)
            self.api_key = self.api_session.auth.login(self.username, self.password)
        except Fault as err:
            if err.faultCode == 2950:
                raise InvalidCredentialsException(
                    "Wrong credentials supplied: '%s'", err.faultString
                )
            else:
                raise SessionException(
                    "Generic remote communication error: '%s'", err.faultString
                ) 
Example #2
Source File: oxcSERVER_addserver.py    From openxenmanager with GNU General Public License v2.0 6 votes vote down vote up
def connect_server(self):
        protocol = ["http", "https"][self.ssl]
        self.url = "%s://%s:%d" % (protocol, self.host, self.port)
        print self.url
        self.connection = xmlrpclib.Server(self.url)
        self.connection_events = xmlrpclib.Server(self.url)
        try:
            self.session = self.connection.session.login_with_password(
                self.user, self.password)
            if self.session['Status'] == "Success":
                self.is_connected = True
                self.session_uuid = self.session['Value']
                self.session_events = \
                    self.connection_events.session.login_with_password(
                        self.user, self.password)
                self.session_events_uuid = self.session_events['Value']
                self.connection_events.event.register(
                    self.session_events_uuid, ["*"])
                # tell the controller that we've finished
                self.emit("connect-success")
            else:
                self.emit("connect-failure",
                          self.session['ErrorDescription'][2])
        except:
            self.emit("connect-failure", sys.exc_info()[1]) 
Example #3
Source File: recipe-501148.py    From code with MIT License 5 votes vote down vote up
def getXmlrpcClient(server_uri, auth = ()):
    """ this will return an xmlrpc client which supports
    basic authentication/authentication through cookies 
    """

    trans = CookieAuthXMLRPCTransport()
    if auth!= ():
        trans.credentials = auth
    client = xmlrpclib.Server(server_uri, transport=trans, verbose=False)
    
    return client 
Example #4
Source File: supervisor_services.py    From memex-explorer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def check_process_state(process_name, state='RUNNING'):
    global wait_3
    if wait_3:
        time.sleep(3)
        wait_3 = False
    server = xmlrpclib.Server('http://localhost:9001/RPC2')
    try:
        response = server.supervisor.getProcessInfo(process_name)['statename'] == state
    except socket.error:
        response = None
    return response 
Example #5
Source File: xmlrpclib.py    From patzilla with GNU Affero General Public License v3.0 5 votes vote down vote up
def __enter__(self):
        try:
            if self.__timeout:
                self.__prevDefaultTimeout = socket.getdefaulttimeout()
                socket.setdefaulttimeout(self.__timeout)
            proxy = xmlrpclib.Server(self.__url, allow_none=True)

        except Exception as ex:
            raise Exception("Unable create XMLRPC-proxy for url '%s': %s" % (self.__url, ex))

        return proxy 
Example #6
Source File: server_mgr_cobbler.py    From contrail-server-manager with Apache License 2.0 5 votes vote down vote up
def __init__(self, base_dir=_DEF_BASE_DIR,
                 ip_address=_DEF_COBBLER_IP,
                 port=_DEF_COBBLER_PORT,
                 username=_DEF_USERNAME,
                 password=_DEF_PASSWORD):

        self._smgr_log = ServerMgrlogger()
        self._smgr_log.log(self._smgr_log.DEBUG, "ServerMgrCobbler Init")


        # Store the passed in values
        self._cobbler_ip = ip_address
        self._cobbler_port = port
        self._cobbler_username = username
        self._cobbler_password = password
        try:
            if self._cobbler_port:
                self._server = xmlrpclib.Server(
                    "http://" +
                    self._cobbler_ip + ":" +
                    self._cobbler_port + "/cobbler_api")
            else:
                self._server = xmlrpclib.Server(
                    "http://" +
                    self._cobbler_ip + "/cobbler_api")
            self._token = self._server.login(self._cobbler_username,
                                             self._cobbler_password)
        except subprocess.CalledProcessError as e:
            msg = ("Cobbler Init: error %d when executing"
                   "\"%s\"" %(e.returncode, e.cmd))
            self.log_and_raise_exception(msg, ERR_OPR_ERROR)
        except Exception as e:
            raise e
    # End of __init__ 
Example #7
Source File: ubigraph.py    From TextDetector with GNU General Public License v3.0 5 votes vote down vote up
def start(self):
        server = Server(self.server_url)
        self.graph = server.ubigraph

        # Create a graph
        for i in range(0, 10):
            self.graph.new_vertex_w_id(i)

        # Make some edges
        for i in range(0, 10):
            self.graph.new_edge(i, (i + 1) % 10) 
Example #8
Source File: ubigraph.py    From TextDetector with GNU General Public License v3.0 5 votes vote down vote up
def start(self):
        server = Server(self.server_url)
        self.graph = server.ubigraph

        # Create a graph
        for i in range(0, 10):
            self.graph.new_vertex_w_id(i)

        # Make some edges
        for i in range(0, 10):
            self.graph.new_edge(i, (i + 1) % 10)