Error reporting in package_* functions
troeger opened this issue · comments
Some of the package providers (e.g. easy_install) do not return their run() / sudo() results to the caller, which makes it impossible for the fabfile.py to detect error conditions. The whole error reporting seems to be inconsistent across the available package managers at the moment.
Since some of them perform multiple calls to their according tools (e.g. apt-get and dpkg-query), it might be difficult to just return the last run() / sudo() result.
I would propose to make a custom data structure the default return type for package_* functions. This should be documented in the decorator description, and added where it is missing.
If needed, I can provide a patch for that.
This closing was accidentally, sorry. I am more a Bitbucket guy ;) ...
Ha! I moved most of my private projects to BitBucket and it is indeed quite good. Anyway, please go forward with ensuring the command return value is communicated.
The only thing is that the error reporting should be consistent throughout the different package managers, which would probably trigger quite a lot of work.
In terms of structure, a String subclass with isError
/isSuccess
would work well -- this would not break compatibility and still allow to disambiguate. It would also be usable in other places.
class Result(str):
def __init__(self,value):
str.__init__(self, value)
self.error = None
def isError( self ):
return self.error is not None
def isSuccess( self ):
return not self.isError()
Would you mind creating a pull request with all the changes?