本文整理匯總了Python中six.moves.xmlrpc_client.ServerProxy方法的典型用法代碼示例。如果您正苦於以下問題:Python xmlrpc_client.ServerProxy方法的具體用法?Python xmlrpc_client.ServerProxy怎麽用?Python xmlrpc_client.ServerProxy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類six.moves.xmlrpc_client
的用法示例。
在下文中一共展示了xmlrpc_client.ServerProxy方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUpClass
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def setUpClass(self):
import tests.data_test_webpage
import httpbin
self.httpbin_thread = utils.run_in_subprocess(httpbin.app.run, host='0.0.0.0', port=14887, passthrough_errors=False)
self.httpbin = 'http://' + socket.gethostbyname(socket.gethostname()) + ':14887'
self.inqueue = Queue(10)
self.outqueue = Queue(10)
self.fetcher = Fetcher(self.inqueue, self.outqueue)
self.fetcher.splash_endpoint = 'http://127.0.0.1:8050/execute'
self.rpc = xmlrpc_client.ServerProxy('http://localhost:%d' % 24444)
self.xmlrpc_thread = utils.run_in_thread(self.fetcher.xmlrpc_run, port=24444)
self.thread = utils.run_in_thread(self.fetcher.run)
self.proxy_thread = subprocess.Popen(['pyproxy', '--username=binux', '--bind=0.0.0.0',
'--password=123456', '--port=14830',
'--debug'], close_fds=True)
self.proxy = socket.gethostbyname(socket.gethostname()) + ':14830'
示例2: _connect
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def _connect(self, config):
server = config['sat_server']
self.username = config['sat_username']
self.password = config['sat_password']
if not server.startswith("http://") and not server.startswith("https://"):
server = "https://%s" % server
if not server.endswith("XMLRPC"):
server = "%s/XMLRPC" % server
try:
self.force_register = self.options.force_register
except AttributeError:
self.force_register = False
self.logger.debug("Initializing satellite connection to %s", server)
try:
# We need two API endpoints: /XMLRPC and /rpc/api
self.server_xmlrpc = xmlrpc_client.ServerProxy(server, verbose=0, transport=RequestsXmlrpcTransport(server))
server_api = server.replace('/XMLRPC', '/rpc/api')
self.server_rpcapi = xmlrpc_client.ServerProxy(server_api, verbose=0, transport=RequestsXmlrpcTransport(server_api))
except Exception as e:
self.logger.exception("Unable to connect to the Satellite server")
raise SatelliteError("Unable to connect to the Satellite server: " % str(e))
self.logger.debug("Initialized satellite connection")
示例3: _getStringValue
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def _getStringValue(val):
try:
if isinstance(val, xmlrpc_client.ServerProxy):
rval = "<Server Proxy>"
elif hasattr(val, 'asString'):
rval = val.asString()
elif inspect.isclass(val):
rval = '<Class %s.%s>' % (val.__module__, val.__name__)
elif not hasattr(val, '__str__'):
if hasattr(val, '__class__'):
rval = '<unprintable of class %s>' % val.__class__
else:
rval = '<unprintable>'
else:
rval = val
return rval
except Exception as e:
try:
return '<Exception occured while converting %s to string: %s' % (
repr(val), e)
except Exception as e:
return '<Exception occured while converting to repr: %s' % (e,)
示例4: setUpClass
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def setUpClass(self):
shutil.rmtree('./data/tests', ignore_errors=True)
os.makedirs('./data/tests')
def get_taskdb():
return taskdb.TaskDB(self.taskdb_path)
self.taskdb = get_taskdb()
def get_projectdb():
return projectdb.ProjectDB(self.projectdb_path)
self.projectdb = get_projectdb()
def get_resultdb():
return resultdb.ResultDB(self.resultdb_path)
self.resultdb = get_resultdb()
self.newtask_queue = Queue(10)
self.status_queue = Queue(10)
self.scheduler2fetcher = Queue(10)
self.rpc = xmlrpc_client.ServerProxy('http://localhost:%d' % self.scheduler_xmlrpc_port)
def run_scheduler():
scheduler = Scheduler(taskdb=get_taskdb(), projectdb=get_projectdb(),
newtask_queue=self.newtask_queue, status_queue=self.status_queue,
out_queue=self.scheduler2fetcher, data_path="./data/tests/",
resultdb=get_resultdb())
scheduler.UPDATE_PROJECT_INTERVAL = 0.1
scheduler.LOOP_INTERVAL = 0.1
scheduler.INQUEUE_LIMIT = 10
scheduler.DELETE_TIME = 0
scheduler.DEFAULT_RETRY_DELAY = {'': 5}
scheduler._last_tick = int(time.time()) # not dispatch cronjob
self.xmlrpc_thread = run_in_thread(scheduler.xmlrpc_run, port=self.scheduler_xmlrpc_port)
scheduler.run()
self.process = run_in_thread(run_scheduler)
time.sleep(1)
示例5: test_xmlrpc_server
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def test_xmlrpc_server(self, uri='http://127.0.0.1:3423'):
from six.moves.xmlrpc_client import ServerProxy
client = ServerProxy(uri)
assert client.test_1() == 'test_1'
assert client.test_3({'asdf':4}) == {'asdf':4}
示例6: connect_rpc
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def connect_rpc(ctx, param, value):
if not value:
return
try:
from six.moves import xmlrpc_client
except ImportError:
import xmlrpclib as xmlrpc_client
return xmlrpc_client.ServerProxy(value, allow_none=True)
示例7: xml_pypi_server
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def xml_pypi_server(server):
transport = xmlrpc_client.Transport()
client = xmlrpc_client.ServerProxy(server, transport)
try:
yield client
finally:
transport.close()
示例8: __init__
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def __init__(self):
self.server = xmlrpc_client.ServerProxy("http://127.0.0.1:12400", allow_none=True)
self.last_update = None
示例9: __init__
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def __init__(self, uri, transport=None, encoding=None, verbose=0,
allow_none=1):
xmlrpc_client.ServerProxy.__init__(self, uri, transport, encoding,
verbose, allow_none)
self.transport = transport
self._session = None
self.last_login_method = None
self.last_login_params = None
self.API_version = API_VERSION_1_1
示例10: __getattr__
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def __getattr__(self, name):
if name == 'handle':
return self._session
elif name == 'xenapi':
return _Dispatcher(self.API_version, self.xenapi_request, None)
elif name.startswith('login') or name.startswith('slave_local'):
return lambda *params: self._login(name, params)
else:
return xmlrpc_client.ServerProxy.__getattr__(self, name)
示例11: connect
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def connect(url, encoding='UTF-8', use_datetime=True, ssl_verify=True):
# pylint: disable=protected-access
context = None if ssl_verify else ssl._create_unverified_context()
return xmlrpc.ServerProxy(url, encoding=encoding, use_datetime=use_datetime, context=context)
示例12: __init__
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def __init__(self, uri, timeout=DEFAULT_TIMEOUT, *args, **kwargs):
transport = _TimeoutTransport(timeout=timeout, *args, **kwargs)
kwargs['transport'] = transport
xmlrpclib.ServerProxy.__init__(self, uri, *args, **kwargs)
示例13: __getattr__
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def __getattr__(self, name):
res = xmlrpclib.ServerProxy.__getattr__(self, name)
if isinstance(res, xmlrpclib._Method):
res = XMLRPCMethod(res)
return res
示例14: _SearchCommand_search
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def _SearchCommand_search(cmd, _query, options):
from six.moves import xmlrpc_client
from pip._internal.download import PipXmlrpcTransport
index_url = options.index
with cmd._build_session(options) as session:
transport = PipXmlrpcTransport(index_url, session)
pypi = xmlrpc_client.ServerProxy(index_url, transport)
return pypi.search(cmd._spec, cmd._operator)
示例15: __init__
# 需要導入模塊: from six.moves import xmlrpc_client [as 別名]
# 或者: from six.moves.xmlrpc_client import ServerProxy [as 別名]
def __init__(self, username=None, password=None):
self.server = ServerProxy('https://api.opensubtitles.org/xml-rpc', TimeoutSafeTransport(10))
if any((username, password)) and not all((username, password)):
raise ConfigurationError('Username and password must be specified')
# None values not allowed for logging in, so replace it by ''
self.username = username or ''
self.password = password or ''
self.token = None