mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-27 02:16:12 +01:00
Cleanup babysitter a bit
In case of an exception, return status code 1 by default.
This commit is contained in:
parent
6acc90d438
commit
d66ccb2a7d
@ -75,23 +75,18 @@ def run(prg, argv=None):
|
|||||||
raise
|
raise
|
||||||
except oscerr.SignalInterrupt:
|
except oscerr.SignalInterrupt:
|
||||||
print('killed!', file=sys.stderr)
|
print('killed!', file=sys.stderr)
|
||||||
return 1
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('interrupted!', file=sys.stderr)
|
print('interrupted!', file=sys.stderr)
|
||||||
return 130
|
return 130
|
||||||
except oscerr.UserAbort:
|
except oscerr.UserAbort:
|
||||||
print('aborted.', file=sys.stderr)
|
print('aborted.', file=sys.stderr)
|
||||||
return 1
|
|
||||||
except oscerr.APIError as e:
|
except oscerr.APIError as e:
|
||||||
print('BuildService API error:', e.msg, file=sys.stderr)
|
print('BuildService API error:', e.msg, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except oscerr.LinkExpandError as e:
|
except oscerr.LinkExpandError as e:
|
||||||
print('Link "%s/%s" cannot be expanded:\n' % (e.prj, e.pac), e.msg, file=sys.stderr)
|
print('Link "%s/%s" cannot be expanded:\n' % (e.prj, e.pac), e.msg, file=sys.stderr)
|
||||||
print('Use "osc repairlink" to fix merge conflicts.\n', file=sys.stderr)
|
print('Use "osc repairlink" to fix merge conflicts.\n', file=sys.stderr)
|
||||||
return 1
|
|
||||||
except oscerr.WorkingCopyWrongVersion as e:
|
except oscerr.WorkingCopyWrongVersion as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except oscerr.NoWorkingCopy as e:
|
except oscerr.NoWorkingCopy as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
if os.path.isdir('.git'):
|
if os.path.isdir('.git'):
|
||||||
@ -102,7 +97,6 @@ def run(prg, argv=None):
|
|||||||
print("Current directory looks like svn.", file=sys.stderr)
|
print("Current directory looks like svn.", file=sys.stderr)
|
||||||
if os.path.isdir('CVS'):
|
if os.path.isdir('CVS'):
|
||||||
print("Current directory looks like cvs.", file=sys.stderr)
|
print("Current directory looks like cvs.", file=sys.stderr)
|
||||||
return 1
|
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
print('Server returned an error:', e, file=sys.stderr)
|
print('Server returned an error:', e, file=sys.stderr)
|
||||||
if hasattr(e, 'osc_msg'):
|
if hasattr(e, 'osc_msg'):
|
||||||
@ -131,84 +125,63 @@ def run(prg, argv=None):
|
|||||||
if h != 'Set-Cookie':
|
if h != 'Set-Cookie':
|
||||||
print("%s: %s" % (h, v))
|
print("%s: %s" % (h, v))
|
||||||
|
|
||||||
return 1
|
|
||||||
except BadStatusLine as e:
|
except BadStatusLine as e:
|
||||||
print('Server returned an invalid response:', e, file=sys.stderr)
|
print('Server returned an invalid response:', e, file=sys.stderr)
|
||||||
print(e.line, file=sys.stderr)
|
print(e.line, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except URLError as e:
|
except URLError as e:
|
||||||
print('Failed to reach a server:\n', e.reason, file=sys.stderr)
|
print('Failed to reach a server:\n', e.reason, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except URLGrabError as e:
|
except URLGrabError as e:
|
||||||
print('Failed to grab %s: %s' % (e.url, e.strerror), file=sys.stderr)
|
print('Failed to grab %s: %s' % (e.url, e.strerror), file=sys.stderr)
|
||||||
return 1
|
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
# ignore broken pipe
|
# ignore broken pipe
|
||||||
if e.errno != errno.EPIPE:
|
if e.errno != errno.EPIPE:
|
||||||
raise
|
raise
|
||||||
return 1
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.errno != errno.ENOENT:
|
if e.errno != errno.ENOENT:
|
||||||
raise
|
raise
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except (oscerr.ConfigError, oscerr.NoConfigfile) as e:
|
except (oscerr.ConfigError, oscerr.NoConfigfile) as e:
|
||||||
print(e.msg, file=sys.stderr)
|
print(e.msg, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except oscerr.OscIOError as e:
|
except oscerr.OscIOError as e:
|
||||||
print(e.msg, file=sys.stderr)
|
print(e.msg, file=sys.stderr)
|
||||||
if getattr(prg.options, 'debug', None) or \
|
if getattr(prg.options, 'debug', None) or \
|
||||||
getattr(prg.conf, 'config', {}).get('debug', None):
|
getattr(prg.conf, 'config', {}).get('debug', None):
|
||||||
print(e.e, file=sys.stderr)
|
print(e.e, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except (oscerr.WrongOptions, oscerr.WrongArgs) as e:
|
except (oscerr.WrongOptions, oscerr.WrongArgs) as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
return 2
|
return 2
|
||||||
except oscerr.ExtRuntimeError as e:
|
except oscerr.ExtRuntimeError as e:
|
||||||
print(e.file + ':', e.msg, file=sys.stderr)
|
print(e.file + ':', e.msg, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except oscerr.ServiceRuntimeError as e:
|
except oscerr.ServiceRuntimeError as e:
|
||||||
print(e.msg, file=sys.stderr)
|
print(e.msg, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except oscerr.WorkingCopyOutdated as e:
|
except oscerr.WorkingCopyOutdated as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except (oscerr.PackageExists, oscerr.PackageMissing, oscerr.WorkingCopyInconsistent) as e:
|
except (oscerr.PackageExists, oscerr.PackageMissing, oscerr.WorkingCopyInconsistent) as e:
|
||||||
print(e.msg, file=sys.stderr)
|
print(e.msg, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except oscerr.PackageInternalError as e:
|
except oscerr.PackageInternalError as e:
|
||||||
print('a package internal error occured\n' \
|
print('a package internal error occured\n' \
|
||||||
'please file a bug and attach your current package working copy ' \
|
'please file a bug and attach your current package working copy ' \
|
||||||
'and the following traceback to it:', file=sys.stderr)
|
'and the following traceback to it:', file=sys.stderr)
|
||||||
print(e.msg, file=sys.stderr)
|
print(e.msg, file=sys.stderr)
|
||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
return 1
|
|
||||||
except oscerr.PackageError as e:
|
except oscerr.PackageError as e:
|
||||||
print(e.msg, file=sys.stderr)
|
print(e.msg, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except PackageError as e:
|
except PackageError as e:
|
||||||
print('%s:' % e.fname, e.msg, file=sys.stderr)
|
print('%s:' % e.fname, e.msg, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except RPMError as e:
|
except RPMError as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except SSLError as e:
|
except SSLError as e:
|
||||||
print("SSL Error:", e, file=sys.stderr)
|
print("SSL Error:", e, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except SSLVerificationError as e:
|
except SSLVerificationError as e:
|
||||||
print("Certificate Verification Error:", e, file=sys.stderr)
|
print("Certificate Verification Error:", e, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except NoSecureSSLError as e:
|
except NoSecureSSLError as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except CpioError as e:
|
except CpioError as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
return 1
|
|
||||||
except oscerr.OscBaseError as e:
|
except oscerr.OscBaseError as e:
|
||||||
print('*** Error:', e, file=sys.stderr)
|
print('*** Error:', e, file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# vim: sw=4 et
|
# vim: sw=4 et
|
||||||
|
Loading…
Reference in New Issue
Block a user