Python-显示控制台输出

Python-显示控制台输出,python,Python,现在我有一个命令,允许您将更改应用到我的托管服务器上的本地文件。是否有办法使bot发送等待ctx。发送(…)git reset命令的输出以不协调? 通常,输出如下所示: HEAD is now at f8dd7fe Slash Commands/Pull Feature/JSON Changes! 这是我当前的命令: @client.command() @commands.has_角色('Bot Manager') 异步def gitpull(ctx): typebot=config['Bot

现在我有一个命令,允许您将更改应用到我的托管服务器上的本地文件。是否有办法使bot发送
等待ctx。发送(…)
git reset命令的输出以不协调? 通常,输出如下所示:

HEAD is now at f8dd7fe Slash Commands/Pull Feature/JSON Changes!
这是我当前的命令:

@client.command()
@commands.has_角色('Bot Manager')
异步def gitpull(ctx):
typebot=config['BotType']
如果typebot==“BETA”:
系统(“git fetch--all”)
操作系统(“git重置——硬源/测试实例”)
等待ctx.send(“我已尝试*提取**TestingInstance**中的最新更改”)
elif typebot==“稳定”:
系统(“git fetch--all”)
操作系统(“git重置——硬源/主控”)
等待ctx.send(“我已尝试*提取**主机**中最近的更改”)
任何建议或提示都会大有帮助

使用模块,而不是操作系统
。这将允许您捕获子流程的输出

比如:

@client.command()
@commands.has_role('Bot Manager')
async def gitpull(ctx):
    typebot = config['BotType']
    output = ''
    if typebot == "BETA":
        p = subprocess.run("git fetch --all", shell=True, text=True, capture_output=True, check=True)
        output += p.stdout
        p = subprocess.run("git reset --hard origin/TestingInstance", shell=True, text=True, capture_output=True, check=True)
        output += p.stdout
        await ctx.send(f"I have attempted to *pull* the most recent changes in **TestingInstance**\n{output}")
    elif typebot == "STABLE":
        p = subprocess.run("git fetch --all", shell=True, text=True, capture_output=True, check=True)
        output += p.stdout
        p = subprocess.run("git reset --hard origin/master", shell=True, text=True, capture_output=True, check=True)
        output += p.stdout
        await ctx.send(f"I have attempted to *pull* the most recent changes in **Master**\n{output}")