Better messages and return codes in applications

Use stderr and return codes >0 when it makes sense.
Loose return code conventions:
* 1 for generic errors
* 2 for user input errors
* 3 for remote errors (not found, etc.)
* 4 for not implemented
This commit is contained in:
Laurent Bachelier 2011-05-03 01:02:00 +02:00
commit 8075d538f0
18 changed files with 168 additions and 149 deletions

View file

@ -133,7 +133,7 @@ class HaveSex(ReplApplication):
def edit_optims(self, backend_names, optims_names, stop=False):
if optims_names is None:
print >>sys.stderr, 'Error: missing parameters.'
return 1
return 2
for optim_name in optims_names.split():
backends_optims = {}
@ -165,7 +165,7 @@ class HaveSex(ReplApplication):
def optims(self, function, backend_names, optims, store=True):
if optims is None:
print >>sys.stderr, 'Error: missing parameters.'
return 1
return 2
for optim_name in optims.split():
try:
@ -211,8 +211,6 @@ class HaveSex(ReplApplication):
if store:
self.storage.save()
return 0
def complete_optim(self, text, line, *ignored):
args = line.split(' ')
if len(args) == 2: