import os
import zipfile
def mapToFile(className):
return className.replace('.', '/') + '.class'
def handleWalkError(err):
print 'Error When Access ', err.filename
print err
def findJarInDir(dir_root, className):
classPath = mapToFile(className)
for root, dirs, files in os.walk(dir_root, onerror=handleWalkError):
if not files:
continue
for f in files:
if f.lower().endswith('.jar'):
fpath = os.path.join(root, f)
with zipfile.ZipFile(open(fpath, 'rb')) as zf:
if classPath in zf.namelist():
print fpath
findJarInDir(r'D:\Oracle\Middleware', 'weblogic.Deployer')