本文整理汇总了Python中sos.utilities.find函数的典型用法代码示例。如果您正苦于以下问题:Python find函数的具体用法?Python find怎么用?Python find使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了find函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: postproc
def postproc(self):
"""
Obfuscate passwords.
"""
password_xml_regex = re.compile(r'<password>.*</password>', re.IGNORECASE)
for dir_ in self.__jbossServerConfigDirs:
path = os.path.join(self.__jbossHome, dir_)
self.doRegexSub(os.path.join(path,"configuration","*.xml"),
password_xml_regex,
r'<password>********</password>')
tmp = os.path.join(path,"configuration")
for propFile in find("*-users.properties", tmp):
self.doRegexSub(propFile,
r"=(.*)",
r'=********')
# Remove PW from -ds.xml files
tmp = os.path.join(path, "deployments")
for dsFile in find("*-ds.xml", tmp):
self.doRegexSub(dsFile,
password_xml_regex,
r"<password>********</password>")
示例2: __getFiles
def __getFiles(self, configDirAry):
"""
This function will collect files from JBOSS_HOME for analysis. The scope of files to
be collected are determined by options to this SOS plug-in.
"""
for dir_ in configDirAry:
path = os.path.join(self.__jbossHome, dir_)
## First add forbidden files
self.addForbiddenPath(os.path.join(path, "tmp"))
self.addForbiddenPath(os.path.join(path, "work"))
self.addForbiddenPath(os.path.join(path, "data"))
if os.path.exists(path):
## First get everything in the conf dir
confDir = os.path.join(path, "configuration")
self.addForbiddenPath(os.path.join(confDir, 'mgmt-users.properties'))
self.doCopyFileOrDir(confDir, sub=(self.__jbossHome, 'JBOSSHOME'))
## Log dir next
logDir = os.path.join(path, "log")
for logFile in find("*", logDir):
self.addCopySpecLimit(logFile,
self.getOption("logsize"),
sub=(self.__jbossHome, 'JBOSSHOME'))
## Deploy dir
deployDir = os.path.join(path, "deployments")
for deployFile in find("*", deployDir, max_depth=1):
self.addCopySpec(deployFile, sub=(self.__jbossHome, 'JBOSSHOME'))
示例3: __getFiles
def __getFiles(self, configDirAry):
"""
This function will collect files from JBOSS_HOME for analysis. The scope of files to
be collected are determined by options to this SOS plug-in.
"""
for dir_ in configDirAry:
path = os.path.join(self.__jbossHome, dir_)
## First add forbidden files
self.addForbiddenPath(os.path.join(path, "tmp"))
self.addForbiddenPath(os.path.join(path, "work"))
self.addForbiddenPath(os.path.join(path, "data"))
if os.path.exists(path):
## First get everything in the conf dir
confDir = os.path.join(path, "configuration")
self.addForbiddenPath(os.path.join(confDir, 'mgmt-users.properties'))
self.addForbiddenPath(os.path.join(confDir, 'application-users.properties'))
self.doCopyFileOrDir(confDir, sub=(self.__jbossHome, 'JBOSSHOME'))
for logFile in find("*.log", path):
self.addCopySpecLimit(logFile,
self.getOption("logsize"),
sub=(self.__jbossHome, 'JBOSSHOME'))
for xml in find("*.xml", path):
self.addCopySpec(xml)
deployment_info = self.__get_deployment_info(confDir)
deployments = self.__get_deployments(path)
for deployment in deployments:
self.__get_listing_from_deployment(deployment, deployment_info)
示例4: postproc
def postproc(self):
"""
Obfuscate passwords.
"""
for dir in self.__jbossServerConfigDirs:
path=os.path.join(self.__jbossHome, "server", dir)
## Really annoying that there appears to be no vehicle to
## say I want ignore case...argh!
self.doRegexSub(os.path.join(path,"conf","login-config.xml"),
r"\"[Pp][Aa][Ss][Ss][Ww][Oo][Rr][Dd]\".*>.*</[Mm][Oo][Dd][Uu][Ll][Ee]-[Oo][Pp][Tt][Ii][Oo][Nn].*>",
r'"password">********</module-option>')
tmp = os.path.join(path,"conf", "props")
for propFile in find("*-users.properties", tmp):
self.doRegexSub(propFile,
r"=(.*)",
r'=********')
## Remove PW from -ds.xml files
tmp=os.path.join(path, "deploy")
for dsFile in find("*-ds.xml", tmp):
self.doRegexSub(dsFile,
r"<[Pp][Aa][Ss][Ss][Ww][Oo][Rr][Dd].*>.*</[Pp][Aa][Ss][Ss][Ww][Oo][Rr][Dd].*>",
r"<password>********</password>")
return
示例5: setup
def setup(self):
super(RedHatPostgreSQL, self).setup()
scl = "rh-postgresql95"
pghome = self.get_option("pghome")
# Copy PostgreSQL log files.
for filename in find("*.log", pghome):
self.add_copy_spec(filename)
for filename in find("*.log", self.convert_copyspec_scl(scl, pghome)):
self.add_copy_spec(filename)
# Copy PostgreSQL config files.
for filename in find("*.conf", pghome):
self.add_copy_spec(filename)
for filename in find("*.conf", self.convert_copyspec_scl(scl, pghome)):
self.add_copy_spec(filename)
self.add_copy_spec(os.path.join(pghome, "data", "PG_VERSION"))
self.add_copy_spec(os.path.join(pghome, "data", "postmaster.opts"))
self.add_copy_spec_scl(scl, os.path.join(pghome, "data", "PG_VERSION"))
self.add_copy_spec_scl(scl, os.path.join(
pghome,
"data",
"postmaster.opts"
)
)
if scl in self.scls_matched:
self.do_pg_dump(scl=scl, filename="pgdump-scl-%s.tar" % scl)
示例6: setup
def setup(self):
super(RedHatPostgreSQL, self).setup()
# Copy PostgreSQL log files.
for file in find("*.log", self.get_option("pghome")):
self.add_copy_spec(file)
# Copy PostgreSQL config files.
for file in find("*.conf", self.get_option("pghome")):
self.add_copy_spec(file)
self.add_copy_spec(os.path.join(self.get_option("pghome"), "data" , "PG_VERSION"))
self.add_copy_spec(os.path.join(self.get_option("pghome"), "data" , "postmaster.opts"))
示例7: setup
def setup(self):
if self.getOption("dbname"):
if self.getOption("password"):
self.tmp_dir = tempfile.mkdtemp()
self.pg_dump()
else:
self.addAlert("WARN: password must be supplied to dump a database.")
# Copy PostgreSQL log files.
for file in find("*.log", self.getOption("pghome")):
self.addCopySpec(file)
# Copy PostgreSQL config files.
for file in find("*.conf", self.getOption("pghome")):
self.addCopySpec(file)
self.addCopySpec(os.path.join(self.getOption("pghome"), "data" , "PG_VERSION"))
self.addCopySpec(os.path.join(self.getOption("pghome"), "data" , "postmaster.opts"))
示例8: __getServerConfigJarInfo
def __getServerConfigJarInfo(self, configDirAry):
self.__jbossHTMLBody += """
<br/>
<br/>
<div id="profile-jar-info" style="font-weight: bold;">– JBoss Server Configurations Jar Information</div>
"""
for dir in configDirAry:
serverDir = os.path.join("server", dir)
path=os.path.join(self.__jbossHome, serverDir)
if os.path.exists(path):
nicePath=path.replace(os.sep, "-")
self.__jbossHTMLBody += """
<div>
— Summary of Jar Files in the <tt>%s</tt> JBoss Server Configuration
( <a href="javascript:show('%s')">Show</a> / <a
href="javascript:hide('%s')">Hide</a> ):
</div>
<div id="%s" style="overflow: hidden; display: none">
<ul style="list-style-type: square">
""" % (dir, nicePath,nicePath,nicePath)
found = False
for jarFile in find("*.jar", path):
found = True
nicePath=jarFile.replace(os.sep, "-")
self.__jbossHTMLBody += """
<li id="system-jar-info">Jar File: <tt>%s</tt><br/>
MD5: <tt>%s</tt>
<br /> Manifest File (
<a href="javascript:show('%s')">Show</a> /
<a href="javascript:hide('%s')">Hide</a> ):<br />
<div id="%s" style="overflow: hidden; display: none">
<pre>
%s
</pre>
</div>
</li>
""" % (jarFile,
self.__getMd5(jarFile),
nicePath,
nicePath,
nicePath,
self.__getManifest(jarFile))
if not found:
self.addAlert("WARN: No jars found in the JBoss server configuration (%s)." % (path))
self.__jbossHTMLBody += """
</ul>
</div>
"""
else:
self.addAlert("ERROR: JBoss server configuration path (" + path + ") does not exist.")
return
示例9: __getFiles
def __getFiles(self, configDirAry):
"""
This function will collect files from JBOSS_HOME for analysis. The scope of files to
be collected are determined by options to this SOS plug-in.
"""
for dir in configDirAry:
path=os.path.join(self.__jbossHome, "server", dir)
## First add forbidden files
self.addForbiddenPath(os.path.join(path, "tmp"))
self.addForbiddenPath(os.path.join(path, "work"))
self.addForbiddenPath(os.path.join(path, "data"))
if os.path.exists(path):
## First get everything in the conf dir
confDir=os.path.join(path, "conf")
self.doCopyFileOrDir(confDir)
## Log dir next
logDir=os.path.join(path, "log")
for logFile in find("*", logDir):
self.addCopySpecLimit(logFile, self.getOption("logsize"))
## Deploy dir
deployDir=os.path.join(path, "deploy")
for deployFile in find("*", deployDir, max_depth=1):
self.addCopySpec(deployFile)
## Get application deployment descriptors if designated.
if self.isOptionEnabled("appxml"):
appxml=self.getOption("appxml")
## I'd rather use comma as the delimiter but getOption doesn't seem to be passing it through.
## Since we are using spaces as the delimiter, we need to filter out empty list elements
## if the user did something like ' all default web '.
appxml=appxml.split(' ')
## Flter(None doesn't work. Allows 0.
appxml=filter(lambda x: len(x), appxml)
for app in appxml:
pat = os.path.join("*%s*" % (app,), "WEB-INF")
for file in find("*.xml", deployDir, path_pattern=pat):
self.addCopySpec(file)
return
示例10: setup
def setup(self):
super(RedHatPostgreSQL, self).setup()
pghome = self.get_option("pghome")
scl = None
for pkg in self.packages[1:]:
# The scl name, package name, and service name all differ slightly
# but is at least consistent in doing so across versions, so we
# need to do some mangling here
if self.service_is_running(pkg.replace('-server', '')):
scl = pkg.split('-postgresql-')[0]
# Copy PostgreSQL log files.
for filename in find("*.log", pghome):
self.add_copy_spec(filename)
for filename in find("*.log", self.convert_copyspec_scl(scl, pghome)):
self.add_copy_spec(filename)
# Copy PostgreSQL config files.
for filename in find("*.conf", pghome):
self.add_copy_spec(filename)
for filename in find("*.conf", self.convert_copyspec_scl(scl, pghome)):
self.add_copy_spec(filename)
self.add_copy_spec(os.path.join(pghome, "data", "PG_VERSION"))
self.add_copy_spec(os.path.join(pghome, "data", "postmaster.opts"))
self.add_copy_spec_scl(scl, os.path.join(pghome, "data", "PG_VERSION"))
self.add_copy_spec_scl(scl, os.path.join(
pghome,
"data",
"postmaster.opts"
)
)
if scl and scl in self.scls_matched:
self.do_pg_dump(scl=scl, filename="pgdump-scl-%s.tar" % scl)
示例11: __get_deployment_info
def __get_deployment_info(self, dir_):
"""Gets the deployment name to sha1 mapping for all deployments defined
in configs under dir_"""
deployment_info = {}
for config in find("*.xml", dir_):
root = ElementTree.parse(config).getroot()
# the namespace is harder to fetch than it should be
ns = root.tag.rpartition("}")[0]
ns += "}"
for deployment in root.findall("./%sdeployments/%sdeployment" % (ns, ns)):
name = deployment.attrib.get("name")
sha1 = deployment.getchildren()[0].attrib.get("sha1")
deployment_info[sha1] = name
return deployment_info
示例12: postproc
def postproc(self):
"""
Obfuscate passwords.
"""
for dir_ in self.__jbossServerConfigDirs:
path = os.path.join(self.__jbossHome, dir_)
self.doRegexSub(os.path.join(path,"configuration","login-config.xml"),
re.compile(r'"password".*>.*</module-option>', re.IGNORECASE),
r'"password">********</module-option>')
tmp = os.path.join(path,"conf", "props")
for propFile in find("*-users.properties", tmp):
self.doRegexSub(propFile,
r"=(.*)",
r'=********')
# Remove PW from -ds.xml files
tmp = os.path.join(path, "deploy")
for dsFile in find("*-ds.xml", tmp):
self.doRegexSub(dsFile,
re.compile(r"<password.*>.*</password.*>", re.IGNORECASE),
r"<password>********</password>")
示例13: __getStdJarInfo
def __getStdJarInfo(self):
found = False
jar_info_list = []
for jarFile in find("*.jar", self.__jbossHome):
checksum = self.__getMd5(jarFile)
manifest = self.__getManifest(jarFile)
path = jarFile.replace(self.__jbossHome, 'JBOSSHOME')
if manifest:
manifest = manifest.strip()
jar_info_list.append((path, checksum, manifest))
found = True
if found:
jar_info_list.sort()
self.addStringAsFile("\n".join([
"%s\n%s\n%s\n" % (name, checksum, manifest)
for (name, checksum, manifest) in jar_info_list]),
'jarinfo.txt')
else:
self.addAlert("WARN: No jars found in JBoss system path (" + self.__jbossHome + ").")
示例14: test_find_leaf
def test_find_leaf(self):
leaves = find("leaf", TEST_DIR)
self.assertTrue(any(name.endswith("leaf") for name in leaves))
示例15: test_not_in_pattern
def test_not_in_pattern(self):
leaves = find("leaf", TEST_DIR, path_pattern="tests/path")
self.assertFalse(any(name.endswith("leaf") for name in leaves))