# Path: catkin_tools/commands/catkin.py
# def main(sysargs=None):
#     try:
#         catkin_main(sysargs)
#     except KeyboardInterrupt:
#         print('Interrupted by user!')


import functools
import os
import re
import shutil
import subprocess
import sys
import tempfile
            import traceback
from io import StringIO
from subprocess import TimeoutExpired
from catkin_tools.commands.catkin import main as catkin_main
            from inspect import getargspec
        self.out = StringIO()
        self.err = StringIO()
        sys.stdout = self.out
        sys.stderr = self.err
        return self.out, self.err

    def __exit__(self, exc_type, exc_value, traceback):
        sys.stdout = self.original_stdout
        sys.stderr = self.original_stderr

        print(self.out.getvalue())


class temporary_directory(object):

    def __init__(self, prefix=''):
        self.prefix = prefix
        self.delete = False

    def __enter__(self):
        self.original_cwd = os.getcwd()
        self.temp_path = tempfile.mkdtemp(prefix=self.prefix)
        os.chdir(self.temp_path)
        return self.temp_path

    def __exit__(self, exc_type, exc_value, traceback):
        if self.delete and self.temp_path and os.path.exists(self.temp_path):
            print('Deleting temporary testind directory: %s' % self.temp_path)
            shutil.rmtree(self.temp_path)
        if self.original_cwd and os.path.exists(self.original_cwd):

# Path: catkin_tools/commands/catkin.py
# def main(sysargs=None):
#     try:
#         catkin_main(sysargs)
#     except KeyboardInterrupt:
#         print('Interrupted by user!')


# Path: tests/utils.py
import functools
import os
import re
import shutil
import subprocess
import sys
import tempfile
            import traceback
from io import StringIO
from subprocess import TimeoutExpired
from catkin_tools.commands.catkin import main as catkin_main
            from inspect import getargspec

        self.out = StringIO()
        self.err = StringIO()
        sys.stdout = self.out
        sys.stderr = self.err
        return self.out, self.err

    def __exit__(self, exc_type, exc_value, traceback):
        sys.stdout = self.original_stdout
        sys.stderr = self.original_stderr

        print(self.out.getvalue())


class temporary_directory(object):

    def __init__(self, prefix=''):
        self.prefix = prefix
        self.delete = False

    def __enter__(self):
        self.original_cwd = os.getcwd()
        self.temp_path = tempfile.mkdtemp(prefix=self.prefix)
        os.chdir(self.temp_path)
        return self.temp_path

    def __exit__(self, exc_type, exc_value, traceback):
        if self.delete and self.temp_path and os.path.exists(self.temp_path):
            print('Deleting temporary testind directory: %s' % self.temp_path)
            shutil.rmtree(self.temp_path)
        if self.original_cwd and os.path.exists(self.original_cwd):

            os.chdir(self.original_cwd)