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


Python ClassLoader.getSystemClassLoader方法代码示例

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


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

示例1: get_jython_jar

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
def get_jython_jar():
    from java.lang import ClassLoader  # @UnresolvedImport
    cl = ClassLoader.getSystemClassLoader()
    paths = map(lambda url: url.getFile(), cl.getURLs())
    for p in paths:
        if 'jython.jar' in p:
            return p
    raise RuntimeError('Unable to find jython.jar')
开发者ID:wesleybl,项目名称:Pydev,代码行数:10,代码来源:debugger_fixtures.py

示例2: __init__

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
 def __init__(self):
     if ClassPath._instance:
         self.__dict__.update(ClassPath._instance.__dict__)
     else:
         if 'CLASSPATH' in os.environ:
             self._path = classpath.split(classpathsep)
         else:
             raise InstallationError("Cannot find CLASSPATH environmment variable")
         self._stdloader = ClassLoader.getSystemClassLoader()
         ClassPath._instance = self
开发者ID:RedstonerServer,项目名称:Python-Plugin-Loader,代码行数:12,代码来源:jclasspath.py

示例3: addURL

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
 def addURL(self, u): 
      """Purpose: Call this with u= URL for 
      the new Class/jar to be loaded""" 
      sysloader = javaClassLoader.getSystemClassLoader() 
      sysclass = URLClassLoader 
      method = sysclass.getDeclaredMethod("addURL", [javaURL]) 
      a = method.setAccessible(1) 
      jar_a = jarray.array([u], javaObject) 
      b = method.invoke(sysloader, [u]) 
      return u 
开发者ID:dimagi,项目名称:touchforms,代码行数:12,代码来源:classPathHacker.py

示例4: __init__

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
 def __init__(self):
     if ClassPath._instance:
         self.__dict__.update(ClassPath._instance.__dict__)
     else:
         if 'CLASSPATH' in os.environ:
             self._path = classpath.split(classpathsep)
         else:
             self._path = []
         self._stdloader = ClassLoader.getSystemClassLoader()
         ClassPath._instance = self
开发者ID:fiber-space,项目名称:jynx,代码行数:12,代码来源:jclasspath.py

示例5: get_logging_config

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
def get_logging_config():
    """Returns the absolute path to the logging config file
    """

    # We need to find the path to the /pyrig
    from java.lang import ClassLoader
    cl = ClassLoader.getSystemClassLoader()
    paths = map(lambda url: url.getFile(), cl.getURLs())

    # Search all available paths for the one to /pyrig
    path = next(x for x in paths if "pyrig" in x)

    # Now we can return the absolute path to the logging file
    return os.path.join(path, "logging.conf")
开发者ID:potty-dzmeia,项目名称:jatu,代码行数:16,代码来源:misc_utils.py

示例6: _jython_set_classpath

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
def _jython_set_classpath(jars):
    '''
    import a jar at runtime (needed for JDBC [Class.forName])

    adapted by Bastian Bowe from
    http://stackoverflow.com/questions/3015059/jython-classpath-sys-path-and-jdbc-drivers
    '''
    from java.net import URL, URLClassLoader
    from java.lang import ClassLoader
    from java.io import File
    m = URLClassLoader.getDeclaredMethod("addURL", [URL])
    m.accessible = 1
    urls = [File(i).toURL() for i in jars]
    m.invoke(ClassLoader.getSystemClassLoader(), urls)
开发者ID:LetschM,项目名称:iis,代码行数:16,代码来源:dbapi2.py

示例7: set_font

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
def set_font(font_size):
    '''
    Loads font from resources' ttf file.
    DejaVuSans doesn't work in Retina display screens properly, so check OS,
    if OSX then use Monaco instead.
    '''
    # Take into account user preferred font size
    if "mac" in System.getProperty("os.name").lower():
        font = Font("Monaco", Font.PLAIN, font_size)
    else:
        path_to_ttf = 'resources/fonts/dejavu/ttf/DejaVuSans.ttf'
        loader = ClassLoader.getSystemClassLoader()
        stream = loader.getResourceAsStream(path_to_ttf)
        font = Font.createFont(Font.TRUETYPE_FONT, stream)
        font = font.deriveFont(Font.PLAIN, font_size)
    return font
