Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement] Make the exception dump while invoking run() optional #78

Open
N0K0 opened this issue Sep 8, 2020 · 2 comments
Open

[Improvement] Make the exception dump while invoking run() optional #78

N0K0 opened this issue Sep 8, 2020 · 2 comments

Comments

@N0K0
Copy link

N0K0 commented Sep 8, 2020

Hi!

Been using Sultan for a little while now and i've found one part that should be improved.

from api.py -> cmd -> run()

       except Exception as e:
            result = Result(None, commands, self._context, exception=e)
            result.dump_exception()
            if halt_on_nonzero:
                raise e

The dump_exception() should be optional. At the moment i have three instances of Sultan running "inside" each other due to ssh chaining, and as you might understand, the stack dumb turns into a giant mess when a dump is invoked at layer 3 up to layer 1

@N0K0
Copy link
Author

N0K0 commented Sep 8, 2020

I can come with an PR if you want. Would you like an new parameter, or via the quite flag?

@N0K0
Copy link
Author

N0K0 commented Sep 8, 2020

Currently working my way around the dump with a monkey patch

def dump_exception_patch(self):
    if not self._exception:
        try:
            raise subprocess.CalledProcessError(
                self.rc, "".join(self._commands), self.stderr
            )
        except subprocess.CalledProcessError as e:
            self._exception = e

        # Removed all log dumping here

        if self._halt_on_nonzero:
            raise self._exception

Result.dump_exception = dump_exception_patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant