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


Python GaussLog.printMessage方法代码示例

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


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

示例1: executeCommand

# 需要导入模块: from script.util.GaussLog import GaussLog [as 别名]
# 或者: from script.util.GaussLog.GaussLog import printMessage [as 别名]
def executeCommand():
    """
    """
    failedNodes = ""
    succeedNodes = ""
    try:
        command = (g_opts.cmd.strip()).split(" ")
        if len(command) > 1:
            GaussLog.exitWithError("Parameter -c input error, only need command.")
        checkCmd = "which %s" % command[0]
        (status, output) = g_sshTool.getSshStatusOutput(checkCmd)
        for node in status.keys():
            if status[node] != 0:
                failedNodes += "%s " % node
            else:
                succeedNodes += "%s " % node
        if failedNodes != "":
            GaussLog.exitWithError(
                "Command %s not exist or not have executable permissions on %s." % (command, failedNodes)
            )
        failedNodes = ""
        succeedNodes = ""
        executeCmd = g_opts.cmd + " " + g_opts.parameterlist
        #############################################################
        cmdFile = "%s/ClusterCall_%d.sh" % (DefaultValue.getTmpDirFromEnv(), os.getpid())
        cmdCreateFile = "touch %s" % cmdFile
        (status, output) = commands.getstatusoutput(cmdCreateFile)
        if status != 0:
            GaussLog.exitWithError("Touch file %s failed!" % cmdFile)

        cmdFileMod = "chmod 640 %s" % cmdFile
        (status, output) = commands.getstatusoutput(cmdFileMod)
        if status != 0:
            GaussLog.exitWithError("Chmod file %s failed!" % cmdFile)

        fp = open(cmdFile, "a")
        fp.write("#!/bin/sh")
        fp.write(os.linesep)
        fp.write("%s" % (executeCmd))
        fp.write(os.linesep)
        fp.flush()
        fp.close()

        ##############################################################
        cmdDir = DefaultValue.getTmpDirFromEnv()
        g_sshTool.scpFiles(cmdFile, cmdDir)
        cmdExecute = "sh %s" % cmdFile
        (status, output) = g_sshTool.getSshStatusOutput(cmdExecute)

        for node in status.keys():
            if status[node] != 0:
                failedNodes += "%s " % node
            else:
                succeedNodes += "%s " % node
        if failedNodes != "" and succeedNodes != "":
            GaussLog.printMessage("Execute command failed on %s." % failedNodes)
            GaussLog.printMessage("Execute command succeed on %s.\n" % succeedNodes)
        elif failedNodes == "":
            GaussLog.printMessage("Execute command succeed on all nodes.\n")
        elif succeedNodes == "":
            GaussLog.printMessage("Execute command failed on all nodes.\n")

        GaussLog.printMessage("Output:\n%s" % output)

        cmdFileRm = "rm %s" % cmdFile
        g_sshTool.executeCommand(cmdFileRm, "rm cmdFile")

    except Exception, e:
        if fp:
            fp.close()
        cmdFileRm = "rm %s" % cmdFile
        g_sshTool.executeCommand(cmdFileRm, "rm cmdFile")
        GaussLog.exitWithError(str(e))
开发者ID:jianhuiz,项目名称:cf-apps,代码行数:75,代码来源:ClusterCall.py


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