Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.tags = extra_args.pop('tags', list())
if 'jobname' in extra_args:
jobname = extra_args['jobname']
# Check whether the first character of a jobname is an
# integer. SGE does not allow job names to start with a
# number, so add a prefix...
if len(jobname) == 0:
gc3libs.log.warning("Empty string passed as jobname to %s", self)
jobname = "GC3Pie.%s.%s" % (self.__class__.__name__, id(self))
elif str(jobname)[0] in string.digits:
jobname = "GC3Pie.%s" % jobname
extra_args['jobname'] = jobname
# task setup; creates the `.execution` attribute as well
Task.__init__(self, **extra_args)
def detach(self):
"""
Remove any reference to the current grid interface. After
this, calling any method other than :meth:`attach` results in
an exception :class:`TaskDetachedFromGridError` being thrown.
"""
if self._attached:
self._attached = False
try:
self._controller.remove(self)
except:
pass
self._controller = Task.__no_controller
# number, so add a prefix...
if len(jobname) == 0:
gc3libs.log.warning(
"Empty string passed as jobname to %s,"
" generating UUID job name", self)
jobname = ("GC3Pie.%s.%s"
% (self.__class__.__name__, uuid.uuid4()))
elif str(jobname)[0] not in string.letters:
gc3libs.log.warning(
"Supplied job name `%s` for %s does not start"
" with a letter; changing it to `GC3Pie.%s`"
% (jobname, self, jobname))
jobname = "GC3Pie.%s" % jobname
extra_args['jobname'] = jobname
# task setup; creates the `.execution` attribute as well
Task.__init__(self, **extra_args)
the job has not been updated for a certain period of time
thus it is placed in UNKNOWN state.
Two possible ways of changing from this state:
1) next update cycle, job status is updated from the remote
server
2) derive this method for Application specific logic to deal
with this case
The default implementation does nothing, override in derived
classes to implement additional behavior.
"""
pass
class Application(Task):
"""
Support for running a generic application with the GC3Libs.
The following parameters are *required* to create an `Application`
instance:
`arguments`
List or sequence of program arguments. The program to execute is
the first one.; any object in the list will be converted to
string via Python's `str()`.
`inputs`
Files that will be copied to the remote execution node before
execution starts.
There are two possible ways of specifying the `inputs` parameter:
def detach(self):
"""
Remove any reference to the current grid interface. After
this, calling any method other than :meth:`attach` results in
an exception :class:`TaskDetachedFromGridError` being thrown.
"""
if self._attached:
self._attached = False
try:
self._controller.remove(self)
except:
pass
self._controller = Task.__no_controller
# https://bugzilla.redhat.com/show_bug.cgi?id=573782 )
# we need to disable `logging` reporting of exceptions.
try:
version_info = sys.version_info
except AttributeError:
version_info = (1, 5) # 1.5 or earlier
if version_info < (2, 5):
logging.raiseExceptions = False
# when used in the `output` attribute of an application,
# it stands for "fetch the whole contents of the remote
# directory"
ANY_OUTPUT = '*'
class Application(Task):
"""
Support for running a generic application with the GC3Libs.
The following parameters are *required* to create an `Application`
instance:
`arguments`
List or sequence of program arguments. The program to execute is
the first one.; any object in the list will be converted to
string via Python's `str()`.
`inputs`
Files that will be copied to the remote execution node before
execution starts.
There are two possible ways of specifying the `inputs` parameter: