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


Python Pkg.substitute_shell_vars方法代码示例

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


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

示例1: check

# 需要导入模块: import Pkg [as 别名]
# 或者: from Pkg import substitute_shell_vars [as 别名]
    def check(self, pkg):
	# Check only binary package
	if pkg.isSource():
	    return

        list=[]
        for f in pkg.files().keys():
            if rc_regex.search(f):
                basename=basename_regex.search(f).group(1)
                list.append(basename)
		if pkg.files()[f][0] & 0500 != 0500:
		    yield InitScriptNonExecutable(pkg,f)
	    
		if dot_in_name_regex.match(basename):
			yield InitScriptNameWithDot(pkg, f)
                # check chkconfig call in %post and %preun
                postin=pkg[rpm.RPMTAG_POSTIN] or pkg[rpm.RPMTAG_POSTINPROG]
                if not postin:
                    yield InitScriptWithoutChkconfigPostin(pkg, f)
                else:
                    if not chkconfig_regex.search(postin):
                        yield PostinWithoutChkconfig(pkg, f)                    
                    
                preun=pkg[rpm.RPMTAG_PREUN] or pkg[rpm.RPMTAG_PREUNPROG]
                if not preun:
                    yield InitScriptWithoutChkconfigPreun(pkg, f)
                else:
                    if not chkconfig_regex.search(preun):
                        yield PreunWithoutChkconfig(pkg, f)

                # check common error in file content
                fd=open(pkg.dirName() + '/' + f, 'r')
                content=fd.read(-1)
                fd.close()
                
                if not status_regex.search(content):
                    yield NoStatusEntry(pkg, f)
                    
                if not reload_regex.search(content):
                    yield NoReloadEntry(pkg, f)
                    
                res=chkconfig_content_regex.search(content)
                if not res:
                    yield NoChkconfigLine(pkg, f)
                else:
                    if res.group(1) == '-':
                        yield NoDefaultRunlevel(pkg)
                        
                res=subsys_regex.search(content)
                if not res:
                    yield SubsysNotUsed(pkg, f)
                else:
                    name=res.group(1)
                    if name != basename:
                        error=1
                        if name[0] == '$':
                            value=Pkg.substitute_shell_vars(name, content)
                            if value == basename:
                                error=0
                        if error:
                            yield IncoherentSubsys(pkg, f, name)
开发者ID:bhdn,项目名称:scrutiny,代码行数:63,代码来源:InitScriptCheck.py

示例2: check_binary

# 需要导入模块: import Pkg [as 别名]
# 或者: from Pkg import substitute_shell_vars [as 别名]

#.........这里部分代码省略.........
                    in_lsb_tag = True
                    continue
                if line.endswith('### END INIT INFO'):
                    in_lsb_tag = False
                    for kw, vals in lsb_tags.items():
                        if len(vals) != 1:
                            printError(pkg, 'redundant-lsb-keyword', kw)

                    for kw in RECOMMENDED_LSB_KEYWORDS:
                        if kw not in lsb_tags:
                            printWarning(pkg, 'missing-lsb-keyword',
                                         "%s in %s" % (kw, fname))
                if in_lsb_tag:
                    # TODO maybe we do not have to handle this ?
                    if lastline.endswith('\\'):
                        line = lastline + line
                    else:
                        res = lsb_tags_regex.search(line)
                        if not res:
                            cres = lsb_cont_regex.search(line)
                            if not (in_lsb_description and cres):
                                in_lsb_description = False
                                printError(
                                    pkg, 'malformed-line-in-lsb-comment-block',
                                    line)
                            else:
                                lsb_tags["Description"][-1] += \
                                    " " + cres.group(1)
                        else:
                            tag = res.group(1)
                            if not tag.startswith('X-') and \
                                    tag not in LSB_KEYWORDS:
                                printError(pkg, 'unknown-lsb-keyword', line)
                            else:
                                in_lsb_description = (tag == 'Description')
                                if tag not in lsb_tags:
                                    lsb_tags[tag] = []
                                lsb_tags[tag].append(res.group(2))
                    lastline = line

                if not status_found and status_regex.search(line):
                    status_found = True

                if not reload_found and reload_regex.search(line):
                    reload_found = True

                res = chkconfig_content_regex.search(line)
                if res:
                    chkconfig_content_found = True
                    if use_deflevels:
                        if res.group(1) == '-':
                            printWarning(pkg, 'no-default-runlevel', fname)
                    elif res.group(1) != '-':
                        printWarning(pkg, 'service-default-enabled', fname)

                res = subsys_regex.search(line)
                if res:
                    subsys_regex_found = True
                    name = res.group(1)
                    if use_subsys and name != basename:
                        error = True
                        if name[0] == '$':
                            value = Pkg.substitute_shell_vars(name,
                                                              content_str)
                            if value == basename:
                                error = False
                        else:
                            i = name.find('}')
                            if i != -1:
                                name = name[0:i]
                                error = name != basename
                        if error and len(name):
                            if name[0] == '$':
                                printWarning(pkg, 'incoherent-subsys', fname,
                                             name)
                            else:
                                printError(pkg, 'incoherent-subsys', fname,
                                           name)

            if "Default-Start" in lsb_tags:
                if "".join(lsb_tags["Default-Start"]):
                    printWarning(pkg, 'service-default-enabled', fname)

            if not status_found:
                printError(pkg, 'no-status-entry', fname)
            if not reload_found:
                printWarning(pkg, 'no-reload-entry', fname)
            if not chkconfig_content_found:
                printError(pkg, 'no-chkconfig-line', fname)
            if not subsys_regex_found and use_subsys:
                printError(pkg, 'subsys-not-used', fname)
            elif subsys_regex_found and not use_subsys:
                printError(pkg, 'subsys-unsupported', fname)

        if len(initscript_list) == 1:
            pkgname = re.sub("-sysvinit$", "", pkg.name.lower())
            goodnames = (pkgname, pkgname + 'd')
            if initscript_list[0] not in goodnames:
                printWarning(pkg, 'incoherent-init-script-name',
                             initscript_list[0], str(goodnames))
开发者ID:rpm-software-management,项目名称:rpmlint,代码行数:104,代码来源:InitScriptCheck.py


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