~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Martin Pool
  • Date: 2005-05-03 08:13:15 UTC
  • Revision ID: mbp@sourcefrog.net-20050503081315-0a34aa107691c392
- Clarify return codes from command objects

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
        This is invoked with the options and arguments bound to
156
156
        keyword parameters.
157
157
 
158
 
        Return True if the command was successful, False if not.
 
158
        Return 0 or None if the command was successful, or a shell
 
159
        error code if not.
159
160
        """
160
 
        return True
 
161
        return 0
161
162
 
162
163
 
163
164
 
979
980
            ## print_stats seems hardcoded to stdout
980
981
            stats.print_stats(20)
981
982
            
982
 
            return ret
 
983
            return ret.status
983
984
 
984
985
        finally:
985
986
            os.close(pffileno)
986
987
            os.remove(pfname)
987
988
    else:
988
 
        cmdobj = cmd_class(cmdopts, cmdargs) or 0
989
 
 
 
989
        cmdobj = cmd_class(cmdopts, cmdargs).status 
990
990
 
991
991
 
992
992
def _report_exception(e, summary, quiet=False):
1010
1010
 
1011
1011
    try:
1012
1012
        try:
1013
 
            ret = run_bzr(argv)
1014
 
            # do this here to catch EPIPE
1015
 
            sys.stdout.flush()
1016
 
            return ret
 
1013
            try:
 
1014
                return run_bzr(argv)
 
1015
            finally:
 
1016
                # do this here inside the exception wrappers to catch EPIPE
 
1017
                sys.stdout.flush()
1017
1018
        except BzrError, e:
1018
1019
            quiet = isinstance(e, (BzrCommandError))
1019
1020
            _report_exception(e, 'error: ' + e.args[0], quiet=quiet)