當前位置: 首頁>>代碼示例>>Python>>正文


Python jpype.isJVMStarted方法代碼示例

本文整理匯總了Python中jpype.isJVMStarted方法的典型用法代碼示例。如果您正苦於以下問題:Python jpype.isJVMStarted方法的具體用法?Python jpype.isJVMStarted怎麽用?Python jpype.isJVMStarted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在jpype的用法示例。


在下文中一共展示了jpype.isJVMStarted方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import jpype [as 別名]
# 或者: from jpype import isJVMStarted [as 別名]
def __init__(
        self,
        jars=None,
        jvm_started=False,
        mark_time_ranges=False,
        include_range=False,
        jvm_flags=None,
        language="english",
    ):
        """Initializes SUTime.
        """
        self.jars = jars if jars is not None else []
        self._check_language_model_dependency(language.lower())

        if not jvm_started and not jpype.isJVMStarted():
            self._start_jvm(jvm_flags)

        if not jpype.isThreadAttachedToJVM():
            jpype.attachThreadToJVM()
        wrapper = jpype.JClass("edu.stanford.nlp.python.SUTimeWrapper")
        self._sutime = wrapper(mark_time_ranges, include_range, language) 
開發者ID:FraBle,項目名稱:python-sutime,代碼行數:23,代碼來源:sutime.py

示例2: _start_jvm

# 需要導入模塊: import jpype [as 別名]
# 或者: from jpype import isJVMStarted [as 別名]
def _start_jvm(self, minimum_heap_size, maximum_heap_size):
        jvm_options = [
            '-Xms{minimum_heap_size}'.format(minimum_heap_size=minimum_heap_size),
            '-Xmx{maximum_heap_size}'.format(maximum_heap_size=maximum_heap_size),
            '-Djava.class.path={classpath}'.format(
                classpath=self._classpath)
        ]
        if not jpype.isJVMStarted():
            jpype.startJVM(
                jpype.getDefaultJVMPath(),
                *jvm_options
            ) 
開發者ID:FraBle,項目名稱:python-duckling,代碼行數:14,代碼來源:duckling.py

示例3: _init_jvm

# 需要導入模塊: import jpype [as 別名]
# 或者: from jpype import isJVMStarted [as 別名]
def _init_jvm():
    if not jpype.isJVMStarted():
        jars = []
        for top, dirs, files in os.walk(imp.find_module("twkorean")[1] + "/data/lib"):
            for nm in files:
                jars.append(os.path.join(top, nm))
        jpype.startJVM(jpype.getDefaultJVMPath(),
                       "-Djava.class.path=%s" % os.pathsep.join(jars)) 
開發者ID:jaepil,項目名稱:twkorean,代碼行數:10,代碼來源:__init__.py

示例4: _start_jvm

# 需要導入模塊: import jpype [as 別名]
# 或者: from jpype import isJVMStarted [as 別名]
def _start_jvm(self):
        """Start JAVA virtual machine if it is not running."""
        jar_location = resource_filename(__name__, 'infodynamics.jar')
        if not jp.isJVMStarted():
            jp.startJVM(jp.getDefaultJVMPath(), '-ea', ('-Djava.class.path=' +
                                                        jar_location)) 
開發者ID:pwollstadt,項目名稱:IDTxl,代碼行數:8,代碼來源:estimators_jidt.py

示例5: _start_jvm

# 需要導入模塊: import jpype [as 別名]
# 或者: from jpype import isJVMStarted [as 別名]
def _start_jvm(cls, jvm_path, jvm_options, driver_path, log4j_conf):
        if jvm_path is None:
            jvm_path = jpype.get_default_jvm_path()
        if driver_path is None:
            driver_path = os.path.join(cls._BASE_PATH, ATHENA_JAR)
        if log4j_conf is None:
            log4j_conf = os.path.join(cls._BASE_PATH, LOG4J_PROPERTIES)
        if not jpype.isJVMStarted():
            _logger.debug("JVM path: %s", jvm_path)
            args = [
                "-server",
                "-Djava.class.path={0}".format(driver_path),
                "-Dlog4j.configuration=file:{0}".format(log4j_conf),
            ]
            if jvm_options:
                args.extend(jvm_options)
            _logger.debug("JVM args: %s", args)
            if jpype.__version__.startswith("0.6"):
                jpype.startJVM(jvm_path, *args)
            else:
                jpype.startJVM(
                    jvm_path, *args, ignoreUnrecognized=True, convertStrings=True
                )
            cls.class_loader = (
                jpype.java.lang.Thread.currentThread().getContextClassLoader()
            )
        if not jpype.isThreadAttachedToJVM():
            jpype.attachThreadToJVM()
            if not cls.class_loader:
                cls.class_loader = (
                    jpype.java.lang.Thread.currentThread().getContextClassLoader()
                )
            class_loader = jpype.java.net.URLClassLoader.newInstance(
                [jpype.java.net.URL("jar:file:{0}!/".format(driver_path))],
                cls.class_loader,
            )
            jpype.java.lang.Thread.currentThread().setContextClassLoader(class_loader) 