开发者ID:oracc,项目名称:nammu,代码行数:18,代码来源:__init__.py

示例8: importJar

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
def importJar(jarFile):
    '''
    import a jar at runtime (needed for JDBC [Class.forName])

    adapted from http://forum.java.sun.com/thread.jspa?threadID=300557
    Author: SG Langer Jan 2007 translated the above Java to Jython
    Author: [email protected] simplified and updated for jython-2.5.3b3

    >>> importJar('mysql-connector-java-5.1.29-bin.jar')
    >>> import java.lang.Class
    >>> java.lang.Class.forName('com.mysql.jdbc.Driver')
    <type 'com.mysql.jdbc.Driver'>
    '''
    from java.net import URL, URLClassLoader
    from java.lang import ClassLoader
    from java.io import File
    m = URLClassLoader.getDeclaredMethod("addURL", [URL])
    m.accessible = 1
    m.invoke(ClassLoader.getSystemClassLoader(), [File(jarFile).toURL()])
开发者ID:lalo73,项目名称:jython-jdbc-example,代码行数:21,代码来源:importer.py

示例9: get_yaml_config

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
def get_yaml_config(yaml_filename):
    '''
    Load contents of <yaml_filename> into dictionary.
    Note file_handler's filename needs to be an absolute path and hence
    manually changed from here.
    '''
    # Create helper object to load log config from jar resources
    # Load config details from yaml file.
    # Note getResource returns a java.net.URL object which is incompatible
    # with Python's open method, so we need to work around it by copying the
    # file to the home directory and open from there.
    yaml_path = 'resources/config/{}'.format(yaml_filename)
    loader = ClassLoader.getSystemClassLoader()
    config_file_url = loader.getResource(yaml_path)
    # In Unix getResource returns the path with prefix "file:" but in
    # Windows prefix is "jar:file:"
    path_to_jar = str(config_file_url).split('file:')[1]
    path_to_jar = path_to_jar.split('!')[0]

    path_to_config = get_log_path(yaml_filename)

    # Check if log config file exists already.
    # If it doesn't, paste it from JAR's resources to there.
    # If it does, check is up to date with latest version
    if not os.path.isfile(path_to_config):
        copy_yaml_to_home(path_to_jar, yaml_path, path_to_config)
    else:
        # We are running from the JAR file, not the local console
        update_yaml_config(path_to_jar, yaml_path, path_to_config)

    # Load local YAML file and perform required patches on the settings in
    # memory if the settings version is different between the jar and the local
    # file. Ensures that memory and file settings always match.
    (jar_config, local_config,
     jar_version, local_version) = get_config_versions(path_to_jar, yaml_path,
                                                       path_to_config)

    if yaml_filename == 'settings.yaml':
        if different_versions(jar_version, local_version):
            return patch_config(local_config)

    return local_config
开发者ID:oracc,项目名称:nammu,代码行数:44,代码来源:__init__.py

示例10: read_from_jar

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
def read_from_jar(relative_path):
    '''
    reads a file from within a jar. returns the file content
    '''
    from java.lang import ClassLoader
    from java.io import InputStreamReader, BufferedReader

    loader = ClassLoader.getSystemClassLoader()
    stream = loader.getResourceAsStream(relative_path)
    reader = BufferedReader(InputStreamReader(stream))
    
    line = reader.readLine()
    buf = ''
    while line is not None:
        buf += line
        line = reader.readLine()
        
    reader.close()
    stream.close()
    return buf
开发者ID:Schnitzl42,项目名称:JLibcloud,代码行数:22,代码来源:utils.py

