def getRPCInterface(env): # dumbass ServerProxy won't allow us to pass in a non-HTTP url, # so we fake the url we pass into it and always use the transport's # 'serverurl' to figure out what to attach to ''' # dumbass ServerProxy不允许我们传入非http url,(我们使用unix) 所以我们伪造传递给它的url,并且总是使用传输器的url # 'serverurl',附加 ''' # 客户端 return xmlrpclib.ServerProxy('http://127.0.0.1', getRPCTransport(env))
def test_issue_835(self): args = '-m supervisor.supervisord -c supervisor/tests/fixtures/issue-836.conf'.split() supervisord = pexpect.spawn(sys.executable, args, encoding='utf-8') self.addCleanup(supervisord.kill, signal.SIGINT) supervisord.expect_exact('cat entered RUNNING state', timeout=10) server = xmlrpclib.ServerProxy('http://127.0.0.1:9001/RPC2') try: for s in ('The Øresund bridge ends in Malmö', 'hello'): result = server.supervisor.sendProcessStdin('cat', s) self.assertTrue(result) supervisord.expect_exact(s, timeout=5) finally: server('close')()
def supervisor(self): "http://supervisord.org/api.html" # copy from: # https://github.com/Supervisor/supervisor/blob/76df237032f7d9fbe80a0adce3829c8b916d5b58/supervisor/options.py#L1718 if self._supervisorctl is None: self._supervisorctl = xmlrpclib.ServerProxy( # dumbass ServerProxy won't allow us to pass in a non-HTTP url, # so we fake the url we pass into it and # always use the transport's # 'serverurl' to figure out what to attach to "http://127.0.0.1", transport=xmlrpc.SupervisorTransport( serverurl=f"unix://{self.data_root}/supervisor.sock"), ) return self._supervisorctl.supervisor
def test_issue_835(self): filename = pkg_resources.resource_filename(__name__, 'fixtures/issue-835.conf') args = ['-m', 'supervisor.supervisord', '-c', filename] supervisord = pexpect.spawn(sys.executable, args, encoding='utf-8') self.addCleanup(supervisord.kill, signal.SIGINT) supervisord.expect_exact('cat entered RUNNING state', timeout=60) transport = SupervisorTransport('', '', 'unix:///tmp/issue-835.sock') server = xmlrpclib.ServerProxy('http://anything/RPC2', transport) try: for s in ('The Øresund bridge ends in Malmö', 'hello'): result = server.supervisor.sendProcessStdin('cat', s) self.assertTrue(result) supervisord.expect_exact(s, timeout=30) finally: transport.connection.close()
def test_issue_1483b_identifier_from_config_file(self): """When the identifier is supplied in the config file only, that identifier is used instead of the default.""" filename = pkg_resources.resource_filename( __name__, 'fixtures/issue-1483b.conf') args = ['-m', 'supervisor.supervisord', '-c', filename] supervisord = pexpect.spawn(sys.executable, args, encoding='utf-8') self.addCleanup(supervisord.kill, signal.SIGINT) supervisord.expect_exact('supervisord started with pid') from supervisor.compat import xmlrpclib from supervisor.xmlrpc import SupervisorTransport transport = SupervisorTransport('', '', 'unix:///tmp/issue-1483b.sock') try: server = xmlrpclib.ServerProxy( 'http://transport.ignores.host/RPC2', transport) ident = server.supervisor.getIdentification() finally: transport.close() self.assertEqual(ident, "from_config_file")
def getRPCInterface(env): # dumbass ServerProxy won't allow us to pass in a non-HTTP url, # so we fake the url we pass into it and always use the transport's # 'serverurl' to figure out what to attach to return xmlrpclib.ServerProxy('http://127.0.0.1', getRPCTransport(env))
def _get_rpc_client(server_url): return xmlrpclib.ServerProxy( 'http://127.0.0.1', supervisor.xmlrpc.SupervisorTransport('', '', server_url))