Output and Running

Output contents

Use the self.output to print contents to the output.

self.output.success("This is a good, should be green")
self.output.info("This is a neutral, should be white")
self.output.warn("This is a warning, should be yellow")
self.output.error("Error, should be red")
self.output.rewrite_line("for progress bars, issues a cr")

Check the source code. You might be able to produce different outputs with different colors.

Running commands

run(self, command, output=True, cwd=None, win_bash=False, subsystem=None, msys_mingw=True):

self.run() is a helper to run system commands and throw exceptions when errors occur, so that command errors are do not pass unnoticed. It is just a wrapper for os.system()

Optional parameters:

  • output (Optional, Defaulted to True) When True it will write in stdout.

    You can pass any stream that accepts a write method like a six.StringIO():

from six import StringIO  # Python 2 and 3 compatible
mybuf = StringIO()
self.run("mycommand", output=mybuf)
  • cwd (Optional, Defaulted to . current directory): Current directory to run the command.

  • win_bash (Optional, Defaulted to False): When True, it will run the configure/make commands inside a bash.

  • subsystem (Optional, Defaulted to None will autodetect the subsystem). Used to escape the command according to the specified subsystem.

  • msys_mingw (Optional, Defaulted to True) If the specified subsystem is MSYS2, will start it in MinGW mode (native windows development).