当前位置: 首页>>代码示例>>Python>>正文


Python JavaGateway.launch_gateway方法代码示例

本文整理汇总了Python中py4j.java_gateway.JavaGateway.launch_gateway方法的典型用法代码示例。如果您正苦于以下问题:Python JavaGateway.launch_gateway方法的具体用法?Python JavaGateway.launch_gateway怎么用?Python JavaGateway.launch_gateway使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在py4j.java_gateway.JavaGateway的用法示例。


在下文中一共展示了JavaGateway.launch_gateway方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
 def __init__(self):     
     my_logger = getLogger('py4j')
     handler = StreamHandler()
     handler.setLevel(DEBUG)
     my_logger.setLevel(DEBUG)
     my_logger.addHandler(handler)
     
     if glob.glob("./lib/py4j-0.8.1.jar"):
         jarpath = glob.glob("./lib/py4j-0.8.1.jar")[0]
     elif glob.glob("./py4j-0.8.1.jar"):
         jarpath = glob.glob("./py4j-0.8.1")
     else:
         jarpath = None
     
     if glob.glob("./lib/droidnavi-gateway-server*"):
         classpath = glob.glob("./lib/droidnavi-gateway-server*")
     elif glob.glob("./droidnavi-gateway-server*"):
         classpath = glob.glob("./droidnavi-gateway-server*")[0]
     else:
         classpath = None
         
     self.__gateway = JavaGateway.launch_gateway(jarpath=jarpath, classpath=classpath, die_on_exit=True)
     print self.__gateway
     app = QtGui.QApplication(sys.argv)
     mainWindow = MainWindow(self.__gateway)
     sys.exit(app.exec_())
开发者ID:Kenishi,项目名称:DroidNavi,代码行数:28,代码来源:Launcher.py

示例2: testRedirectToFile

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
    def testRedirectToFile(self):
        (_, outpath) = tempfile.mkstemp(text=True)
        (_, errpath) = tempfile.mkstemp(text=True)

        stdout = open(outpath, "w")
        stderr = open(errpath, "w")

        try:
            self.gateway = JavaGateway.launch_gateway(
                redirect_stdout=stdout, redirect_stderr=stderr)
            for i in range(10):
                self.gateway.jvm.System.out.println("Test")
                self.gateway.jvm.System.err.println("Test2")
            # Should not be necessary
            quiet_close(stdout)
            quiet_close(stderr)

            # Test that the redirect files were written to correctly
            with open(outpath, "r") as stdout:
                lines = stdout.readlines()
                self.assertEqual(10, len(lines))
                self.assertEqual("Test\n", lines[0])

            with open(errpath, "r") as stderr:
                lines = stderr.readlines()
                self.assertEqual(10, len(lines))
                self.assertEqual("Test2\n", lines[0])
        finally:
            os.unlink(outpath)
            os.unlink(errpath)
开发者ID:18600597055,项目名称:hue,代码行数:32,代码来源:java_gateway_test.py

示例3: testGatewayAuth

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
    def testGatewayAuth(self):
        self.gateway = JavaGateway.launch_gateway(enable_auth=True)

        # Make sure the default client can connect to the server.
        klass = self.gateway.jvm.java.lang.String
        help_page = self.gateway.help(klass, short_name=True, display=False)
        self.assertGreater(len(help_page), 1)

        # Replace the client with one that does not authenticate.
        # Make sure it fails.
        bad_client = GatewayClient(gateway_parameters=GatewayParameters(
            address=self.gateway.gateway_parameters.address,
            port=self.gateway.gateway_parameters.port))
        self.gateway.set_gateway_client(bad_client)
        try:
            self.gateway.help(klass, short_name=True, display=False)
            self.fail("Expected failure to communicate with gateway server.")
        except Exception:
            # Expected
            pass
        finally:
            # Restore a good client. This allows the gateway to be shut down.
            good_client = GatewayClient(
                gateway_parameters=self.gateway.gateway_parameters)
            self.gateway.set_gateway_client(good_client)
开发者ID:bartdag,项目名称:py4j,代码行数:27,代码来源:java_gateway_test.py

示例4: clearschedule

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
 def clearschedule(self, cfname, counter):
     gateway = JavaGateway.launch_gateway(port=9009,jarpath="/home/ubuntu/py4j0.8.jar", classpath="/home/ubuntu/py-tpcc-master/pytpcc/")
     gateway = JavaGateway(GatewayParameters(port=9009))
     interface_object = gateway.entry_point
     millis = int(round(time.time() * 1000))
     #uuid = gateway.jvm.java.util.UUID()
     clId = gateway.jvm.java.util.UUID.randomUUID()
     l = 20
     interface_object.clearscheduleAndQueueTPCC(20, cfname, 1,  clId, millis)
开发者ID:ssidhanta,项目名称:py-tpcc-master,代码行数:11,代码来源:cassandradriver.py

示例5: __init__

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
  def __init__(self, driver_name, url, username, password):
    if 'py4j' not in sys.modules:
      raise Exception('Required py4j module is not imported.')

    self.gateway = JavaGateway.launch_gateway(classpath=os.environ['CLASSPATH'])

    self.jdbc_driver = driver_name
    self.db_url = url
    self.username = username
    self.password = password

    self.conn = None
开发者ID:ShahabT,项目名称:hue,代码行数:14,代码来源:jdbc.py

示例6: schedule

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
 def schedule(self, cfname, counter):
     gateway = JavaGateway.launch_gateway(port=9009,jarpath="/home/ubuntu/py4j0.8.jar", classpath="/home/ubuntu/py-tpcc-master/pytpcc/")
     gateway = JavaGateway(GatewayParameters(port=9009))
     #logging.info("***before launch gateway  in schedule")
     #logging.info("***before printing values  in schedule")
     interface_object = gateway.entry_point
     millis = int(round(time.time() * 1000))
     #logging.info("***value of millis: ", %millis)
     #uuid = gateway.jvm.java.util.UUID()
     clId = gateway.jvm.java.util.UUID.randomUUID()
     logging.debug("***value of clId: ",clId)
     l = 20
     #interface_object.scheduleAndQueueTPCC()
     interface_object.scheduleAndQueueTPCC(20, cfname, 1,  clId, millis)
开发者ID:ssidhanta,项目名称:py-tpcc-master,代码行数:16,代码来源:cassandradriver.py

示例7: testRedirectToDeque

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
 def testRedirectToDeque(self):
     qout = deque()
     qerr = deque()
     self.gateway = JavaGateway.launch_gateway(
         redirect_stdout=qout, redirect_stderr=qerr)
     for i in range(10):
         self.gateway.jvm.System.out.println("Test")
         self.gateway.jvm.System.err.println("Test2")
     sleep()
     for i in range(10):
         self.assertEqual("Test\n", qout.pop())
         self.assertEqual("Test2\n", qerr.pop())
     self.assertEqual(0, len(qout))
     self.assertEqual(0, len(qerr))
开发者ID:18600597055,项目名称:hue,代码行数:16,代码来源:java_gateway_test.py

示例8: testRedirectToQueue

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
 def testRedirectToQueue(self):
     qout = Queue()
     qerr = Queue()
     self.gateway = JavaGateway.launch_gateway(
         redirect_stdout=qout, redirect_stderr=qerr)
     for i in range(10):
         self.gateway.jvm.System.out.println("Test")
         self.gateway.jvm.System.err.println("Test2")
     sleep()
     for i in range(10):
         self.assertEqual("Test\n", qout.get())
         self.assertEqual("Test2\n", qerr.get())
     self.assertTrue(qout.empty)
     self.assertTrue(qerr.empty)
开发者ID:18600597055,项目名称:hue,代码行数:16,代码来源:java_gateway_test.py

示例9: test_gateway_close

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
async def test_gateway_close():
    """
    Test that shutting down the context does not shut down the Java side gateway if launch_jvm was
    False.

    """
    gateway = JavaGateway.launch_gateway()
    async with Context() as context:
        await Py4JComponent(gateway={'port': gateway.gateway_parameters.port},
                            launch_jvm=False).start(context)
        context.java.jvm.java.lang.System.setProperty('TEST_VALUE', 'abc')

    assert gateway.jvm.java.lang.System.getProperty('TEST_VALUE') == 'abc'
    gateway.shutdown()
开发者ID:asphalt-framework,项目名称:asphalt-py4j,代码行数:16,代码来源:test_component.py

示例10: testRedirectToDeque

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
 def testRedirectToDeque(self):
     end = os.linesep
     qout = deque()
     qerr = deque()
     self.gateway = JavaGateway.launch_gateway(
         redirect_stdout=qout, redirect_stderr=qerr)
     for i in range(10):
         self.gateway.jvm.System.out.println("Test")
         self.gateway.jvm.System.err.println("Test2")
     sleep()
     for i in range(10):
         self.assertEqual("Test{0}".format(end), qout.pop())
         # Assert IN because some Java/OS outputs some garbage on stderr.
         line = qerr.pop()
         if stderr_is_polluted(line):
             line = qerr.pop()
         self.assertEqual("Test2{0}".format(end), line)
     self.assertEqual(0, len(qout))
     self.assertEqual(0, len(qerr))
