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

Feature Request: Version of LongRunning that returns TaskError on non zero return code? #453

Open
eddieparker opened this issue May 2, 2023 · 2 comments

Comments

@eddieparker
Copy link

eddieparker commented May 2, 2023

I'd love if there was a version of doit.tools.LongRunning that had it return TaskError if return code was non zero. I tend to use this for a light build system for tasks that have dependencies, and having it not stop at the first error requires a bunch of scrolling and buries problems.

I tend to unroll it in my own dodo.py scripts, but it'd be nice if it was inbuilt. I ended up hacking my own locally in my dodo.py and it works quite nicely:

class LongRunningTask(doit.tools.CmdAction):
	' Run a command and wait for it to finish, and fail if it fails.'

	def execute(self, out=None, err=None):
		action = self.expand_action()
		process = subprocess.Popen(
			action, shell=self.shell, stdout=out, stderr=err, **self.pkwargs,)
		try:
			return_value = process.wait()
		
			if return_value != 0:
				return doit.exceptions.TaskError(f'Command failed with return code {return_value}')

		except KeyboardInterrupt:
			# normal way to stop interactive process
			pass
Fund with Polar
@schettino72
Copy link
Member

The "Interactive" checks the return code. does that work for you?

The problem of having too many features/API is that people dont find them!
So providing the building blocks to allow users to code their own solution is a good compromise.
So I would tend to reject this...

@eddieparker
Copy link
Author

I can respect having too many features/API - a big surface area means a lot more to maintain. :)

Interactive is close to what I want, but it doesn't capture output, unfortunately.

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

2 participants