Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __getitem__(self, signal_num):
if signal_num == 120:
return _Signals.Lost
elif signal_num == 121:
return _Signals.Cancelled
elif signal_num == 122:
return _Signals.RemoteKill
elif signal_num == 123:
return _Signals.DataStagingFailure
elif signal_num == 124:
return _Signals.RemoteError
elif signal_num == 125:
return _Signals.SubmissionFailed
else:
raise gc3libs.exceptions.InvalidArgument(
"Unknown signal number %d" % signal_num)
def __getitem__(self, signal_num):
if signal_num == 120:
return _Signals.Lost
elif signal_num == 121:
return _Signals.Cancelled
elif signal_num == 122:
return _Signals.RemoteKill
elif signal_num == 123:
return _Signals.DataStagingFailure
elif signal_num == 124:
return _Signals.RemoteError
elif signal_num == 125:
return _Signals.SubmissionFailed
else:
raise gc3libs.exceptions.InvalidArgument(
"Unknown signal number %d" % signal_num)
self.exitcode = None
else:
try:
# `value` can be a tuple `(signal, exitcode)`
self.signal = int(value[0])
self.exitcode = int(value[1])
except (TypeError, ValueError):
self.exitcode = (int(value) >> 8) & 0xff
self.signal = int(value) & 0x7f
# ensure values are within allowed range
self.exitcode &= 0xff
self.signal &= 0x7f
return (locals())
# `Run.Signals` is an instance of global class `_Signals`
Signals = _Signals()
@staticmethod
def shellexit_to_returncode(rc):
"""
Convert a shell exit code to a POSIX process return code.
A POSIX shell represents the return code of the last-run
program within its exit code as follows:
* If the program was terminated by signal `N`, the shell exits
with code 128+N,
* otherwise, if the program terminated with exit code C, the
shell exits with code C.
"""
def __getitem__(self, signal_num):
if signal_num == 120:
return _Signals.Lost
elif signal_num == 121:
return _Signals.Cancelled
elif signal_num == 122:
return _Signals.RemoteKill
elif signal_num == 123:
return _Signals.DataStagingFailure
elif signal_num == 124:
return _Signals.RemoteError
elif signal_num == 125:
return _Signals.SubmissionFailed
else:
raise gc3libs.exceptions.InvalidArgument(
"Unknown signal number %d" % signal_num)
def __getitem__(self, signal_num):
if signal_num == 120:
return _Signals.Lost
elif signal_num == 121:
return _Signals.Cancelled
elif signal_num == 122:
return _Signals.RemoteKill
elif signal_num == 123:
return _Signals.DataStagingFailure
elif signal_num == 124:
return _Signals.RemoteError
elif signal_num == 125:
return _Signals.SubmissionFailed
else:
raise gc3libs.exceptions.InvalidArgument(
"Unknown signal number %d" % signal_num)
def __getitem__(self, signal_num):
if signal_num == 120:
return _Signals.Lost
elif signal_num == 121:
return _Signals.Cancelled
elif signal_num == 122:
return _Signals.RemoteKill
elif signal_num == 123:
return _Signals.DataStagingFailure
elif signal_num == 124:
return _Signals.RemoteError
elif signal_num == 125:
return _Signals.SubmissionFailed
else:
raise gc3libs.exceptions.InvalidArgument(
"Unknown signal number %d" % signal_num)
if value is None:
self.signal = None
self.exitcode = None
else:
try:
# `value` can be a tuple `(signal, exitcode)`;
# ensure values are within allowed range
self.signal = int(value[0]) & 0x7f
self.exitcode = int(value[1]) & 0xff
except (TypeError, ValueError):
self.exitcode = (int(value) >> 8) & 0xff
self.signal = int(value) & 0x7f
return (locals())
# `Run.Signals` is an instance of global class `_Signals`
Signals = _Signals()
@staticmethod
def shellexit_to_returncode(rc):
"""
Convert a shell exit code to a POSIX process return code.
A POSIX shell represents the return code of the last-run
program within its exit code as follows:
* If the program was terminated by signal `N`, the shell exits
with code 128+N,
* otherwise, if the program terminated with exit code C, the
shell exits with code C.
"""
# only the less significant 8 bits matter
def __getitem__(self, signal_num):
if signal_num == 120:
return _Signals.Lost
elif signal_num == 121:
return _Signals.Cancelled
elif signal_num == 122:
return _Signals.RemoteKill
elif signal_num == 123:
return _Signals.DataStagingFailure
elif signal_num == 124:
return _Signals.RemoteError
elif signal_num == 125:
return _Signals.SubmissionFailed
else:
raise gc3libs.exceptions.InvalidArgument(
"Unknown signal number %d" % signal_num)