예제 #1
0
    def addJarFile(self, jarFile):
        __doc__ = """if you want to add a .jar file with a MANIFEST, add it first"""
        jarJarFile = JarFile(jarFile)
        self.addManifest(jarJarFile.getManifest())
        jarJarFile.close()

        jarInputStream = JarInputStream(FileInputStream(jarFile))
        jarEntry = jarInputStream.getNextJarEntry()
        while jarEntry:
            self.getJarOutputStream().putNextEntry(jarEntry)
            buffer = jarray.zeros(self._bufsize, 'b')
            read = jarInputStream.read(buffer)
            while read <> -1:
                self.getJarOutputStream().write(buffer, 0, read)
                read = jarInputStream.read(buffer)
            self.getJarOutputStream().closeEntry()
            jarEntry = jarInputStream.getNextJarEntry()
예제 #2
0
파일: support.py 프로젝트: Britefury/jython
  def addJarFile(self, jarFile):
    __doc__ = """if you want to add a .jar file with a MANIFEST, add it first"""
    jarJarFile = JarFile(jarFile)
    self.addManifest(jarJarFile.getManifest())
    jarJarFile.close()

    jarInputStream = JarInputStream(FileInputStream(jarFile))
    jarEntry = jarInputStream.getNextJarEntry()
    while jarEntry:
      self.getJarOutputStream().putNextEntry(jarEntry)
      buffer = jarray.zeros(self._bufsize, 'b')
      read = jarInputStream.read(buffer)
      while read <> -1:
        self.getJarOutputStream().write(buffer, 0, read)
        read = jarInputStream.read(buffer)
      self.getJarOutputStream().closeEntry()
      jarEntry = jarInputStream.getNextJarEntry()
예제 #3
0
def getPluginInfo(jarFilename):
    if not (os.path.isfile(jarFilename) and jarFilename.endswith(".jar")):
        raise InvalidPluginError("JES plugins must be .jar files.")

    jar = JarFile(jarFilename)
    manifest = jar.getManifest()
    if manifest is None:
        raise InvalidPluginError("JES plugins need to have a JAR manifest "
                                 "indicating that they are for JES.")

    attrs = manifest.mainAttributes
    for attr in REQUIRED_ATTRIBUTES:
        if attrs.getValue(attr) is None:
            raise InvalidPluginError("JES plugins need to define a %s "
                                     "in their JAR manifest." % attr)

    entry = jar.getEntry(".JESDescription.txt")
    if entry is None:
        raise InvalidPluginError(
            "JES plugins need to include a description file.")

    inputStream = jar.getInputStream(entry)
    scanner = Scanner(inputStream).useDelimiter("\\A")
    description = scanner.next() if scanner.hasNext(
    ) else "(No description given.)"
    inputStream.close()

    info = {
        'filename': jarFilename,
        'basename': os.path.basename(jarFilename),
        'dirname': os.path.dirname(jarFilename),
        'title': attrs.getValue("JES-Plugin-Title"),
        'version': attrs.getValue("JES-Plugin-Version"),
        'description': description
    }

    info['display'] = "%s %s (%s)" % (info['title'], info['version'],
                                      info['basename'])
    info['longDescription'] = info['display'] + '\n' + description

    jar.close()
    return info
예제 #4
0
파일: plugins.py 프로젝트: HenryStevens/jes
def getPluginInfo(jarFilename):
    if not (os.path.isfile(jarFilename) and jarFilename.endswith(".jar")):
        raise InvalidPluginError("JES plugins must be .jar files.")

    jar = JarFile(jarFilename)
    manifest = jar.getManifest()
    if manifest is None:
        raise InvalidPluginError("JES plugins need to have a JAR manifest "
                                 "indicating that they are for JES.")

    attrs = manifest.mainAttributes
    for attr in REQUIRED_ATTRIBUTES:
        if attrs.getValue(attr) is None:
            raise InvalidPluginError("JES plugins need to define a %s "
                                     "in their JAR manifest." % attr)

    entry = jar.getEntry(".JESDescription.txt")
    if entry is None:
        raise InvalidPluginError("JES plugins need to include a description file.")

    inputStream = jar.getInputStream(entry)
    scanner = Scanner(inputStream).useDelimiter("\\A")
    description = scanner.next() if scanner.hasNext() else "(No description given.)"
    inputStream.close()

    info = {
        'filename':     jarFilename,
        'basename':     os.path.basename(jarFilename),
        'dirname':      os.path.dirname(jarFilename),
        'title':        attrs.getValue("JES-Plugin-Title"),
        'version':      attrs.getValue("JES-Plugin-Version"),
        'description':  description
    }

    info['display'] = "%s %s (%s)" % (info['title'], info['version'], info['basename'])
    info['longDescription'] = info['display'] + '\n' + description

    jar.close()
    return info
예제 #5
0
# JAR info tool
# priting out Manifest File informatin
# Kota Miura ([email protected])
# 20120417

from java.util.jar import JarFile
#from java.util.jar import Manifest
def printClasses(jf):
	for e in jf.entries():
		print e.getName()

def printManifest(jf):
	mf = jf.getManifest()
	if mf is not None:
		mainatt = mf.getMainAttributes()
		keys = mainatt.keySet()
		for i in keys:
			print i, mainatt.getValue(i)
	else:
		print 'pity, No Manifest File found!'

# main
filepath = 'C:\\ImageJ2\\plugins\\CLI_.jar'
filepath = 'C:\\ImageJ2\\plugins\\AutoThresholdAdjuster3D_.jar'
filepath = 'D:\\gitrepo\\CorrectBleach\\CorrectBleach_.jar'
jf = JarFile(filepath)
printManifest(jf)
jf.close()