Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def git(self, ctx, pull_push, *, message=None):
"""
Executes git statements in the system shell.
This uses the system shell as defined in $SHELL, or `/bin/bash` otherwise.
Execution can be cancelled by closing the paginator.
"""
message = message if message is not None else "Updated files."
if pull_push == "push":
shellcmd = f'sudo git add .&&sudo git commit -m "{message}"&&sudo git push'
elif pull_push == "pull":
shellcmd = 'sudo git pull'
else:
return await ctx.send("Invalid option given")
async with ReplResponseReactor(ctx.message):
paginator = WrappedPaginator(prefix="```sh", max_size=1985)
paginator.add_line(f"$ git {pull_push}\n")
interface = PaginatorInterface(ctx.bot, paginator, owner=ctx.author)
self.bot.loop.create_task(interface.send_to(ctx))
with ShellReader(shellcmd) as reader:
async for line in reader:
if interface.closed:
return
await interface.add_line(line)
async def jsk_shell(self, ctx: commands.Context, *, argument: codeblock_converter):
"""
Executes statements in the system shell.
This uses the system shell as defined in $SHELL, or `/bin/bash` otherwise.
Execution can be cancelled by closing the paginator.
"""
async with ReplResponseReactor(ctx.message):
with self.submit(ctx):
paginator = WrappedPaginator(prefix="```sh", max_size=1985)
paginator.add_line(f"$ {argument.content}\n")
interface = PaginatorInterface(ctx.bot, paginator, owner=ctx.author)
self.bot.loop.create_task(interface.send_to(ctx))
with ShellReader(argument.content) as reader:
async for line in reader:
if interface.closed:
return
await interface.add_line(line)
await interface.add_line(f"\n[status] Return code {reader.close_code}")