示例#1
0
    async def sh(self, ctx, *, command):
        """Runs a shell command."""

        async with ctx.typing():
            stdout, stderr = await self.run_process(command)

        if stderr:
            text = f'stdout:\n{stdout}\nstderr:\n{stderr}'
        else:
            text = stdout

        try:
            pages = paginator.TextPages(ctx, text)
            await pages.paginate()
        except Exception as e:
            await ctx.send(str(e))
示例#2
0
    async def restart(self, ctx, who):

        cmd = f"systemctl restart {who}"

        async with ctx.typing():
            stdout, stderr = await self.run_process(cmd)

        if stderr:
            text = f'stdout:\n{stdout}\nstderr:\n{stderr}'
        else:
            text = stdout

        try:
            pages = paginator.TextPages(ctx, text)
            await pages.paginate()
        except Exception as e:
            await ctx.send(str(e))