蟋蟀!???
好的,无论如何我都想通了,不得不像这样加载jar文件:
try:
from jpype import *
classpath="/source/build/libs/Photon-0.1.0-SNAPSHOT.jar:/source/build/libs/log4j-1.2.17.jar:/source/build/libs/regxmllib-1.1.1.jar:/source/build/libs/slf4j-log4j12-1.7.25.jar:/source/build/libs/jsr305-3.0.1.jar:/source/build/libs/log4j.properties:/source/build/libs/slf4j-api-1.7.25.jar"
startJVM(getDefaultJVMPath(), "-Djava.class.path=%s" % classpath)
print("JVM started: ",getDefaultJVMPath())
print("classpath=",classpath)
except Exception as e:
print("error launching JVM:", traceback.format_exc())
exit()
print("Starting scan of",scanfolder)
IMPAnalyzer = JClass("com.netflix.imflibrary.app.IMPAnalyzer")
IMPFile = java.io.File(scanfolder)
error_fatal = 0
error_nonfatal = 0
error_warning = 0
if IMPFile.isDirectory():
result_dict = {}
IMPresult_iterator = IMPAnalyzer.analyzePackage(IMPFile).entrySet().iterator()
while IMPresult_iterator.hasNext():
resultpair = IMPresult_iterator.next()
# print(resultpair.getKey(),":")
if len(resultpair.getValue()) > 0:
error_list = []
list_iterator = resultpair.getValue().iterator()
while list_iterator.hasNext():
errorobject = list_iterator.next()
error_list.append(str(errorobject.errorLevel) + ":" + str(errorobject.errorCode) + ":" + errorobject.toString())
if str(errorobject.errorLevel) == "WARNING":
error_warning += 1
elif str(errorobject.errorLevel) == "NON FATAL":
error_nonfatal += 1
elif str(errorobject.errorLevel) == "FATAL":
error_fatal += 1
result_dict[resultpair.getKey()] = error_list
else:
result_dict[resultpair.getKey()]='Ok'
print(scanfolder,"scanned with",error_fatal,"fatal error(s),",error_nonfatal,"nonfatal error(s), and",error_warning,"warning(s)")
pprint.pprint(result_dict)
else:
print(scanfolder,"does not appear to be a valid folder")