Skip to content

Instantly share code, notes, and snippets.

@10se1ucgo
Last active March 27, 2016 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 10se1ucgo/6320a002af3a8410a3b5 to your computer and use it in GitHub Desktop.
Save 10se1ucgo/6320a002af3a8410a3b5 to your computer and use it in GitHub Desktop.
Put in your scripts folder and add to your scripts list. (if you're an idiot)
"""
Please don't use this.
Creator: 10se1ucgo
"""
import sys
from StringIO import StringIO
from commands import alias, name, admin, add
class ExecRedirect(object):
def __enter__(self):
self.old_stdout = sys.stdout
sys.stdout = StringIO()
return sys.stdout
def __exit__(self, type, value, traceback):
sys.stdout = self.old_stdout
@alias('py_run')
@name('idiot')
@admin
def exec_command(connection, *args):
cmd = ' '.join(args)
with ExecRedirect() as redirect:
exec(cmd)
return redirect.getvalue()
add(exec_command)
def apply_script(protocol, connection, config):
return protocol, connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment