ecsjobs.jobs.local_command module¶
-
class
ecsjobs.jobs.local_command.LocalCommand(name, schedule, summary_regex=None, cron_expression=None, command=None, shell=False, timeout=None, script_source=None)[source]¶ Bases:
ecsjobs.jobs.base.JobJob class to run a local command via
subprocess.run(). Theoutputproperty of this class contains combined STDOUT and STDERR.Parameters: - name (str) – unique name for this job
- schedule (str) – the name of the schedule this job runs on
- summary_regex (
stringorNone) – A regular expression to use for extracting a string from the job output for use in the summary table. If there is more than one match, the last one will be used. - cron_expression (str) – A cron-like expression parsable by cronex specifying when the job should run. This has the effect of causing runs to skip this job unless the expression matches. It’s recommended not to use any minute specifiers and not to use any hour specifiers if the total runtime of all jobs is more than an hour.
- command (
strorlist) – The command to execute as either a String or a List of Strings, as used bysubprocess.run(). Ifscript_sourceis specified and this parameter is not an empty string or empty list, it will be passed as arguments to the downloaded script. - shell (bool) – Whether or not to execute the provided command through the
shell. Corresponds to the
shellargument ofsubprocess.run(). - timeout (int) – An integer number of seconds to allow the command to
run. Cooresponds to the
timeoutargument ofsubprocess.run(). - script_source (str) – A URL to retrieve an executable script from, in
place of
command. This currently supports URLs withhttp://,https://ors3://schemes. HTTP and HTTPS URLs must be directly retrievable without any authentication. S3 URLs will use the same credentials already in use for the session. Note that this setting will cause ecsjobs to download and execute code from a potentially untrusted location.
-
_get_script(script_url)[source]¶ Download a script from HTTP/HTTPS or S3 to a temporary path, make it executable, and return the command to execute.
Parameters: script_url (str) – URL to download - HTTP/HTTPS or S3 Returns: path to the downloaded executable script if self._commandis an empty string, empty array, or None. Otherwise, a list whose first element is the path to the downloaded executable script, and then containsself._command.Return type: str
-
_schema_dict= {'properties': {'command': {'oneOf': [{'type': 'string'}, {'type': 'array', 'items': [{'type': 'string'}]}]}, 'script_source': {'format': 'url', 'pattern': '^(s3|http|https)://.*$', 'type': 'string'}, 'shell': {'type': 'boolean'}, 'timeout': {'oneOf': [{'type': 'integer'}, {'type': 'null'}]}}, 'type': 'object'}¶ Dictionary describing the configuration file schema, to be validated with jsonschema.