开发者ID:bartdag,项目名称:py4j,代码行数:21,代码来源:java_gateway_test.py

示例11: testRedirectToFile

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
    def testRedirectToFile(self):
        end = os.linesep
        (out_handle, outpath) = tempfile.mkstemp(text=True)
        (err_handle, errpath) = tempfile.mkstemp(text=True)

        stdout = open(outpath, "w")
        stderr = open(errpath, "w")

        try:
            self.gateway = JavaGateway.launch_gateway(
                redirect_stdout=stdout, redirect_stderr=stderr)
            for i in range(10):
                self.gateway.jvm.System.out.println("Test")
                self.gateway.jvm.System.err.println("Test2")
            self.gateway.shutdown()
            sleep()
            # Should not be necessary
            quiet_close(stdout)
            quiet_close(stderr)

            # Test that the redirect files were written to correctly
            with open(outpath, "r") as stdout:
                lines = stdout.readlines()
                self.assertEqual(10, len(lines))
                self.assertEqual("Test{0}".format(end), lines[0])

            with open(errpath, "r") as stderr:
                lines = stderr.readlines()
                if not stderr_is_polluted(lines[0]):
                    self.assertEqual(10, len(lines))
                    # XXX Apparently, it's \n by default even on windows...
                    # Go figure
                    self.assertEqual("Test2\n", lines[0])
        finally:
            os.close(out_handle)
            os.close(err_handle)
            os.unlink(outpath)
            os.unlink(errpath)
开发者ID:bartdag,项目名称:py4j,代码行数:40,代码来源:java_gateway_test.py

示例12: get_caller_dir

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
from py4j.java_gateway import JavaGateway

from wavesynlib.languagecenter.utils import get_caller_dir


itext_filename = None
self_dir = get_caller_dir()

for filename in os.listdir(self_dir):
    if re.match('itextpdf.*\.jar', filename): # iText jar is found.
        itext_filename = os.path.join(self_dir, filename)
        
if itext_filename is None:
    raise ImportError('Cannot find iText jar file.')
    
_gateway = JavaGateway.launch_gateway(die_on_exit=True, classpath=itext_filename)

class PdfManipulator(object):
    '''
Supported Commands:
    IO Commands:
        read_from_file: read a PDF file, arguments: filename, return a stream;
        write_to_file: write to a PDF file, arguments: filename.
    Manipulation Commands:
        append: append one or more PDF files to the end of the current stream;
            arguments: filelist (the list of the PDF file names);
        remove_pages: remove pages from the stream, 
            arguments: pagenum (the number of the pages which will be removed);
        remove_annotations: remove the annotations of the current stream.

Command Pipeline Example:
开发者ID:xialulee,项目名称:WaveSynPlugins,代码行数:33,代码来源:itextnode.py

示例13: testRedirectToNullOtherProcessGroup

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
 def testRedirectToNullOtherProcessGroup(self):
     self.gateway = JavaGateway.launch_gateway(
         create_new_process_group=True)
     for i in range(4097):  # Hangs if not properly redirected
         self.gateway.jvm.System.out.println("Test")
开发者ID:bartdag,项目名称:py4j,代码行数:7,代码来源:java_gateway_test.py

示例14: testRedirectToNull

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
 def testRedirectToNull(self):
     self.gateway = JavaGateway.launch_gateway()
     for i in range(4097):  # Hangs if not properly redirected
         self.gateway.jvm.System.out.println("Test")
开发者ID:bartdag,项目名称:py4j,代码行数:6,代码来源:java_gateway_test.py

示例15: testJavaopts

# 需要导入模块: from py4j.java_gateway import JavaGateway [as 别名]
# 或者: from py4j.java_gateway.JavaGateway import launch_gateway [as 别名]
 def testJavaopts(self):
     self.gateway = JavaGateway.launch_gateway(javaopts=["-Xmx64m"])
     self.assertTrue(self.gateway.jvm)
开发者ID:bartdag,项目名称:py4j,代码行数:5,代码来源:java_gateway_test.py


注:本文中的py4j.java_gateway.JavaGateway.launch_gateway方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。