本文整理汇总了Python中xmlrpclib.Server方法的典型用法代码示例。如果您正苦于以下问题:Python xmlrpclib.Server方法的具体用法?Python xmlrpclib.Server怎么用?Python xmlrpclib.Server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpclib
的用法示例。
在下文中一共展示了xmlrpclib.Server方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __connect
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Server [as 别名]
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
)
示例2: connect_server
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Server [as 别名]
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])
示例3: getXmlrpcClient
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Server [as 别名]
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
示例4: check_process_state
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Server [as 别名]
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
示例5: __enter__
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Server [as 别名]
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
示例6: __init__
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Server [as 别名]
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__
示例7: start
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Server [as 别名]
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)