示例11: addFile

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
def addFile(jarFile):
    '''
    http://stackoverflow.com/questions/3015059/jython-classpath-sys-path-and-jdbc-drivers
    import a jar at runtime (needed for JDBC [Class.forName])

    adapted from http://forum.java.sun.com/thread.jspa?threadID=300557
    Author: SG Langer Jan 2007 translated the above Java to Jython
    Author: [email protected] simplified and updated for jython-2.5.3b3

    >>> importJar('jars/jtds-1.2.5.jar')
    >>> import java.lang.Class
    >>> java.lang.Class.forName('net.sourceforge.jtds.jdbc.Driver')
    <type 'net.sourceforge.jtds.jdbc.Driver'>
    '''
    from java.net import URL, URLClassLoader
    from java.lang import ClassLoader
    from java.io import File
    m = URLClassLoader.getDeclaredMethod("addURL", [URL])
    m.accessible = 1
    m.invoke(ClassLoader.getSystemClassLoader(), [File(jarFile).toURL()])
    return 
开发者ID:bingpan1,项目名称:programming-language-network,代码行数:23,代码来源:classpath.py

示例12: load

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
 def load(self, img_file, namehint=None):
     """
     Load image from file as a java.awt.image.BufferedImage.
     Return the bufferedimage as a Surface.
     """
     try:
         try:
             f = env.japplet.class.getResource(img_file.replace('\\','/'))    #java uses /, not os.path Windows \
             if not f:
                 raise
         except:
             cload = ClassLoader.getSystemClassLoader()
             f = cload.getResourceAsStream(img_file.replace('\\','/'))
             print "fe"
             
     except:
         
         f = File(img_file)
     
     bimage = ImageIO.read(f)
     surf = Surface(bimage)
     return surf
开发者ID:bowbahdoe,项目名称:Keys,代码行数:24,代码来源:image.py

示例13: execute

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
 def execute(self):
     self.customize(self.options)
     connection = None
     try:
         connection = Overthere.getConnection(CifsConnectionBuilder.CIFS_PROTOCOL, self.options)
         connection.setWorkingDirectory(connection.getFile(self.remotePath))
         # upload the script and pass it to cscript.exe
         targetFile = connection.getTempFile('parameters', '.txt')
         OverthereUtils.write(String(self.script).getBytes(), targetFile)
         targetFile.setExecutable(True)
         exeFile = connection.getTempFile('HpToolsLauncher', '.exe')
         sysloader = ClassLoader.getSystemClassLoader()
         OverthereUtils.write(sysloader.getResourceAsStream("HpTools/HpToolsLauncher.exe"), exeFile)
         exeFile.setExecutable(True)
         # run cscript in batch mode
         scriptCommand = CmdLine.build(exeFile.getPath(), '-paramfile', targetFile.getPath())
         return connection.execute(self.stdout, self.stderr, scriptCommand)
     except Exception, e:
         stacktrace = StringWriter()
         writer = PrintWriter(stacktrace, True)
         e.printStackTrace(writer)
         self.stderr.handleLine(stacktrace.toString())
         return 1
开发者ID:xebialabs-community,项目名称:xlr-loadrunner-plugin,代码行数:25,代码来源:RunLoadRunner.py

示例14: findImageResource

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
 def findImageResource(self, name):
     #Create helper object to load icon images in jar
     loader = ClassLoader.getSystemClassLoader()
     #Load image
     return loader.getResource("resources/images/" + name + ".png")
开发者ID:raquel-ucl,项目名称:NammuToolbarTest,代码行数:7,代码来源:ToolbarView.py

示例15: __init__

# 需要导入模块: from java.lang import ClassLoader [as 别名]
# 或者: from java.lang.ClassLoader import getSystemClassLoader [as 别名]
 def __init__(self):
     self.system_class_loader = ClassLoader.getSystemClassLoader()
     self.url_class_loader = URLClassLoader
开发者ID:nexiles,项目名称:nexiles.jython,代码行数:5,代码来源:classpath_hacker.py


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