開發者ID:laughingman7743,項目名稱:PyAthenaJDBC,代碼行數:39,代碼來源:connection.py

示例6: attach_thread_to_jvm

# 需要導入模塊: import jpype [as 別名]
# 或者: from jpype import isJVMStarted [as 別名]
def attach_thread_to_jvm() -> None:
    "https://github.com/baztian/jaydebeapi/issues/14#issuecomment-261489331"

    import jpype

    if jpype.isJVMStarted() and not jpype.isThreadAttachedToJVM():
        jpype.attachThreadToJVM()
        jpype.java.lang.Thread.currentThread().setContextClassLoader(
            jpype.java.lang.ClassLoader.getSystemClassLoader()
        ) 
開發者ID:koxudaxi,項目名稱:local-data-api,代碼行數:12,代碼來源:__init__.py

示例7: create_connection

# 需要導入模塊: import jpype [as 別名]
# 或者: from jpype import isJVMStarted [as 別名]
def create_connection(self):
        service_check_tags = ['server:%s' % self._server]
        service_check_tags.extend(self._tags)

        try:
            # Check if the instantclient is available
            cx_Oracle.clientversion()
        except cx_Oracle.DatabaseError as e:
            # Fallback to JDBC
            use_oracle_client = False
            self.log.debug('Oracle instant client unavailable, falling back to JDBC: %s', e)
            connect_string = self.JDBC_CONNECT_STRING.format(self._server, self._service)
        else:
            use_oracle_client = True
            self.log.debug('Running cx_Oracle version %s', cx_Oracle.version)
            connect_string = self.CX_CONNECT_STRING.format(self._user, self._password, self._server, self._service)

        try:
            if use_oracle_client:
                connection = cx_Oracle.connect(connect_string)
            elif JDBC_IMPORT_ERROR:
                self.log.error(
                    "Oracle client is unavailable and the integration is unable to import JDBC libraries. You may not "
                    "have the Microsoft Visual C++ Runtime 2015 installed on your system. Please double check your "
                    "installation and refer to the Datadog documentation for more information."
                )
                raise JDBC_IMPORT_ERROR
            else:
                try:
                    if jpype.isJVMStarted() and not jpype.isThreadAttachedToJVM():
                        jpype.attachThreadToJVM()
                        jpype.java.lang.Thread.currentThread().setContextClassLoader(
                            jpype.java.lang.ClassLoader.getSystemClassLoader()
                        )
                    connection = jdb.connect(
                        self.ORACLE_DRIVER_CLASS, connect_string, [self._user, self._password], self._jdbc_driver
                    )
                except Exception as e:
                    if "Class {} not found".format(self.ORACLE_DRIVER_CLASS) in str(e):
                        msg = """Cannot run the Oracle check until either the Oracle instant client or the JDBC Driver
                        is available.
                        For the Oracle instant client, see:
                        http://www.oracle.com/technetwork/database/features/instant-client/index.html
                        You will also need to ensure the `LD_LIBRARY_PATH` is also updated so the libs are reachable.

                        For the JDBC Driver, see:
                        http://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html
                        You will also need to ensure the jar is either listed in your $CLASSPATH or in the yaml
                        configuration file of the check.
                        """
                        self.log.error(msg)
                    raise

            self.log.debug("Connected to Oracle DB")
            self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.OK, tags=service_check_tags)
        except Exception as e:
            self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL, tags=service_check_tags)
            self.log.error(e)
            raise
        self._connection = connection 
開發者ID:DataDog,項目名稱:integrations-core,代碼行數:62,代碼來源:oracle.py


注:本文中的jpype.isJVMStarted方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。