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


Python CommandUtils.runCommandInShell2方法代码示例

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


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

示例1: main

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell2 [as 别名]
def main():
    usage = "Usage: %prog [options]"
    parser = ArgumentParser(usage)
    parser.add_argument("-i", "--input-type", dest="input_type", default=DEFAULT_INPUT_TYPE)
    parser.add_argument("-p", "--pkg", dest="pkg")
    parser.add_argument("-f", "--file", dest="json_file", default="packages_minimal.json")
    parser.add_argument("-d", "--disp", dest="display_option", default=DEFAULT_DISPLAY_OPTION)
    parser.add_argument("-s", "--spec-dir", dest="spec_dir", default=SPEC_FILE_DIR)
    parser.add_argument("-l", "--log-dir", dest="log_dir", default=LOG_FILE_DIR)
    parser.add_argument("-t", "--stage-dir", dest="stage_dir", default="../../stage")
    parser.add_argument("-a", "--input-data-dir", dest="input_data_dir", default="../../common/data/")
    parser.add_argument("-o", "--output-dir", dest="output_dir", default="../../stage/common/data")
    options = parser.parse_args()

    constants.setSpecPath(options.spec_dir)
    constants.setLogPath(options.log_dir)
    constants.initialize()

    cmdUtils = CommandUtils()

    if not os.path.isdir(options.output_dir):
        cmdUtils.runCommandInShell2("mkdir -p "+options.output_dir)

    if not options.input_data_dir.endswith('/'):
        options.input_data_dir += '/'
    try:
        specDeps = SpecDependencyGenerator()

        # To display/print package dependencies on console
        if (options.input_type == "pkg" or
                options.input_type == "who-needs" or
                options.input_type == "who-needs-build"):
            specDeps.process(options.input_type, options.pkg, options.display_option)

        elif options.input_type == "json":
            list_json_files = options.json_file.split("\n")
            # Generate the expanded package dependencies json file based on package_list_file
            for json_file in list_json_files:
                shutil.copy2(json_file, options.output_dir)
                json_wrapper_option_list = JsonWrapper(json_file)
                option_list_json = json_wrapper_option_list.read()
                options_sorted = option_list_json.items()
                for install_option in options_sorted:
                    output_file = None
                    input_value = os.path.join(os.path.dirname(json_file), install_option[1]["file"])
                    if options.display_option == "tree" and install_option[1]["title"] == "ISO Packages":
                        continue
                    if options.display_option == "json":
                        output_file = os.path.join(options.output_dir, install_option[1]["file"])
                    print ("Generating the install time dependency list for " + json_file)
                    specDeps.process(options.input_type, input_value, options.display_option, output_file)
    except Exception as e:
        traceback.print_exc()
        sys.stderr.write(str(e))
        sys.stderr.write("Failed to generate dependency lists from spec files\n")
        sys.exit(1)

    sys.stderr.write("Successfully generated dependency lists from spec files\n")
    sys.exit(0)
开发者ID:TiejunChina,项目名称:photon,代码行数:61,代码来源:SpecDeps.py

示例2: findInstalledRPMPackages

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell2 [as 别名]
 def findInstalledRPMPackages(self, chrootID):
     cmd = self.rpmBinary + " " + self.queryRpmPackageOptions
     chrootCmd = self.runInChrootCommand + " " + chrootID
     cmdUtils = CommandUtils()
     result = cmdUtils.runCommandInShell2(cmd, chrootCmd)
     if result is not None:
         return result.decode().split()
     return result
开发者ID:TiejunChina,项目名称:photon,代码行数:10,代码来源:PackageUtils.py

示例3: adjustGCCSpecs

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell2 [as 别名]
    def adjustGCCSpecs(self, package, chrootID, logPath):
        opt = " " + constants.specData.getSecurityHardeningOption(package)
        shutil.copy2(self.adjustGCCSpecScript,  chrootID+"/tmp/"+self.adjustGCCSpecScript)
        cmdUtils=CommandUtils()
        cmd = "/tmp/"+self.adjustGCCSpecScript+opt
        logFile = logPath+"/adjustGCCSpecScript.log"
        chrootCmd=self.runInChrootCommand+" "+chrootID
        returnVal = cmdUtils.runCommandInShell(cmd, logFile, chrootCmd)
        if returnVal:
            return

        self.logger.debug(cmdUtils.runCommandInShell2("ls -la " + chrootID + "/tmp/" + self.adjustGCCSpecScript))
        self.logger.debug(cmdUtils.runCommandInShell2("lsof " + chrootID + "/tmp/" + self.adjustGCCSpecScript))
        self.logger.debug(cmdUtils.runCommandInShell2("ps ax"))

        self.logger.error("Failed while adjusting gcc specs")
        raise "Failed while adjusting gcc specs"
开发者ID:sabertail,项目名称:photon,代码行数:19,代码来源:PackageUtils.py

示例4: adjustGCCSpecs

# 需要导入模块: from CommandUtils import CommandUtils [as 别名]
# 或者: from CommandUtils.CommandUtils import runCommandInShell2 [as 别名]
    def adjustGCCSpecs(self, package, chrootID, logPath):
        opt = " " + constants.specData.getSecurityHardeningOption(package)
        cmdUtils=CommandUtils()
        cpcmd="cp "+ self.adjustGCCSpecScript+" "+chrootID+"/tmp/"+self.adjustGCCSpecScript
        cmd = "/tmp/"+self.adjustGCCSpecScript+opt
        logFile = logPath+"/adjustGCCSpecScript.log"
        chrootCmd=self.runInChrootCommand+" "+chrootID
        returnVal = cmdUtils.runCommandInShell(cpcmd, logFile)
        if not returnVal:
            self.logger.error("Error during copying the file adjust gcc spec")
            raise Exception("Failed while copying adjust gcc spec file")
        returnVal = cmdUtils.runCommandInShell(cmd, logFile, chrootCmd)
        if returnVal:
            return

        self.logger.debug(cmdUtils.runCommandInShell2("ls -la " + chrootID + "/tmp/" + self.adjustGCCSpecScript))
        self.logger.debug(cmdUtils.runCommandInShell2("lsof " + chrootID + "/tmp/" + self.adjustGCCSpecScript))
        self.logger.debug(cmdUtils.runCommandInShell2("ps ax"))

        self.logger.error("Failed while adjusting gcc specs")
        raise Exception("Failed while adjusting gcc specs")
开发者ID:BillTheBest,项目名称:photon,代码行数:23,代码来源:PackageUtils.py


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