repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
mozilla-releng/scriptworker
scriptworker/task.py
get_pull_request_number
def get_pull_request_number(task, source_env_prefix): """Get what Github pull request created the graph. Args: obj (ChainOfTrust or LinkOfTrust): the trust object to inspect source_env_prefix (str): The environment variable prefix that is used to get repository information. Ret...
python
def get_pull_request_number(task, source_env_prefix): """Get what Github pull request created the graph. Args: obj (ChainOfTrust or LinkOfTrust): the trust object to inspect source_env_prefix (str): The environment variable prefix that is used to get repository information. Ret...
[ "def", "get_pull_request_number", "(", "task", ",", "source_env_prefix", ")", ":", "pull_request", "=", "_extract_from_env_in_payload", "(", "task", ",", "source_env_prefix", "+", "'_PULL_REQUEST_NUMBER'", ")", "if", "pull_request", "is", "not", "None", ":", "pull_req...
Get what Github pull request created the graph. Args: obj (ChainOfTrust or LinkOfTrust): the trust object to inspect source_env_prefix (str): The environment variable prefix that is used to get repository information. Returns: int: the pull request number. None: if ...
[ "Get", "what", "Github", "pull", "request", "created", "the", "graph", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L219-L235
train
28,000
mozilla-releng/scriptworker
scriptworker/task.py
get_and_check_project
def get_and_check_project(valid_vcs_rules, source_url): """Given vcs rules and a source_url, return the project. The project is in the path, but is the repo name. `releases/mozilla-beta` is the path; `mozilla-beta` is the project. Args: valid_vcs_rules (tuple of frozendicts): the valid vcs rul...
python
def get_and_check_project(valid_vcs_rules, source_url): """Given vcs rules and a source_url, return the project. The project is in the path, but is the repo name. `releases/mozilla-beta` is the path; `mozilla-beta` is the project. Args: valid_vcs_rules (tuple of frozendicts): the valid vcs rul...
[ "def", "get_and_check_project", "(", "valid_vcs_rules", ",", "source_url", ")", ":", "project_path", "=", "match_url_regex", "(", "valid_vcs_rules", ",", "source_url", ",", "match_url_path_callback", ")", "if", "project_path", "is", "None", ":", "raise", "ValueError",...
Given vcs rules and a source_url, return the project. The project is in the path, but is the repo name. `releases/mozilla-beta` is the path; `mozilla-beta` is the project. Args: valid_vcs_rules (tuple of frozendicts): the valid vcs rules, per ``match_url_regex``. source_url (st...
[ "Given", "vcs", "rules", "and", "a", "source_url", "return", "the", "project", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L278-L300
train
28,001
mozilla-releng/scriptworker
scriptworker/task.py
get_and_check_tasks_for
def get_and_check_tasks_for(context, task, msg_prefix=''): """Given a parent task, return the reason the parent task was spawned. ``.taskcluster.yml`` uses this to know whether to spawn an action, cron, or decision task definition. ``tasks_for`` must be a valid one defined in the context. Args: ...
python
def get_and_check_tasks_for(context, task, msg_prefix=''): """Given a parent task, return the reason the parent task was spawned. ``.taskcluster.yml`` uses this to know whether to spawn an action, cron, or decision task definition. ``tasks_for`` must be a valid one defined in the context. Args: ...
[ "def", "get_and_check_tasks_for", "(", "context", ",", "task", ",", "msg_prefix", "=", "''", ")", ":", "tasks_for", "=", "task", "[", "'extra'", "]", "[", "'tasks_for'", "]", "if", "tasks_for", "not", "in", "context", ".", "config", "[", "'valid_tasks_for'",...
Given a parent task, return the reason the parent task was spawned. ``.taskcluster.yml`` uses this to know whether to spawn an action, cron, or decision task definition. ``tasks_for`` must be a valid one defined in the context. Args: task (dict): the task definition. msg_prefix (str): the...
[ "Given", "a", "parent", "task", "return", "the", "reason", "the", "parent", "task", "was", "spawned", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L304-L326
train
28,002
mozilla-releng/scriptworker
scriptworker/task.py
get_repo_scope
def get_repo_scope(task, name): """Given a parent task, return the repo scope for the task. Background in https://bugzilla.mozilla.org/show_bug.cgi?id=1459705#c3 Args: task (dict): the task definition. Raises: ValueError: on too many `repo_scope`s (we allow for 1 or 0). Returns: ...
python
def get_repo_scope(task, name): """Given a parent task, return the repo scope for the task. Background in https://bugzilla.mozilla.org/show_bug.cgi?id=1459705#c3 Args: task (dict): the task definition. Raises: ValueError: on too many `repo_scope`s (we allow for 1 or 0). Returns: ...
[ "def", "get_repo_scope", "(", "task", ",", "name", ")", ":", "repo_scopes", "=", "[", "]", "for", "scope", "in", "task", "[", "'scopes'", "]", ":", "if", "REPO_SCOPE_REGEX", ".", "match", "(", "scope", ")", ":", "repo_scopes", ".", "append", "(", "scop...
Given a parent task, return the repo scope for the task. Background in https://bugzilla.mozilla.org/show_bug.cgi?id=1459705#c3 Args: task (dict): the task definition. Raises: ValueError: on too many `repo_scope`s (we allow for 1 or 0). Returns: str: the ``repo_scope`` ...
[ "Given", "a", "parent", "task", "return", "the", "repo", "scope", "for", "the", "task", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L330-L355
train
28,003
mozilla-releng/scriptworker
scriptworker/task.py
is_github_task
def is_github_task(task): """Determine if a task is related to GitHub. This function currently looks into the ``schedulerId``, ``extra.tasks_for``, and ``metadata.source``. Args: task (dict): the task definition to check. Returns: bool: True if a piece of data refers to GitHub ...
python
def is_github_task(task): """Determine if a task is related to GitHub. This function currently looks into the ``schedulerId``, ``extra.tasks_for``, and ``metadata.source``. Args: task (dict): the task definition to check. Returns: bool: True if a piece of data refers to GitHub ...
[ "def", "is_github_task", "(", "task", ")", ":", "return", "any", "(", "(", "# XXX Cron tasks don't usually define 'taskcluster-github' as their schedulerId as they", "# are scheduled within another Taskcluster task.", "task", ".", "get", "(", "'schedulerId'", ")", "==", "'taskc...
Determine if a task is related to GitHub. This function currently looks into the ``schedulerId``, ``extra.tasks_for``, and ``metadata.source``. Args: task (dict): the task definition to check. Returns: bool: True if a piece of data refers to GitHub
[ "Determine", "if", "a", "task", "is", "related", "to", "GitHub", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L466-L486
train
28,004
mozilla-releng/scriptworker
scriptworker/task.py
is_action
def is_action(task): """Determine if a task is an action task. Trusted decision and action tasks are important in that they can generate other valid tasks. The verification of decision and action tasks is slightly different, so we need to be able to tell them apart. This checks for the following t...
python
def is_action(task): """Determine if a task is an action task. Trusted decision and action tasks are important in that they can generate other valid tasks. The verification of decision and action tasks is slightly different, so we need to be able to tell them apart. This checks for the following t...
[ "def", "is_action", "(", "task", ")", ":", "result", "=", "False", "if", "_extract_from_env_in_payload", "(", "task", ",", "'ACTION_CALLBACK'", ")", ":", "result", "=", "True", "if", "task", ".", "get", "(", "'extra'", ",", "{", "}", ")", ".", "get", "...
Determine if a task is an action task. Trusted decision and action tasks are important in that they can generate other valid tasks. The verification of decision and action tasks is slightly different, so we need to be able to tell them apart. This checks for the following things:: * ``task.pa...
[ "Determine", "if", "a", "task", "is", "an", "action", "task", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L490-L514
train
28,005
mozilla-releng/scriptworker
scriptworker/task.py
prepare_to_run_task
def prepare_to_run_task(context, claim_task): """Given a `claim_task` json dict, prepare the `context` and `work_dir`. Set `context.claim_task`, and write a `work_dir/current_task_info.json` Args: context (scriptworker.context.Context): the scriptworker context. claim_task (dict): the clai...
python
def prepare_to_run_task(context, claim_task): """Given a `claim_task` json dict, prepare the `context` and `work_dir`. Set `context.claim_task`, and write a `work_dir/current_task_info.json` Args: context (scriptworker.context.Context): the scriptworker context. claim_task (dict): the clai...
[ "def", "prepare_to_run_task", "(", "context", ",", "claim_task", ")", ":", "current_task_info", "=", "{", "}", "context", ".", "claim_task", "=", "claim_task", "current_task_info", "[", "'taskId'", "]", "=", "get_task_id", "(", "claim_task", ")", "current_task_inf...
Given a `claim_task` json dict, prepare the `context` and `work_dir`. Set `context.claim_task`, and write a `work_dir/current_task_info.json` Args: context (scriptworker.context.Context): the scriptworker context. claim_task (dict): the claim_task dict. Returns: dict: the contents...
[ "Given", "a", "claim_task", "json", "dict", "prepare", "the", "context", "and", "work_dir", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L518-L542
train
28,006
mozilla-releng/scriptworker
scriptworker/task.py
run_task
async def run_task(context, to_cancellable_process): """Run the task, sending stdout+stderr to files. https://github.com/python/asyncio/blob/master/examples/subprocess_shell.py Args: context (scriptworker.context.Context): the scriptworker context. to_cancellable_process (types.Callable): ...
python
async def run_task(context, to_cancellable_process): """Run the task, sending stdout+stderr to files. https://github.com/python/asyncio/blob/master/examples/subprocess_shell.py Args: context (scriptworker.context.Context): the scriptworker context. to_cancellable_process (types.Callable): ...
[ "async", "def", "run_task", "(", "context", ",", "to_cancellable_process", ")", ":", "kwargs", "=", "{", "# pragma: no branch", "'stdout'", ":", "PIPE", ",", "'stderr'", ":", "PIPE", ",", "'stdin'", ":", "None", ",", "'close_fds'", ":", "True", ",", "'preexe...
Run the task, sending stdout+stderr to files. https://github.com/python/asyncio/blob/master/examples/subprocess_shell.py Args: context (scriptworker.context.Context): the scriptworker context. to_cancellable_process (types.Callable): tracks the process so that it can be stopped if the worker i...
[ "Run", "the", "task", "sending", "stdout", "+", "stderr", "to", "files", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L546-L606
train
28,007
mozilla-releng/scriptworker
scriptworker/task.py
reclaim_task
async def reclaim_task(context, task): """Try to reclaim a task from the queue. This is a keepalive / heartbeat. Without it the job will expire and potentially be re-queued. Since this is run async from the task, the task may complete before we run, in which case we'll get a 409 the next time we ...
python
async def reclaim_task(context, task): """Try to reclaim a task from the queue. This is a keepalive / heartbeat. Without it the job will expire and potentially be re-queued. Since this is run async from the task, the task may complete before we run, in which case we'll get a 409 the next time we ...
[ "async", "def", "reclaim_task", "(", "context", ",", "task", ")", ":", "while", "True", ":", "log", ".", "debug", "(", "\"waiting %s seconds before reclaiming...\"", "%", "context", ".", "config", "[", "'reclaim_interval'", "]", ")", "await", "asyncio", ".", "...
Try to reclaim a task from the queue. This is a keepalive / heartbeat. Without it the job will expire and potentially be re-queued. Since this is run async from the task, the task may complete before we run, in which case we'll get a 409 the next time we reclaim. Args: context (scriptwor...
[ "Try", "to", "reclaim", "a", "task", "from", "the", "queue", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L610-L650
train
28,008
mozilla-releng/scriptworker
scriptworker/task.py
complete_task
async def complete_task(context, result): """Mark the task as completed in the queue. Decide whether to call reportCompleted, reportFailed, or reportException based on the exit status of the script. If the task has expired or been cancelled, we'll get a 409 status. Args: context (scriptwo...
python
async def complete_task(context, result): """Mark the task as completed in the queue. Decide whether to call reportCompleted, reportFailed, or reportException based on the exit status of the script. If the task has expired or been cancelled, we'll get a 409 status. Args: context (scriptwo...
[ "async", "def", "complete_task", "(", "context", ",", "result", ")", ":", "args", "=", "[", "get_task_id", "(", "context", ".", "claim_task", ")", ",", "get_run_id", "(", "context", ".", "claim_task", ")", "]", "reversed_statuses", "=", "get_reversed_statuses"...
Mark the task as completed in the queue. Decide whether to call reportCompleted, reportFailed, or reportException based on the exit status of the script. If the task has expired or been cancelled, we'll get a 409 status. Args: context (scriptworker.context.Context): the scriptworker context. ...
[ "Mark", "the", "task", "as", "completed", "in", "the", "queue", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L654-L688
train
28,009
mozilla-releng/scriptworker
scriptworker/task.py
claim_work
async def claim_work(context): """Find and claim the next pending task in the queue, if any. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict: a dict containing a list of the task definitions of the tasks claimed. """ log.debug("Calling claimWo...
python
async def claim_work(context): """Find and claim the next pending task in the queue, if any. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict: a dict containing a list of the task definitions of the tasks claimed. """ log.debug("Calling claimWo...
[ "async", "def", "claim_work", "(", "context", ")", ":", "log", ".", "debug", "(", "\"Calling claimWork...\"", ")", "payload", "=", "{", "'workerGroup'", ":", "context", ".", "config", "[", "'worker_group'", "]", ",", "'workerId'", ":", "context", ".", "confi...
Find and claim the next pending task in the queue, if any. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict: a dict containing a list of the task definitions of the tasks claimed.
[ "Find", "and", "claim", "the", "next", "pending", "task", "in", "the", "queue", "if", "any", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/task.py#L692-L717
train
28,010
mozilla-releng/scriptworker
scriptworker/cot/verify.py
raise_on_errors
def raise_on_errors(errors, level=logging.CRITICAL): """Raise a CoTError if errors. Helper function because I had this code block everywhere. Args: errors (list): the error errors level (int, optional): the log level to use. Defaults to logging.CRITICAL Raises: CoTError: if e...
python
def raise_on_errors(errors, level=logging.CRITICAL): """Raise a CoTError if errors. Helper function because I had this code block everywhere. Args: errors (list): the error errors level (int, optional): the log level to use. Defaults to logging.CRITICAL Raises: CoTError: if e...
[ "def", "raise_on_errors", "(", "errors", ",", "level", "=", "logging", ".", "CRITICAL", ")", ":", "if", "errors", ":", "log", ".", "log", "(", "level", ",", "\"\\n\"", ".", "join", "(", "errors", ")", ")", "raise", "CoTError", "(", "\"\\n\"", ".", "j...
Raise a CoTError if errors. Helper function because I had this code block everywhere. Args: errors (list): the error errors level (int, optional): the log level to use. Defaults to logging.CRITICAL Raises: CoTError: if errors is non-empty
[ "Raise", "a", "CoTError", "if", "errors", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L286-L301
train
28,011
mozilla-releng/scriptworker
scriptworker/cot/verify.py
guess_task_type
def guess_task_type(name, task_defn): """Guess the task type of the task. Args: name (str): the name of the task. Returns: str: the task_type. Raises: CoTError: on invalid task_type. """ parts = name.split(':') task_type = parts[-1] if task_type == 'parent': ...
python
def guess_task_type(name, task_defn): """Guess the task type of the task. Args: name (str): the name of the task. Returns: str: the task_type. Raises: CoTError: on invalid task_type. """ parts = name.split(':') task_type = parts[-1] if task_type == 'parent': ...
[ "def", "guess_task_type", "(", "name", ",", "task_defn", ")", ":", "parts", "=", "name", ".", "split", "(", "':'", ")", "task_type", "=", "parts", "[", "-", "1", "]", "if", "task_type", "==", "'parent'", ":", "if", "is_action", "(", "task_defn", ")", ...
Guess the task type of the task. Args: name (str): the name of the task. Returns: str: the task_type. Raises: CoTError: on invalid task_type.
[ "Guess", "the", "task", "type", "of", "the", "task", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L375-L399
train
28,012
mozilla-releng/scriptworker
scriptworker/cot/verify.py
check_interactive_docker_worker
def check_interactive_docker_worker(link): """Given a task, make sure the task was not defined as interactive. * ``task.payload.features.interactive`` must be absent or False. * ``task.payload.env.TASKCLUSTER_INTERACTIVE`` must be absent or False. Args: link (LinkOfTrust): the task link we're ...
python
def check_interactive_docker_worker(link): """Given a task, make sure the task was not defined as interactive. * ``task.payload.features.interactive`` must be absent or False. * ``task.payload.env.TASKCLUSTER_INTERACTIVE`` must be absent or False. Args: link (LinkOfTrust): the task link we're ...
[ "def", "check_interactive_docker_worker", "(", "link", ")", ":", "errors", "=", "[", "]", "log", ".", "info", "(", "\"Checking for {} {} interactive docker-worker\"", ".", "format", "(", "link", ".", "name", ",", "link", ".", "task_id", ")", ")", "try", ":", ...
Given a task, make sure the task was not defined as interactive. * ``task.payload.features.interactive`` must be absent or False. * ``task.payload.env.TASKCLUSTER_INTERACTIVE`` must be absent or False. Args: link (LinkOfTrust): the task link we're checking. Returns: list: the list of ...
[ "Given", "a", "task", "make", "sure", "the", "task", "was", "not", "defined", "as", "interactive", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L432-L454
train
28,013
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_docker_image_sha
def verify_docker_image_sha(chain, link): """Verify that built docker shas match the artifact. Args: chain (ChainOfTrust): the chain we're operating on. link (LinkOfTrust): the task link we're checking. Raises: CoTError: on failure. """ cot = link.cot task = link.task ...
python
def verify_docker_image_sha(chain, link): """Verify that built docker shas match the artifact. Args: chain (ChainOfTrust): the chain we're operating on. link (LinkOfTrust): the task link we're checking. Raises: CoTError: on failure. """ cot = link.cot task = link.task ...
[ "def", "verify_docker_image_sha", "(", "chain", ",", "link", ")", ":", "cot", "=", "link", ".", "cot", "task", "=", "link", ".", "task", "errors", "=", "[", "]", "if", "isinstance", "(", "task", "[", "'payload'", "]", ".", "get", "(", "'image'", ")",...
Verify that built docker shas match the artifact. Args: chain (ChainOfTrust): the chain we're operating on. link (LinkOfTrust): the task link we're checking. Raises: CoTError: on failure.
[ "Verify", "that", "built", "docker", "shas", "match", "the", "artifact", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L458-L511
train
28,014
mozilla-releng/scriptworker
scriptworker/cot/verify.py
find_sorted_task_dependencies
def find_sorted_task_dependencies(task, task_name, task_id): """Find the taskIds of the chain of trust dependencies of a given task. Args: task (dict): the task definition to inspect. task_name (str): the name of the task, for logging and naming children. task_id (str): the taskId of th...
python
def find_sorted_task_dependencies(task, task_name, task_id): """Find the taskIds of the chain of trust dependencies of a given task. Args: task (dict): the task definition to inspect. task_name (str): the name of the task, for logging and naming children. task_id (str): the taskId of th...
[ "def", "find_sorted_task_dependencies", "(", "task", ",", "task_name", ",", "task_id", ")", ":", "log", ".", "info", "(", "\"find_sorted_task_dependencies {} {}\"", ".", "format", "(", "task_name", ",", "task_id", ")", ")", "cot_input_dependencies", "=", "[", "_cr...
Find the taskIds of the chain of trust dependencies of a given task. Args: task (dict): the task definition to inspect. task_name (str): the name of the task, for logging and naming children. task_id (str): the taskId of the task. Returns: list: tuples associating dependent tas...
[ "Find", "the", "taskIds", "of", "the", "chain", "of", "trust", "dependencies", "of", "a", "given", "task", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L515-L550
train
28,015
mozilla-releng/scriptworker
scriptworker/cot/verify.py
build_task_dependencies
async def build_task_dependencies(chain, task, name, my_task_id): """Recursively build the task dependencies of a task. Args: chain (ChainOfTrust): the chain of trust to add to. task (dict): the task definition to operate on. name (str): the name of the task to operate on. my_ta...
python
async def build_task_dependencies(chain, task, name, my_task_id): """Recursively build the task dependencies of a task. Args: chain (ChainOfTrust): the chain of trust to add to. task (dict): the task definition to operate on. name (str): the name of the task to operate on. my_ta...
[ "async", "def", "build_task_dependencies", "(", "chain", ",", "task", ",", "name", ",", "my_task_id", ")", ":", "log", ".", "info", "(", "\"build_task_dependencies {} {}\"", ".", "format", "(", "name", ",", "my_task_id", ")", ")", "if", "name", ".", "count",...
Recursively build the task dependencies of a task. Args: chain (ChainOfTrust): the chain of trust to add to. task (dict): the task definition to operate on. name (str): the name of the task to operate on. my_task_id (str): the taskId of the task to operate on. Raises: C...
[ "Recursively", "build", "the", "task", "dependencies", "of", "a", "task", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L562-L594
train
28,016
mozilla-releng/scriptworker
scriptworker/cot/verify.py
download_cot
async def download_cot(chain): """Download the signed chain of trust artifacts. Args: chain (ChainOfTrust): the chain of trust to add to. Raises: BaseDownloadError: on failure. """ artifact_tasks = [] # only deal with chain.links, which are previously finished tasks with #...
python
async def download_cot(chain): """Download the signed chain of trust artifacts. Args: chain (ChainOfTrust): the chain of trust to add to. Raises: BaseDownloadError: on failure. """ artifact_tasks = [] # only deal with chain.links, which are previously finished tasks with #...
[ "async", "def", "download_cot", "(", "chain", ")", ":", "artifact_tasks", "=", "[", "]", "# only deal with chain.links, which are previously finished tasks with", "# signed chain of trust artifacts. ``chain.task`` is the current running", "# task, and will not have a signed chain of trust...
Download the signed chain of trust artifacts. Args: chain (ChainOfTrust): the chain of trust to add to. Raises: BaseDownloadError: on failure.
[ "Download", "the", "signed", "chain", "of", "trust", "artifacts", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L598-L637
train
28,017
mozilla-releng/scriptworker
scriptworker/cot/verify.py
download_cot_artifact
async def download_cot_artifact(chain, task_id, path): """Download an artifact and verify its SHA against the chain of trust. Args: chain (ChainOfTrust): the chain of trust object task_id (str): the task ID to download from path (str): the relative path to the artifact to download ...
python
async def download_cot_artifact(chain, task_id, path): """Download an artifact and verify its SHA against the chain of trust. Args: chain (ChainOfTrust): the chain of trust object task_id (str): the task ID to download from path (str): the relative path to the artifact to download ...
[ "async", "def", "download_cot_artifact", "(", "chain", ",", "task_id", ",", "path", ")", ":", "link", "=", "chain", ".", "get_link", "(", "task_id", ")", "log", ".", "debug", "(", "\"Verifying {} is in {} cot artifacts...\"", ".", "format", "(", "path", ",", ...
Download an artifact and verify its SHA against the chain of trust. Args: chain (ChainOfTrust): the chain of trust object task_id (str): the task ID to download from path (str): the relative path to the artifact to download Returns: str: the full path of the downloaded artifact...
[ "Download", "an", "artifact", "and", "verify", "its", "SHA", "against", "the", "chain", "of", "trust", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L641-L681
train
28,018
mozilla-releng/scriptworker
scriptworker/cot/verify.py
download_cot_artifacts
async def download_cot_artifacts(chain): """Call ``download_cot_artifact`` in parallel for each "upstreamArtifacts". Optional artifacts are allowed to not be downloaded. Args: chain (ChainOfTrust): the chain of trust object Returns: list: list of full paths to downloaded artifacts. Fa...
python
async def download_cot_artifacts(chain): """Call ``download_cot_artifact`` in parallel for each "upstreamArtifacts". Optional artifacts are allowed to not be downloaded. Args: chain (ChainOfTrust): the chain of trust object Returns: list: list of full paths to downloaded artifacts. Fa...
[ "async", "def", "download_cot_artifacts", "(", "chain", ")", ":", "upstream_artifacts", "=", "chain", ".", "task", "[", "'payload'", "]", ".", "get", "(", "'upstreamArtifacts'", ",", "[", "]", ")", "all_artifacts_per_task_id", "=", "get_all_artifacts_per_task_id", ...
Call ``download_cot_artifact`` in parallel for each "upstreamArtifacts". Optional artifacts are allowed to not be downloaded. Args: chain (ChainOfTrust): the chain of trust object Returns: list: list of full paths to downloaded artifacts. Failed optional artifacts aren't returned ...
[ "Call", "download_cot_artifact", "in", "parallel", "for", "each", "upstreamArtifacts", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L685-L723
train
28,019
mozilla-releng/scriptworker
scriptworker/cot/verify.py
is_artifact_optional
def is_artifact_optional(chain, task_id, path): """Tells whether an artifact is flagged as optional or not. Args: chain (ChainOfTrust): the chain of trust object task_id (str): the id of the aforementioned task Returns: bool: True if artifact is optional """ upstream_artif...
python
def is_artifact_optional(chain, task_id, path): """Tells whether an artifact is flagged as optional or not. Args: chain (ChainOfTrust): the chain of trust object task_id (str): the id of the aforementioned task Returns: bool: True if artifact is optional """ upstream_artif...
[ "def", "is_artifact_optional", "(", "chain", ",", "task_id", ",", "path", ")", ":", "upstream_artifacts", "=", "chain", ".", "task", "[", "'payload'", "]", ".", "get", "(", "'upstreamArtifacts'", ",", "[", "]", ")", "optional_artifacts_per_task_id", "=", "get_...
Tells whether an artifact is flagged as optional or not. Args: chain (ChainOfTrust): the chain of trust object task_id (str): the id of the aforementioned task Returns: bool: True if artifact is optional
[ "Tells", "whether", "an", "artifact", "is", "flagged", "as", "optional", "or", "not", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L726-L739
train
28,020
mozilla-releng/scriptworker
scriptworker/cot/verify.py
get_all_artifacts_per_task_id
def get_all_artifacts_per_task_id(chain, upstream_artifacts): """Return every artifact to download, including the Chain Of Trust Artifacts. Args: chain (ChainOfTrust): the chain of trust object upstream_artifacts: the list of upstream artifact definitions Returns: dict: sorted list...
python
def get_all_artifacts_per_task_id(chain, upstream_artifacts): """Return every artifact to download, including the Chain Of Trust Artifacts. Args: chain (ChainOfTrust): the chain of trust object upstream_artifacts: the list of upstream artifact definitions Returns: dict: sorted list...
[ "def", "get_all_artifacts_per_task_id", "(", "chain", ",", "upstream_artifacts", ")", ":", "all_artifacts_per_task_id", "=", "{", "}", "for", "link", "in", "chain", ".", "links", ":", "# Download task-graph.json for decision+action task cot verification", "if", "link", "....
Return every artifact to download, including the Chain Of Trust Artifacts. Args: chain (ChainOfTrust): the chain of trust object upstream_artifacts: the list of upstream artifact definitions Returns: dict: sorted list of paths to downloaded artifacts ordered by taskId
[ "Return", "every", "artifact", "to", "download", "including", "the", "Chain", "Of", "Trust", "Artifacts", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L742-L779
train
28,021
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_link_ed25519_cot_signature
def verify_link_ed25519_cot_signature(chain, link, unsigned_path, signature_path): """Verify the ed25519 signatures of the chain of trust artifacts populated in ``download_cot``. Populate each link.cot with the chain of trust json body. Args: chain (ChainOfTrust): the chain of trust to add to. ...
python
def verify_link_ed25519_cot_signature(chain, link, unsigned_path, signature_path): """Verify the ed25519 signatures of the chain of trust artifacts populated in ``download_cot``. Populate each link.cot with the chain of trust json body. Args: chain (ChainOfTrust): the chain of trust to add to. ...
[ "def", "verify_link_ed25519_cot_signature", "(", "chain", ",", "link", ",", "unsigned_path", ",", "signature_path", ")", ":", "if", "chain", ".", "context", ".", "config", "[", "'verify_cot_signature'", "]", ":", "log", ".", "debug", "(", "\"Verifying the {} {} {}...
Verify the ed25519 signatures of the chain of trust artifacts populated in ``download_cot``. Populate each link.cot with the chain of trust json body. Args: chain (ChainOfTrust): the chain of trust to add to. Raises: (CoTError, ScriptWorkerEd25519Error): on signature verification failure.
[ "Verify", "the", "ed25519", "signatures", "of", "the", "chain", "of", "trust", "artifacts", "populated", "in", "download_cot", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L783-L828
train
28,022
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_cot_signatures
def verify_cot_signatures(chain): """Verify the signatures of the chain of trust artifacts populated in ``download_cot``. Populate each link.cot with the chain of trust json body. Args: chain (ChainOfTrust): the chain of trust to add to. Raises: CoTError: on failure. """ for ...
python
def verify_cot_signatures(chain): """Verify the signatures of the chain of trust artifacts populated in ``download_cot``. Populate each link.cot with the chain of trust json body. Args: chain (ChainOfTrust): the chain of trust to add to. Raises: CoTError: on failure. """ for ...
[ "def", "verify_cot_signatures", "(", "chain", ")", ":", "for", "link", "in", "chain", ".", "links", ":", "unsigned_path", "=", "link", ".", "get_artifact_full_path", "(", "'public/chain-of-trust.json'", ")", "ed25519_signature_path", "=", "link", ".", "get_artifact_...
Verify the signatures of the chain of trust artifacts populated in ``download_cot``. Populate each link.cot with the chain of trust json body. Args: chain (ChainOfTrust): the chain of trust to add to. Raises: CoTError: on failure.
[ "Verify", "the", "signatures", "of", "the", "chain", "of", "trust", "artifacts", "populated", "in", "download_cot", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L831-L846
train
28,023
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_task_in_task_graph
def verify_task_in_task_graph(task_link, graph_defn, level=logging.CRITICAL): """Verify a given task_link's task against a given graph task definition. This is a helper function for ``verify_link_in_task_graph``; this is split out so we can call it multiple times when we fuzzy match. Args: tas...
python
def verify_task_in_task_graph(task_link, graph_defn, level=logging.CRITICAL): """Verify a given task_link's task against a given graph task definition. This is a helper function for ``verify_link_in_task_graph``; this is split out so we can call it multiple times when we fuzzy match. Args: tas...
[ "def", "verify_task_in_task_graph", "(", "task_link", ",", "graph_defn", ",", "level", "=", "logging", ".", "CRITICAL", ")", ":", "ignore_keys", "=", "(", "\"created\"", ",", "\"deadline\"", ",", "\"expires\"", ",", "\"dependencies\"", ",", "\"schedulerId\"", ")",...
Verify a given task_link's task against a given graph task definition. This is a helper function for ``verify_link_in_task_graph``; this is split out so we can call it multiple times when we fuzzy match. Args: task_link (LinkOfTrust): the link to try to match graph_defn (dict): the task de...
[ "Verify", "a", "given", "task_link", "s", "task", "against", "a", "given", "graph", "task", "definition", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L850-L893
train
28,024
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_link_in_task_graph
def verify_link_in_task_graph(chain, decision_link, task_link): """Compare the runtime task definition against the decision task graph. Args: chain (ChainOfTrust): the chain we're operating on. decision_link (LinkOfTrust): the decision task link task_link (LinkOfTrust): the task link we...
python
def verify_link_in_task_graph(chain, decision_link, task_link): """Compare the runtime task definition against the decision task graph. Args: chain (ChainOfTrust): the chain we're operating on. decision_link (LinkOfTrust): the decision task link task_link (LinkOfTrust): the task link we...
[ "def", "verify_link_in_task_graph", "(", "chain", ",", "decision_link", ",", "task_link", ")", ":", "log", ".", "info", "(", "\"Verifying the {} {} task definition is part of the {} {} task graph...\"", ".", "format", "(", "task_link", ".", "name", ",", "task_link", "."...
Compare the runtime task definition against the decision task graph. Args: chain (ChainOfTrust): the chain we're operating on. decision_link (LinkOfTrust): the decision task link task_link (LinkOfTrust): the task link we're testing Raises: CoTError: on failure.
[ "Compare", "the", "runtime", "task", "definition", "against", "the", "decision", "task", "graph", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L915-L937
train
28,025
mozilla-releng/scriptworker
scriptworker/cot/verify.py
get_pushlog_info
async def get_pushlog_info(decision_link): """Get pushlog info for a decision LinkOfTrust. Args: decision_link (LinkOfTrust): the decision link to get pushlog info about. Returns: dict: pushlog info. """ source_env_prefix = decision_link.context.config['source_env_prefix'] rep...
python
async def get_pushlog_info(decision_link): """Get pushlog info for a decision LinkOfTrust. Args: decision_link (LinkOfTrust): the decision link to get pushlog info about. Returns: dict: pushlog info. """ source_env_prefix = decision_link.context.config['source_env_prefix'] rep...
[ "async", "def", "get_pushlog_info", "(", "decision_link", ")", ":", "source_env_prefix", "=", "decision_link", ".", "context", ".", "config", "[", "'source_env_prefix'", "]", "repo", "=", "get_repo", "(", "decision_link", ".", "task", ",", "source_env_prefix", ")"...
Get pushlog info for a decision LinkOfTrust. Args: decision_link (LinkOfTrust): the decision link to get pushlog info about. Returns: dict: pushlog info.
[ "Get", "pushlog", "info", "for", "a", "decision", "LinkOfTrust", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L941-L967
train
28,026
mozilla-releng/scriptworker
scriptworker/cot/verify.py
get_scm_level
async def get_scm_level(context, project): """Get the scm level for a project from ``projects.yml``. We define all known projects in ``projects.yml``. Let's make sure we have it populated in ``context``, then return the scm level of ``project``. SCM levels are an integer, 1-3, matching Mozilla commit ...
python
async def get_scm_level(context, project): """Get the scm level for a project from ``projects.yml``. We define all known projects in ``projects.yml``. Let's make sure we have it populated in ``context``, then return the scm level of ``project``. SCM levels are an integer, 1-3, matching Mozilla commit ...
[ "async", "def", "get_scm_level", "(", "context", ",", "project", ")", ":", "await", "context", ".", "populate_projects", "(", ")", "level", "=", "context", ".", "projects", "[", "project", "]", "[", "'access'", "]", ".", "replace", "(", "\"scm_level_\"", "...
Get the scm level for a project from ``projects.yml``. We define all known projects in ``projects.yml``. Let's make sure we have it populated in ``context``, then return the scm level of ``project``. SCM levels are an integer, 1-3, matching Mozilla commit levels. https://www.mozilla.org/en-US/about/go...
[ "Get", "the", "scm", "level", "for", "a", "project", "from", "projects", ".", "yml", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L971-L990
train
28,027
mozilla-releng/scriptworker
scriptworker/cot/verify.py
populate_jsone_context
async def populate_jsone_context(chain, parent_link, decision_link, tasks_for): """Populate the json-e context to rebuild ``parent_link``'s task definition. This defines the context that `.taskcluster.yml` expects to be rendered with. See comments at the top of that file for details. Args: ch...
python
async def populate_jsone_context(chain, parent_link, decision_link, tasks_for): """Populate the json-e context to rebuild ``parent_link``'s task definition. This defines the context that `.taskcluster.yml` expects to be rendered with. See comments at the top of that file for details. Args: ch...
[ "async", "def", "populate_jsone_context", "(", "chain", ",", "parent_link", ",", "decision_link", ",", "tasks_for", ")", ":", "task_ids", "=", "{", "\"default\"", ":", "parent_link", ".", "task_id", ",", "\"decision\"", ":", "decision_link", ".", "task_id", ",",...
Populate the json-e context to rebuild ``parent_link``'s task definition. This defines the context that `.taskcluster.yml` expects to be rendered with. See comments at the top of that file for details. Args: chain (ChainOfTrust): the chain of trust to add to. parent_link (LinkOfTrust): th...
[ "Populate", "the", "json", "-", "e", "context", "to", "rebuild", "parent_link", "s", "task", "definition", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1228-L1305
train
28,028
mozilla-releng/scriptworker
scriptworker/cot/verify.py
get_in_tree_template
async def get_in_tree_template(link): """Get the in-tree json-e template for a given link. By convention, this template is SOURCE_REPO/.taskcluster.yml. Args: link (LinkOfTrust): the parent link to get the source url from. Raises: CoTError: on non-yaml `source_url` KeyError: o...
python
async def get_in_tree_template(link): """Get the in-tree json-e template for a given link. By convention, this template is SOURCE_REPO/.taskcluster.yml. Args: link (LinkOfTrust): the parent link to get the source url from. Raises: CoTError: on non-yaml `source_url` KeyError: o...
[ "async", "def", "get_in_tree_template", "(", "link", ")", ":", "context", "=", "link", ".", "context", "source_url", "=", "get_source_url", "(", "link", ")", "if", "not", "source_url", ".", "endswith", "(", "(", "'.yml'", ",", "'.yaml'", ")", ")", ":", "...
Get the in-tree json-e template for a given link. By convention, this template is SOURCE_REPO/.taskcluster.yml. Args: link (LinkOfTrust): the parent link to get the source url from. Raises: CoTError: on non-yaml `source_url` KeyError: on non-well-formed source template Return...
[ "Get", "the", "in", "-", "tree", "json", "-", "e", "template", "for", "a", "given", "link", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1309-L1336
train
28,029
mozilla-releng/scriptworker
scriptworker/cot/verify.py
get_action_context_and_template
async def get_action_context_and_template(chain, parent_link, decision_link): """Get the appropriate json-e context and template for an action task. Args: chain (ChainOfTrust): the chain of trust. parent_link (LinkOfTrust): the parent link to test. decision_link (LinkOfTrust): the paren...
python
async def get_action_context_and_template(chain, parent_link, decision_link): """Get the appropriate json-e context and template for an action task. Args: chain (ChainOfTrust): the chain of trust. parent_link (LinkOfTrust): the parent link to test. decision_link (LinkOfTrust): the paren...
[ "async", "def", "get_action_context_and_template", "(", "chain", ",", "parent_link", ",", "decision_link", ")", ":", "actions_path", "=", "decision_link", ".", "get_artifact_full_path", "(", "'public/actions.json'", ")", "all_actions", "=", "load_json_or_yaml", "(", "ac...
Get the appropriate json-e context and template for an action task. Args: chain (ChainOfTrust): the chain of trust. parent_link (LinkOfTrust): the parent link to test. decision_link (LinkOfTrust): the parent link's decision task link. tasks_for (str): the reason the parent link was ...
[ "Get", "the", "appropriate", "json", "-", "e", "context", "and", "template", "for", "an", "action", "task", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1414-L1467
train
28,030
mozilla-releng/scriptworker
scriptworker/cot/verify.py
get_jsone_context_and_template
async def get_jsone_context_and_template(chain, parent_link, decision_link, tasks_for): """Get the appropriate json-e context and template for any parent task. Args: chain (ChainOfTrust): the chain of trust. parent_link (LinkOfTrust): the parent link to test. decision_link (LinkOfTrust)...
python
async def get_jsone_context_and_template(chain, parent_link, decision_link, tasks_for): """Get the appropriate json-e context and template for any parent task. Args: chain (ChainOfTrust): the chain of trust. parent_link (LinkOfTrust): the parent link to test. decision_link (LinkOfTrust)...
[ "async", "def", "get_jsone_context_and_template", "(", "chain", ",", "parent_link", ",", "decision_link", ",", "tasks_for", ")", ":", "if", "tasks_for", "==", "'action'", ":", "jsone_context", ",", "tmpl", "=", "await", "get_action_context_and_template", "(", "chain...
Get the appropriate json-e context and template for any parent task. Args: chain (ChainOfTrust): the chain of trust. parent_link (LinkOfTrust): the parent link to test. decision_link (LinkOfTrust): the parent link's decision task link. tasks_for (str): the reason the parent link was...
[ "Get", "the", "appropriate", "json", "-", "e", "context", "and", "template", "for", "any", "parent", "task", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1471-L1494
train
28,031
mozilla-releng/scriptworker
scriptworker/cot/verify.py
check_and_update_action_task_group_id
def check_and_update_action_task_group_id(parent_link, decision_link, rebuilt_definitions): """Update the ``ACTION_TASK_GROUP_ID`` of an action after verifying. Actions have varying ``ACTION_TASK_GROUP_ID`` behavior. Release Promotion action tasks set the ``ACTION_TASK_GROUP_ID`` to match the action ``tas...
python
def check_and_update_action_task_group_id(parent_link, decision_link, rebuilt_definitions): """Update the ``ACTION_TASK_GROUP_ID`` of an action after verifying. Actions have varying ``ACTION_TASK_GROUP_ID`` behavior. Release Promotion action tasks set the ``ACTION_TASK_GROUP_ID`` to match the action ``tas...
[ "def", "check_and_update_action_task_group_id", "(", "parent_link", ",", "decision_link", ",", "rebuilt_definitions", ")", ":", "rebuilt_gid", "=", "rebuilt_definitions", "[", "'tasks'", "]", "[", "0", "]", "[", "'payload'", "]", "[", "'env'", "]", "[", "'ACTION_T...
Update the ``ACTION_TASK_GROUP_ID`` of an action after verifying. Actions have varying ``ACTION_TASK_GROUP_ID`` behavior. Release Promotion action tasks set the ``ACTION_TASK_GROUP_ID`` to match the action ``taskId`` so the large set of release tasks have their own taskgroup. Non-relpro action tasks s...
[ "Update", "the", "ACTION_TASK_GROUP_ID", "of", "an", "action", "after", "verifying", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1547-L1585
train
28,032
mozilla-releng/scriptworker
scriptworker/cot/verify.py
compare_jsone_task_definition
def compare_jsone_task_definition(parent_link, rebuilt_definitions): """Compare the json-e rebuilt task definition vs the runtime definition. Args: parent_link (LinkOfTrust): the parent link to test. rebuilt_definitions (dict): the rebuilt task definitions. Raises: CoTError: on fai...
python
def compare_jsone_task_definition(parent_link, rebuilt_definitions): """Compare the json-e rebuilt task definition vs the runtime definition. Args: parent_link (LinkOfTrust): the parent link to test. rebuilt_definitions (dict): the rebuilt task definitions. Raises: CoTError: on fai...
[ "def", "compare_jsone_task_definition", "(", "parent_link", ",", "rebuilt_definitions", ")", ":", "diffs", "=", "[", "]", "for", "compare_definition", "in", "rebuilt_definitions", "[", "'tasks'", "]", ":", "# Rebuilt decision tasks have an extra `taskId`; remove", "if", "...
Compare the json-e rebuilt task definition vs the runtime definition. Args: parent_link (LinkOfTrust): the parent link to test. rebuilt_definitions (dict): the rebuilt task definitions. Raises: CoTError: on failure.
[ "Compare", "the", "json", "-", "e", "rebuilt", "task", "definition", "vs", "the", "runtime", "definition", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1589-L1621
train
28,033
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_parent_task
async def verify_parent_task(chain, link): """Verify the parent task Link. Action task verification is currently in the same verification function as decision tasks, because sometimes we'll have an action task masquerading as a decision task, e.g. in templatized actions for release graphs. To make ...
python
async def verify_parent_task(chain, link): """Verify the parent task Link. Action task verification is currently in the same verification function as decision tasks, because sometimes we'll have an action task masquerading as a decision task, e.g. in templatized actions for release graphs. To make ...
[ "async", "def", "verify_parent_task", "(", "chain", ",", "link", ")", ":", "worker_type", "=", "get_worker_type", "(", "link", ".", "task", ")", "if", "worker_type", "not", "in", "chain", ".", "context", ".", "config", "[", "'valid_decision_worker_types'", "]"...
Verify the parent task Link. Action task verification is currently in the same verification function as decision tasks, because sometimes we'll have an action task masquerading as a decision task, e.g. in templatized actions for release graphs. To make sure our guess of decision or action task isn't fa...
[ "Verify", "the", "parent", "task", "Link", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1625-L1670
train
28,034
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_docker_image_task
async def verify_docker_image_task(chain, link): """Verify the docker image Link. Args: chain (ChainOfTrust): the chain we're operating on. link (LinkOfTrust): the task link we're checking. """ errors = [] # workerType worker_type = get_worker_type(link.task) if worker_type...
python
async def verify_docker_image_task(chain, link): """Verify the docker image Link. Args: chain (ChainOfTrust): the chain we're operating on. link (LinkOfTrust): the task link we're checking. """ errors = [] # workerType worker_type = get_worker_type(link.task) if worker_type...
[ "async", "def", "verify_docker_image_task", "(", "chain", ",", "link", ")", ":", "errors", "=", "[", "]", "# workerType", "worker_type", "=", "get_worker_type", "(", "link", ".", "task", ")", "if", "worker_type", "not", "in", "chain", ".", "context", ".", ...
Verify the docker image Link. Args: chain (ChainOfTrust): the chain we're operating on. link (LinkOfTrust): the task link we're checking.
[ "Verify", "the", "docker", "image", "Link", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1690-L1703
train
28,035
mozilla-releng/scriptworker
scriptworker/cot/verify.py
check_num_tasks
def check_num_tasks(chain, task_count): """Make sure there are a specific number of specific task types. Currently we only check decision tasks. Args: chain (ChainOfTrust): the chain we're operating on task_count (dict): mapping task type to the number of links. Raises: CoTErr...
python
def check_num_tasks(chain, task_count): """Make sure there are a specific number of specific task types. Currently we only check decision tasks. Args: chain (ChainOfTrust): the chain we're operating on task_count (dict): mapping task type to the number of links. Raises: CoTErr...
[ "def", "check_num_tasks", "(", "chain", ",", "task_count", ")", ":", "errors", "=", "[", "]", "# hardcode for now. If we need a different set of constraints, either", "# go by cot_product settings or by task_count['docker-image'] + 1", "min_decision_tasks", "=", "1", "if", "task...
Make sure there are a specific number of specific task types. Currently we only check decision tasks. Args: chain (ChainOfTrust): the chain we're operating on task_count (dict): mapping task type to the number of links. Raises: CoTError: on failure.
[ "Make", "sure", "there", "are", "a", "specific", "number", "of", "specific", "task", "types", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1841-L1862
train
28,036
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_docker_worker_task
async def verify_docker_worker_task(chain, link): """Docker-worker specific checks. Args: chain (ChainOfTrust): the chain we're operating on link (ChainOfTrust or LinkOfTrust): the trust object for the signing task. Raises: CoTError: on failure. """ if chain != link: ...
python
async def verify_docker_worker_task(chain, link): """Docker-worker specific checks. Args: chain (ChainOfTrust): the chain we're operating on link (ChainOfTrust or LinkOfTrust): the trust object for the signing task. Raises: CoTError: on failure. """ if chain != link: ...
[ "async", "def", "verify_docker_worker_task", "(", "chain", ",", "link", ")", ":", "if", "chain", "!=", "link", ":", "# These two checks will die on `link.cot` if `link` is a ChainOfTrust", "# object (e.g., the task we're running `verify_cot` against is a", "# docker-worker task). So ...
Docker-worker specific checks. Args: chain (ChainOfTrust): the chain we're operating on link (ChainOfTrust or LinkOfTrust): the trust object for the signing task. Raises: CoTError: on failure.
[ "Docker", "-", "worker", "specific", "checks", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1890-L1907
train
28,037
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_scriptworker_task
async def verify_scriptworker_task(chain, obj): """Verify the signing trust object. Currently the only check is to make sure it was run on a scriptworker. Args: chain (ChainOfTrust): the chain we're operating on obj (ChainOfTrust or LinkOfTrust): the trust object for the signing task. ...
python
async def verify_scriptworker_task(chain, obj): """Verify the signing trust object. Currently the only check is to make sure it was run on a scriptworker. Args: chain (ChainOfTrust): the chain we're operating on obj (ChainOfTrust or LinkOfTrust): the trust object for the signing task. ...
[ "async", "def", "verify_scriptworker_task", "(", "chain", ",", "obj", ")", ":", "errors", "=", "[", "]", "if", "obj", ".", "worker_impl", "!=", "\"scriptworker\"", ":", "errors", ".", "append", "(", "\"{} {} must be run from scriptworker!\"", ".", "format", "(",...
Verify the signing trust object. Currently the only check is to make sure it was run on a scriptworker. Args: chain (ChainOfTrust): the chain we're operating on obj (ChainOfTrust or LinkOfTrust): the trust object for the signing task.
[ "Verify", "the", "signing", "trust", "object", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1926-L1939
train
28,038
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_repo_matches_url
def verify_repo_matches_url(repo, url): """Verify ``url`` is a part of ``repo``. We were using ``startswith()`` for a while, which isn't a good comparison. This function allows us to ``urlparse`` and compare host and path. Args: repo (str): the repo url url (str): the url to verify is ...
python
def verify_repo_matches_url(repo, url): """Verify ``url`` is a part of ``repo``. We were using ``startswith()`` for a while, which isn't a good comparison. This function allows us to ``urlparse`` and compare host and path. Args: repo (str): the repo url url (str): the url to verify is ...
[ "def", "verify_repo_matches_url", "(", "repo", ",", "url", ")", ":", "repo_parts", "=", "urlparse", "(", "repo", ")", "url_parts", "=", "urlparse", "(", "url", ")", "errors", "=", "[", "]", "repo_path_parts", "=", "repo_parts", ".", "path", ".", "split", ...
Verify ``url`` is a part of ``repo``. We were using ``startswith()`` for a while, which isn't a good comparison. This function allows us to ``urlparse`` and compare host and path. Args: repo (str): the repo url url (str): the url to verify is part of the repo Returns: bool: ``...
[ "Verify", "url", "is", "a", "part", "of", "repo", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1963-L1994
train
28,039
mozilla-releng/scriptworker
scriptworker/cot/verify.py
get_source_url
def get_source_url(obj): """Get the source url for a Trust object. Args: obj (ChainOfTrust or LinkOfTrust): the trust object to inspect Raises: CoTError: if repo and source are defined and don't match Returns: str: the source url. """ source_env_prefix = obj.context.c...
python
def get_source_url(obj): """Get the source url for a Trust object. Args: obj (ChainOfTrust or LinkOfTrust): the trust object to inspect Raises: CoTError: if repo and source are defined and don't match Returns: str: the source url. """ source_env_prefix = obj.context.c...
[ "def", "get_source_url", "(", "obj", ")", ":", "source_env_prefix", "=", "obj", ".", "context", ".", "config", "[", "'source_env_prefix'", "]", "task", "=", "obj", ".", "task", "log", ".", "debug", "(", "\"Getting source url for {} {}...\"", ".", "format", "("...
Get the source url for a Trust object. Args: obj (ChainOfTrust or LinkOfTrust): the trust object to inspect Raises: CoTError: if repo and source are defined and don't match Returns: str: the source url.
[ "Get", "the", "source", "url", "for", "a", "Trust", "object", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L1997-L2020
train
28,040
mozilla-releng/scriptworker
scriptworker/cot/verify.py
trace_back_to_tree
async def trace_back_to_tree(chain): """Trace the chain back to the tree. task.metadata.source: "https://hg.mozilla.org/projects/date//file/a80373508881bfbff67a2a49297c328ff8052572/taskcluster/ci/build" task.payload.env.GECKO_HEAD_REPOSITORY "https://hg.mozilla.org/projects/date/" Args: chain ...
python
async def trace_back_to_tree(chain): """Trace the chain back to the tree. task.metadata.source: "https://hg.mozilla.org/projects/date//file/a80373508881bfbff67a2a49297c328ff8052572/taskcluster/ci/build" task.payload.env.GECKO_HEAD_REPOSITORY "https://hg.mozilla.org/projects/date/" Args: chain ...
[ "async", "def", "trace_back_to_tree", "(", "chain", ")", ":", "errors", "=", "[", "]", "repos", "=", "{", "}", "restricted_privs", "=", "None", "rules", "=", "{", "}", "for", "my_key", ",", "config_key", "in", "{", "'scopes'", ":", "'cot_restricted_scopes'...
Trace the chain back to the tree. task.metadata.source: "https://hg.mozilla.org/projects/date//file/a80373508881bfbff67a2a49297c328ff8052572/taskcluster/ci/build" task.payload.env.GECKO_HEAD_REPOSITORY "https://hg.mozilla.org/projects/date/" Args: chain (ChainOfTrust): the chain we're operating on...
[ "Trace", "the", "chain", "back", "to", "the", "tree", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L2024-L2090
train
28,041
mozilla-releng/scriptworker
scriptworker/cot/verify.py
verify_chain_of_trust
async def verify_chain_of_trust(chain): """Build and verify the chain of trust. Args: chain (ChainOfTrust): the chain we're operating on Raises: CoTError: on failure """ log_path = os.path.join(chain.context.config["task_log_dir"], "chain_of_trust.log") scriptworker_log = logg...
python
async def verify_chain_of_trust(chain): """Build and verify the chain of trust. Args: chain (ChainOfTrust): the chain we're operating on Raises: CoTError: on failure """ log_path = os.path.join(chain.context.config["task_log_dir"], "chain_of_trust.log") scriptworker_log = logg...
[ "async", "def", "verify_chain_of_trust", "(", "chain", ")", ":", "log_path", "=", "os", ".", "path", ".", "join", "(", "chain", ".", "context", ".", "config", "[", "\"task_log_dir\"", "]", ",", "\"chain_of_trust.log\"", ")", "scriptworker_log", "=", "logging",...
Build and verify the chain of trust. Args: chain (ChainOfTrust): the chain we're operating on Raises: CoTError: on failure
[ "Build", "and", "verify", "the", "chain", "of", "trust", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L2105-L2145
train
28,042
mozilla-releng/scriptworker
scriptworker/cot/verify.py
ChainOfTrust.is_try_or_pull_request
async def is_try_or_pull_request(self): """Determine if any task in the chain is a try task. Returns: bool: True if a task is a try task. """ tasks = [asyncio.ensure_future(link.is_try_or_pull_request()) for link in self.links] tasks.insert(0, asyncio.ensure_future(...
python
async def is_try_or_pull_request(self): """Determine if any task in the chain is a try task. Returns: bool: True if a task is a try task. """ tasks = [asyncio.ensure_future(link.is_try_or_pull_request()) for link in self.links] tasks.insert(0, asyncio.ensure_future(...
[ "async", "def", "is_try_or_pull_request", "(", "self", ")", ":", "tasks", "=", "[", "asyncio", ".", "ensure_future", "(", "link", ".", "is_try_or_pull_request", "(", ")", ")", "for", "link", "in", "self", ".", "links", "]", "tasks", ".", "insert", "(", "...
Determine if any task in the chain is a try task. Returns: bool: True if a task is a try task.
[ "Determine", "if", "any", "task", "in", "the", "chain", "is", "a", "try", "task", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L129-L140
train
28,043
mozilla-releng/scriptworker
scriptworker/cot/verify.py
ChainOfTrust.get_link
def get_link(self, task_id): """Get a ``LinkOfTrust`` by task id. Args: task_id (str): the task id to find. Returns: LinkOfTrust: the link matching the task id. Raises: CoTError: if no ``LinkOfTrust`` matches. """ links = [x for x i...
python
def get_link(self, task_id): """Get a ``LinkOfTrust`` by task id. Args: task_id (str): the task id to find. Returns: LinkOfTrust: the link matching the task id. Raises: CoTError: if no ``LinkOfTrust`` matches. """ links = [x for x i...
[ "def", "get_link", "(", "self", ",", "task_id", ")", ":", "links", "=", "[", "x", "for", "x", "in", "self", ".", "links", "if", "x", ".", "task_id", "==", "task_id", "]", "if", "len", "(", "links", ")", "!=", "1", ":", "raise", "CoTError", "(", ...
Get a ``LinkOfTrust`` by task id. Args: task_id (str): the task id to find. Returns: LinkOfTrust: the link matching the task id. Raises: CoTError: if no ``LinkOfTrust`` matches.
[ "Get", "a", "LinkOfTrust", "by", "task", "id", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L142-L158
train
28,044
mozilla-releng/scriptworker
scriptworker/cot/verify.py
ChainOfTrust.get_all_links_in_chain
def get_all_links_in_chain(self): """Return all links in the chain of trust, including the target task. By default, we're checking a task and all its dependencies back to the tree, so the full chain is ``self.links`` + ``self``. However, we also support checking the decision task itself...
python
def get_all_links_in_chain(self): """Return all links in the chain of trust, including the target task. By default, we're checking a task and all its dependencies back to the tree, so the full chain is ``self.links`` + ``self``. However, we also support checking the decision task itself...
[ "def", "get_all_links_in_chain", "(", "self", ")", ":", "if", "self", ".", "is_decision", "(", ")", "and", "self", ".", "get_link", "(", "self", ".", "task_id", ")", ":", "return", "self", ".", "links", "return", "[", "self", "]", "+", "self", ".", "...
Return all links in the chain of trust, including the target task. By default, we're checking a task and all its dependencies back to the tree, so the full chain is ``self.links`` + ``self``. However, we also support checking the decision task itself. In that case, we populate the decis...
[ "Return", "all", "links", "in", "the", "chain", "of", "trust", "including", "the", "target", "task", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L169-L184
train
28,045
mozilla-releng/scriptworker
scriptworker/cot/verify.py
AuditLogFormatter.format
def format(self, record): """Space debug messages for more legibility.""" if record.levelno == logging.DEBUG: record.msg = ' {}'.format(record.msg) return super(AuditLogFormatter, self).format(record)
python
def format(self, record): """Space debug messages for more legibility.""" if record.levelno == logging.DEBUG: record.msg = ' {}'.format(record.msg) return super(AuditLogFormatter, self).format(record)
[ "def", "format", "(", "self", ",", "record", ")", ":", "if", "record", ".", "levelno", "==", "logging", ".", "DEBUG", ":", "record", ".", "msg", "=", "' {}'", ".", "format", "(", "record", ".", "msg", ")", "return", "super", "(", "AuditLogFormatter", ...
Space debug messages for more legibility.
[ "Space", "debug", "messages", "for", "more", "legibility", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/verify.py#L2097-L2101
train
28,046
mozilla-releng/scriptworker
scriptworker/version.py
get_version_string
def get_version_string(version): """Translate a version tuple into a string. Specify the __version__ as a tuple for more precise comparisons, and translate it to __version_string__ for when that's needed. This function exists primarily for easier unit testing. Args: version (Tuple[int, int,...
python
def get_version_string(version): """Translate a version tuple into a string. Specify the __version__ as a tuple for more precise comparisons, and translate it to __version_string__ for when that's needed. This function exists primarily for easier unit testing. Args: version (Tuple[int, int,...
[ "def", "get_version_string", "(", "version", ")", ":", "version_len", "=", "len", "(", "version", ")", "if", "version_len", "==", "3", ":", "version_string", "=", "'%d.%d.%d'", "%", "version", "elif", "version_len", "==", "4", ":", "version_string", "=", "'%...
Translate a version tuple into a string. Specify the __version__ as a tuple for more precise comparisons, and translate it to __version_string__ for when that's needed. This function exists primarily for easier unit testing. Args: version (Tuple[int, int, int, str]): three ints and an optional ...
[ "Translate", "a", "version", "tuple", "into", "a", "string", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/version.py#L26-L50
train
28,047
mozilla-releng/scriptworker
scriptworker/config.py
get_unfrozen_copy
def get_unfrozen_copy(values): """Recursively convert `value`'s tuple values into lists, and frozendicts into dicts. Args: values (frozendict/tuple): the frozendict/tuple. Returns: values (dict/list): the unfrozen copy. """ if isinstance(values, (frozendict, dict)): return...
python
def get_unfrozen_copy(values): """Recursively convert `value`'s tuple values into lists, and frozendicts into dicts. Args: values (frozendict/tuple): the frozendict/tuple. Returns: values (dict/list): the unfrozen copy. """ if isinstance(values, (frozendict, dict)): return...
[ "def", "get_unfrozen_copy", "(", "values", ")", ":", "if", "isinstance", "(", "values", ",", "(", "frozendict", ",", "dict", ")", ")", ":", "return", "{", "key", ":", "get_unfrozen_copy", "(", "value", ")", "for", "key", ",", "value", "in", "values", "...
Recursively convert `value`'s tuple values into lists, and frozendicts into dicts. Args: values (frozendict/tuple): the frozendict/tuple. Returns: values (dict/list): the unfrozen copy.
[ "Recursively", "convert", "value", "s", "tuple", "values", "into", "lists", "and", "frozendicts", "into", "dicts", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/config.py#L57-L73
train
28,048
mozilla-releng/scriptworker
scriptworker/config.py
read_worker_creds
def read_worker_creds(key="credentials"): """Get credentials from CREDS_FILES or the environment. This looks at the CREDS_FILES in order, and falls back to the environment. Args: key (str, optional): each CREDS_FILE is a json dict. This key's value contains the credentials. Defaults ...
python
def read_worker_creds(key="credentials"): """Get credentials from CREDS_FILES or the environment. This looks at the CREDS_FILES in order, and falls back to the environment. Args: key (str, optional): each CREDS_FILE is a json dict. This key's value contains the credentials. Defaults ...
[ "def", "read_worker_creds", "(", "key", "=", "\"credentials\"", ")", ":", "for", "path", "in", "CREDS_FILES", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "continue", "contents", "=", "load_json_or_yaml", "(", "path", ",", "...
Get credentials from CREDS_FILES or the environment. This looks at the CREDS_FILES in order, and falls back to the environment. Args: key (str, optional): each CREDS_FILE is a json dict. This key's value contains the credentials. Defaults to 'credentials'. Returns: dict: the...
[ "Get", "credentials", "from", "CREDS_FILES", "or", "the", "environment", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/config.py#L77-L105
train
28,049
mozilla-releng/scriptworker
scriptworker/config.py
check_config
def check_config(config, path): """Validate the config against DEFAULT_CONFIG. Any unknown keys or wrong types will add error messages. Args: config (dict): the running config. path (str): the path to the config file, used in error messages. Returns: list: the error messages f...
python
def check_config(config, path): """Validate the config against DEFAULT_CONFIG. Any unknown keys or wrong types will add error messages. Args: config (dict): the running config. path (str): the path to the config file, used in error messages. Returns: list: the error messages f...
[ "def", "check_config", "(", "config", ",", "path", ")", ":", "messages", "=", "[", "]", "config_copy", "=", "get_frozen_copy", "(", "config", ")", "missing_keys", "=", "set", "(", "DEFAULT_CONFIG", ".", "keys", "(", ")", ")", "-", "set", "(", "config_cop...
Validate the config against DEFAULT_CONFIG. Any unknown keys or wrong types will add error messages. Args: config (dict): the running config. path (str): the path to the config file, used in error messages. Returns: list: the error messages found when validating the config.
[ "Validate", "the", "config", "against", "DEFAULT_CONFIG", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/config.py#L109-L149
train
28,050
mozilla-releng/scriptworker
scriptworker/config.py
apply_product_config
def apply_product_config(config): """Apply config values that are keyed by `cot_product`. This modifies the passed in configuration. Args: config dict: the config to apply cot_product keying too Returns: dict """ cot_product = config['cot_product'] for key in config: if ...
python
def apply_product_config(config): """Apply config values that are keyed by `cot_product`. This modifies the passed in configuration. Args: config dict: the config to apply cot_product keying too Returns: dict """ cot_product = config['cot_product'] for key in config: if ...
[ "def", "apply_product_config", "(", "config", ")", ":", "cot_product", "=", "config", "[", "'cot_product'", "]", "for", "key", "in", "config", ":", "if", "isinstance", "(", "config", "[", "key", "]", ",", "Mapping", ")", "and", "'by-cot-product'", "in", "c...
Apply config values that are keyed by `cot_product`. This modifies the passed in configuration. Args: config dict: the config to apply cot_product keying too Returns: dict
[ "Apply", "config", "values", "that", "are", "keyed", "by", "cot_product", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/config.py#L156-L176
train
28,051
mozilla-releng/scriptworker
scriptworker/config.py
create_config
def create_config(config_path="scriptworker.yaml"): """Create a config from DEFAULT_CONFIG, arguments, and config file. Then validate it and freeze it. Args: config_path (str, optional): the path to the config file. Defaults to "scriptworker.yaml" Returns: tuple: (config ...
python
def create_config(config_path="scriptworker.yaml"): """Create a config from DEFAULT_CONFIG, arguments, and config file. Then validate it and freeze it. Args: config_path (str, optional): the path to the config file. Defaults to "scriptworker.yaml" Returns: tuple: (config ...
[ "def", "create_config", "(", "config_path", "=", "\"scriptworker.yaml\"", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "config_path", ")", ":", "print", "(", "\"{} doesn't exist! Exiting...\"", ".", "format", "(", "config_path", ")", ",", "fil...
Create a config from DEFAULT_CONFIG, arguments, and config file. Then validate it and freeze it. Args: config_path (str, optional): the path to the config file. Defaults to "scriptworker.yaml" Returns: tuple: (config frozendict, credentials dict) Raises: SystemEx...
[ "Create", "a", "config", "from", "DEFAULT_CONFIG", "arguments", "and", "config", "file", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/config.py#L180-L214
train
28,052
mozilla-releng/scriptworker
scriptworker/config.py
get_context_from_cmdln
def get_context_from_cmdln(args, desc="Run scriptworker"): """Create a Context object from args. Args: args (list): the commandline args. Generally sys.argv Returns: tuple: ``scriptworker.context.Context`` with populated config, and credentials frozendict """ context ...
python
def get_context_from_cmdln(args, desc="Run scriptworker"): """Create a Context object from args. Args: args (list): the commandline args. Generally sys.argv Returns: tuple: ``scriptworker.context.Context`` with populated config, and credentials frozendict """ context ...
[ "def", "get_context_from_cmdln", "(", "args", ",", "desc", "=", "\"Run scriptworker\"", ")", ":", "context", "=", "Context", "(", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "desc", ")", "parser", ".", "add_argument", "(", ...
Create a Context object from args. Args: args (list): the commandline args. Generally sys.argv Returns: tuple: ``scriptworker.context.Context`` with populated config, and credentials frozendict
[ "Create", "a", "Context", "object", "from", "args", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/config.py#L218-L238
train
28,053
mozilla-releng/scriptworker
scriptworker/cot/generate.py
get_cot_artifacts
def get_cot_artifacts(context): """Generate the artifact relative paths and shas for the chain of trust. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict: a dictionary of {"path/to/artifact": {"hash_alg": "..."}, ...} """ artifacts = {} fil...
python
def get_cot_artifacts(context): """Generate the artifact relative paths and shas for the chain of trust. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict: a dictionary of {"path/to/artifact": {"hash_alg": "..."}, ...} """ artifacts = {} fil...
[ "def", "get_cot_artifacts", "(", "context", ")", ":", "artifacts", "=", "{", "}", "filepaths", "=", "filepaths_in_dir", "(", "context", ".", "config", "[", "'artifact_dir'", "]", ")", "hash_alg", "=", "context", ".", "config", "[", "'chain_of_trust_hash_algorith...
Generate the artifact relative paths and shas for the chain of trust. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict: a dictionary of {"path/to/artifact": {"hash_alg": "..."}, ...}
[ "Generate", "the", "artifact", "relative", "paths", "and", "shas", "for", "the", "chain", "of", "trust", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/generate.py#L25-L42
train
28,054
mozilla-releng/scriptworker
scriptworker/cot/generate.py
generate_cot_body
def generate_cot_body(context): """Generate the chain of trust dictionary. This is the unsigned and unformatted chain of trust artifact contents. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict: the unsignd and unformatted chain of trust artifact ...
python
def generate_cot_body(context): """Generate the chain of trust dictionary. This is the unsigned and unformatted chain of trust artifact contents. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict: the unsignd and unformatted chain of trust artifact ...
[ "def", "generate_cot_body", "(", "context", ")", ":", "try", ":", "cot", "=", "{", "'artifacts'", ":", "get_cot_artifacts", "(", "context", ")", ",", "'chainOfTrustVersion'", ":", "1", ",", "'runId'", ":", "context", ".", "claim_task", "[", "'runId'", "]", ...
Generate the chain of trust dictionary. This is the unsigned and unformatted chain of trust artifact contents. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict: the unsignd and unformatted chain of trust artifact contents. Raises: ScriptWo...
[ "Generate", "the", "chain", "of", "trust", "dictionary", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/generate.py#L62-L92
train
28,055
mozilla-releng/scriptworker
scriptworker/cot/generate.py
generate_cot
def generate_cot(context, parent_path=None): """Format and sign the cot body, and write to disk. Args: context (scriptworker.context.Context): the scriptworker context. parent_path (str, optional): The directory to write the chain of trust artifacts to. If None, this is ``artifact_...
python
def generate_cot(context, parent_path=None): """Format and sign the cot body, and write to disk. Args: context (scriptworker.context.Context): the scriptworker context. parent_path (str, optional): The directory to write the chain of trust artifacts to. If None, this is ``artifact_...
[ "def", "generate_cot", "(", "context", ",", "parent_path", "=", "None", ")", ":", "body", "=", "generate_cot_body", "(", "context", ")", "schema", "=", "load_json_or_yaml", "(", "context", ".", "config", "[", "'cot_schema_path'", "]", ",", "is_path", "=", "T...
Format and sign the cot body, and write to disk. Args: context (scriptworker.context.Context): the scriptworker context. parent_path (str, optional): The directory to write the chain of trust artifacts to. If None, this is ``artifact_dir/public/``. Defaults to None. Re...
[ "Format", "and", "sign", "the", "cot", "body", "and", "write", "to", "disk", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/cot/generate.py#L96-L128
train
28,056
mozilla-releng/scriptworker
scriptworker/github.py
is_github_repo_owner_the_official_one
def is_github_repo_owner_the_official_one(context, repo_owner): """Given a repo_owner, check if it matches the one configured to be the official one. Args: context (scriptworker.context.Context): the scriptworker context. repo_owner (str): the repo_owner to verify Raises: scriptwor...
python
def is_github_repo_owner_the_official_one(context, repo_owner): """Given a repo_owner, check if it matches the one configured to be the official one. Args: context (scriptworker.context.Context): the scriptworker context. repo_owner (str): the repo_owner to verify Raises: scriptwor...
[ "def", "is_github_repo_owner_the_official_one", "(", "context", ",", "repo_owner", ")", ":", "official_repo_owner", "=", "context", ".", "config", "[", "'official_github_repos_owner'", "]", "if", "not", "official_repo_owner", ":", "raise", "ConfigError", "(", "'This wor...
Given a repo_owner, check if it matches the one configured to be the official one. Args: context (scriptworker.context.Context): the scriptworker context. repo_owner (str): the repo_owner to verify Raises: scriptworker.exceptions.ConfigError: when no official owner was defined Ret...
[ "Given", "a", "repo_owner", "check", "if", "it", "matches", "the", "one", "configured", "to", "be", "the", "official", "one", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/github.py#L215-L236
train
28,057
mozilla-releng/scriptworker
scriptworker/github.py
GitHubRepository.get_tag_hash
def get_tag_hash(self, tag_name): """Fetch the commit hash that was tagged with ``tag_name``. Args: tag_name (str): the name of the tag Returns: str: the commit hash linked by the tag """ tag_object = get_single_item_from_sequence( sequence=...
python
def get_tag_hash(self, tag_name): """Fetch the commit hash that was tagged with ``tag_name``. Args: tag_name (str): the name of the tag Returns: str: the commit hash linked by the tag """ tag_object = get_single_item_from_sequence( sequence=...
[ "def", "get_tag_hash", "(", "self", ",", "tag_name", ")", ":", "tag_object", "=", "get_single_item_from_sequence", "(", "sequence", "=", "self", ".", "_github_repository", ".", "tags", "(", ")", ",", "condition", "=", "lambda", "tag", ":", "tag", ".", "name"...
Fetch the commit hash that was tagged with ``tag_name``. Args: tag_name (str): the name of the tag Returns: str: the commit hash linked by the tag
[ "Fetch", "the", "commit", "hash", "that", "was", "tagged", "with", "tag_name", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/github.py#L80-L97
train
28,058
mozilla-releng/scriptworker
scriptworker/github.py
GitHubRepository.has_commit_landed_on_repository
async def has_commit_landed_on_repository(self, context, revision): """Tell if a commit was landed on the repository or if it just comes from a pull request. Args: context (scriptworker.context.Context): the scriptworker context. revision (str): the commit hash or the tag name. ...
python
async def has_commit_landed_on_repository(self, context, revision): """Tell if a commit was landed on the repository or if it just comes from a pull request. Args: context (scriptworker.context.Context): the scriptworker context. revision (str): the commit hash or the tag name. ...
[ "async", "def", "has_commit_landed_on_repository", "(", "self", ",", "context", ",", "revision", ")", ":", "# Revision may be a tag name. `branch_commits` doesn't work on tags", "if", "not", "_is_git_full_hash", "(", "revision", ")", ":", "revision", "=", "self", ".", "...
Tell if a commit was landed on the repository or if it just comes from a pull request. Args: context (scriptworker.context.Context): the scriptworker context. revision (str): the commit hash or the tag name. Returns: bool: True if the commit is present in one of the...
[ "Tell", "if", "a", "commit", "was", "landed", "on", "the", "repository", "or", "if", "it", "just", "comes", "from", "a", "pull", "request", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/github.py#L99-L122
train
28,059
mozilla-releng/scriptworker
scriptworker/log.py
update_logging_config
def update_logging_config(context, log_name=None, file_name='worker.log'): """Update python logging settings from config. By default, this sets the ``scriptworker`` log settings, but this will change if some other package calls this function or specifies the ``log_name``. * Use formatting from config ...
python
def update_logging_config(context, log_name=None, file_name='worker.log'): """Update python logging settings from config. By default, this sets the ``scriptworker`` log settings, but this will change if some other package calls this function or specifies the ``log_name``. * Use formatting from config ...
[ "def", "update_logging_config", "(", "context", ",", "log_name", "=", "None", ",", "file_name", "=", "'worker.log'", ")", ":", "log_name", "=", "log_name", "or", "__name__", ".", "split", "(", "'.'", ")", "[", "0", "]", "top_level_logger", "=", "logging", ...
Update python logging settings from config. By default, this sets the ``scriptworker`` log settings, but this will change if some other package calls this function or specifies the ``log_name``. * Use formatting from config settings. * Log to screen if ``verbose`` * Add a rotating logfile from con...
[ "Update", "python", "logging", "settings", "from", "config", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/log.py#L19-L64
train
28,060
mozilla-releng/scriptworker
scriptworker/log.py
pipe_to_log
async def pipe_to_log(pipe, filehandles=(), level=logging.INFO): """Log from a subprocess PIPE. Args: pipe (filehandle): subprocess process STDOUT or STDERR filehandles (list of filehandles, optional): the filehandle(s) to write to. If empty, don't write to a separate file. Defaul...
python
async def pipe_to_log(pipe, filehandles=(), level=logging.INFO): """Log from a subprocess PIPE. Args: pipe (filehandle): subprocess process STDOUT or STDERR filehandles (list of filehandles, optional): the filehandle(s) to write to. If empty, don't write to a separate file. Defaul...
[ "async", "def", "pipe_to_log", "(", "pipe", ",", "filehandles", "=", "(", ")", ",", "level", "=", "logging", ".", "INFO", ")", ":", "while", "True", ":", "line", "=", "await", "pipe", ".", "readline", "(", ")", "if", "line", ":", "line", "=", "to_u...
Log from a subprocess PIPE. Args: pipe (filehandle): subprocess process STDOUT or STDERR filehandles (list of filehandles, optional): the filehandle(s) to write to. If empty, don't write to a separate file. Defaults to (). level (int, optional): the level to log to. Defaults ...
[ "Log", "from", "a", "subprocess", "PIPE", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/log.py#L67-L85
train
28,061
mozilla-releng/scriptworker
scriptworker/log.py
get_log_filehandle
def get_log_filehandle(context): """Open the log and error filehandles. Args: context (scriptworker.context.Context): the scriptworker context. Yields: log filehandle """ log_file_name = get_log_filename(context) makedirs(context.config['task_log_dir']) with open(log_file_...
python
def get_log_filehandle(context): """Open the log and error filehandles. Args: context (scriptworker.context.Context): the scriptworker context. Yields: log filehandle """ log_file_name = get_log_filename(context) makedirs(context.config['task_log_dir']) with open(log_file_...
[ "def", "get_log_filehandle", "(", "context", ")", ":", "log_file_name", "=", "get_log_filename", "(", "context", ")", "makedirs", "(", "context", ".", "config", "[", "'task_log_dir'", "]", ")", "with", "open", "(", "log_file_name", ",", "\"w\"", ",", "encoding...
Open the log and error filehandles. Args: context (scriptworker.context.Context): the scriptworker context. Yields: log filehandle
[ "Open", "the", "log", "and", "error", "filehandles", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/log.py#L103-L116
train
28,062
mozilla-releng/scriptworker
scriptworker/log.py
contextual_log_handler
def contextual_log_handler(context, path, log_obj=None, level=logging.DEBUG, formatter=None): """Add a short-lived log with a contextmanager for cleanup. Args: context (scriptworker.context.Context): the scriptworker context path (str): the path to the log file to cre...
python
def contextual_log_handler(context, path, log_obj=None, level=logging.DEBUG, formatter=None): """Add a short-lived log with a contextmanager for cleanup. Args: context (scriptworker.context.Context): the scriptworker context path (str): the path to the log file to cre...
[ "def", "contextual_log_handler", "(", "context", ",", "path", ",", "log_obj", "=", "None", ",", "level", "=", "logging", ".", "DEBUG", ",", "formatter", "=", "None", ")", ":", "log_obj", "=", "log_obj", "or", "log", "formatter", "=", "formatter", "or", "...
Add a short-lived log with a contextmanager for cleanup. Args: context (scriptworker.context.Context): the scriptworker context path (str): the path to the log file to create log_obj (logging.Logger): the log object to modify. If None, use ``scriptworker.log.log``. Defaults to...
[ "Add", "a", "short", "-", "lived", "log", "with", "a", "contextmanager", "for", "cleanup", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/log.py#L120-L150
train
28,063
mozilla-releng/scriptworker
scriptworker/artifacts.py
upload_artifacts
async def upload_artifacts(context, files): """Compress and upload the requested files from ``artifact_dir``, preserving relative paths. Compression only occurs with files known to be supported. This function expects the directory structure in ``artifact_dir`` to remain the same. So if we want the fi...
python
async def upload_artifacts(context, files): """Compress and upload the requested files from ``artifact_dir``, preserving relative paths. Compression only occurs with files known to be supported. This function expects the directory structure in ``artifact_dir`` to remain the same. So if we want the fi...
[ "async", "def", "upload_artifacts", "(", "context", ",", "files", ")", ":", "def", "to_upload_future", "(", "target_path", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "context", ".", "config", "[", "'artifact_dir'", "]", ",", "target_path",...
Compress and upload the requested files from ``artifact_dir``, preserving relative paths. Compression only occurs with files known to be supported. This function expects the directory structure in ``artifact_dir`` to remain the same. So if we want the files in ``public/...``, create an ``artifact_dir...
[ "Compress", "and", "upload", "the", "requested", "files", "from", "artifact_dir", "preserving", "relative", "paths", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L48-L77
train
28,064
mozilla-releng/scriptworker
scriptworker/artifacts.py
compress_artifact_if_supported
def compress_artifact_if_supported(artifact_path): """Compress artifacts with GZip if they're known to be supported. This replaces the artifact given by a gzip binary. Args: artifact_path (str): the path to compress Returns: content_type, content_encoding (tuple): Type and encoding o...
python
def compress_artifact_if_supported(artifact_path): """Compress artifacts with GZip if they're known to be supported. This replaces the artifact given by a gzip binary. Args: artifact_path (str): the path to compress Returns: content_type, content_encoding (tuple): Type and encoding o...
[ "def", "compress_artifact_if_supported", "(", "artifact_path", ")", ":", "content_type", ",", "encoding", "=", "guess_content_type_and_encoding", "(", "artifact_path", ")", "log", ".", "debug", "(", "'\"{}\" is encoded with \"{}\" and has mime/type \"{}\"'", ".", "format", ...
Compress artifacts with GZip if they're known to be supported. This replaces the artifact given by a gzip binary. Args: artifact_path (str): the path to compress Returns: content_type, content_encoding (tuple): Type and encoding of the file. Encoding equals 'gzip' if compressed.
[ "Compress", "artifacts", "with", "GZip", "if", "they", "re", "known", "to", "be", "supported", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L80-L108
train
28,065
mozilla-releng/scriptworker
scriptworker/artifacts.py
guess_content_type_and_encoding
def guess_content_type_and_encoding(path): """Guess the content type of a path, using ``mimetypes``. Falls back to "application/binary" if no content type is found. Args: path (str): the path to guess the mimetype of Returns: str: the content type of the file """ for ext, con...
python
def guess_content_type_and_encoding(path): """Guess the content type of a path, using ``mimetypes``. Falls back to "application/binary" if no content type is found. Args: path (str): the path to guess the mimetype of Returns: str: the content type of the file """ for ext, con...
[ "def", "guess_content_type_and_encoding", "(", "path", ")", ":", "for", "ext", ",", "content_type", "in", "_EXTENSION_TO_MIME_TYPE", ".", "items", "(", ")", ":", "if", "path", ".", "endswith", "(", "ext", ")", ":", "return", "content_type", "content_type", ","...
Guess the content type of a path, using ``mimetypes``. Falls back to "application/binary" if no content type is found. Args: path (str): the path to guess the mimetype of Returns: str: the content type of the file
[ "Guess", "the", "content", "type", "of", "a", "path", "using", "mimetypes", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L111-L129
train
28,066
mozilla-releng/scriptworker
scriptworker/artifacts.py
create_artifact
async def create_artifact(context, path, target_path, content_type, content_encoding, storage_type='s3', expires=None): """Create an artifact and upload it. This should support s3 and azure out of the box; we'll need some tweaking if we want to support redirect/error artifacts. Args: context (...
python
async def create_artifact(context, path, target_path, content_type, content_encoding, storage_type='s3', expires=None): """Create an artifact and upload it. This should support s3 and azure out of the box; we'll need some tweaking if we want to support redirect/error artifacts. Args: context (...
[ "async", "def", "create_artifact", "(", "context", ",", "path", ",", "target_path", ",", "content_type", ",", "content_encoding", ",", "storage_type", "=", "'s3'", ",", "expires", "=", "None", ")", ":", "payload", "=", "{", "\"storageType\"", ":", "storage_typ...
Create an artifact and upload it. This should support s3 and azure out of the box; we'll need some tweaking if we want to support redirect/error artifacts. Args: context (scriptworker.context.Context): the scriptworker context. path (str): the path of the file to upload. target_pat...
[ "Create", "an", "artifact", "and", "upload", "it", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L153-L200
train
28,067
mozilla-releng/scriptworker
scriptworker/artifacts.py
get_artifact_url
def get_artifact_url(context, task_id, path): """Get a TaskCluster artifact url. Args: context (scriptworker.context.Context): the scriptworker context task_id (str): the task id of the task that published the artifact path (str): the relative path of the artifact Returns: ...
python
def get_artifact_url(context, task_id, path): """Get a TaskCluster artifact url. Args: context (scriptworker.context.Context): the scriptworker context task_id (str): the task id of the task that published the artifact path (str): the relative path of the artifact Returns: ...
[ "def", "get_artifact_url", "(", "context", ",", "task_id", ",", "path", ")", ":", "if", "path", ".", "startswith", "(", "\"public/\"", ")", ":", "url", "=", "context", ".", "queue", ".", "buildUrl", "(", "'getLatestArtifact'", ",", "task_id", ",", "path", ...
Get a TaskCluster artifact url. Args: context (scriptworker.context.Context): the scriptworker context task_id (str): the task id of the task that published the artifact path (str): the relative path of the artifact Returns: str: the artifact url Raises: TaskCluste...
[ "Get", "a", "TaskCluster", "artifact", "url", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L216-L240
train
28,068
mozilla-releng/scriptworker
scriptworker/artifacts.py
download_artifacts
async def download_artifacts(context, file_urls, parent_dir=None, session=None, download_func=download_file, valid_artifact_task_ids=None): """Download artifacts in parallel after validating their URLs. Valid ``taskId``s for download include the task's dependencies and the ``ta...
python
async def download_artifacts(context, file_urls, parent_dir=None, session=None, download_func=download_file, valid_artifact_task_ids=None): """Download artifacts in parallel after validating their URLs. Valid ``taskId``s for download include the task's dependencies and the ``ta...
[ "async", "def", "download_artifacts", "(", "context", ",", "file_urls", ",", "parent_dir", "=", "None", ",", "session", "=", "None", ",", "download_func", "=", "download_file", ",", "valid_artifact_task_ids", "=", "None", ")", ":", "parent_dir", "=", "parent_dir...
Download artifacts in parallel after validating their URLs. Valid ``taskId``s for download include the task's dependencies and the ``taskGroupId``, which by convention is the ``taskId`` of the decision task. Args: context (scriptworker.context.Context): the scriptworker context. file_urls ...
[ "Download", "artifacts", "in", "parallel", "after", "validating", "their", "URLs", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L258-L309
train
28,069
mozilla-releng/scriptworker
scriptworker/artifacts.py
get_upstream_artifacts_full_paths_per_task_id
def get_upstream_artifacts_full_paths_per_task_id(context): """List the downloaded upstream artifacts. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict, dict: lists of the paths to upstream artifacts, sorted by task_id. First dict represents...
python
def get_upstream_artifacts_full_paths_per_task_id(context): """List the downloaded upstream artifacts. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict, dict: lists of the paths to upstream artifacts, sorted by task_id. First dict represents...
[ "def", "get_upstream_artifacts_full_paths_per_task_id", "(", "context", ")", ":", "upstream_artifacts", "=", "context", ".", "task", "[", "'payload'", "]", "[", "'upstreamArtifacts'", "]", "task_ids_and_relative_paths", "=", "[", "(", "artifact_definition", "[", "'taskI...
List the downloaded upstream artifacts. Args: context (scriptworker.context.Context): the scriptworker context. Returns: dict, dict: lists of the paths to upstream artifacts, sorted by task_id. First dict represents the existing upstream artifacts. The second one maps t...
[ "List", "the", "downloaded", "upstream", "artifacts", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L312-L355
train
28,070
mozilla-releng/scriptworker
scriptworker/artifacts.py
get_and_check_single_upstream_artifact_full_path
def get_and_check_single_upstream_artifact_full_path(context, task_id, path): """Return the full path where an upstream artifact is located on disk. Args: context (scriptworker.context.Context): the scriptworker context. task_id (str): the task id of the task that published the artifact ...
python
def get_and_check_single_upstream_artifact_full_path(context, task_id, path): """Return the full path where an upstream artifact is located on disk. Args: context (scriptworker.context.Context): the scriptworker context. task_id (str): the task id of the task that published the artifact ...
[ "def", "get_and_check_single_upstream_artifact_full_path", "(", "context", ",", "task_id", ",", "path", ")", ":", "abs_path", "=", "get_single_upstream_artifact_full_path", "(", "context", ",", "task_id", ",", "path", ")", "if", "not", "os", ".", "path", ".", "exi...
Return the full path where an upstream artifact is located on disk. Args: context (scriptworker.context.Context): the scriptworker context. task_id (str): the task id of the task that published the artifact path (str): the relative path of the artifact Returns: str: absolute pa...
[ "Return", "the", "full", "path", "where", "an", "upstream", "artifact", "is", "located", "on", "disk", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L358-L379
train
28,071
mozilla-releng/scriptworker
scriptworker/artifacts.py
get_single_upstream_artifact_full_path
def get_single_upstream_artifact_full_path(context, task_id, path): """Return the full path where an upstream artifact should be located. Artifact may not exist. If you want to be sure if does, use ``get_and_check_single_upstream_artifact_full_path()`` instead. This function is mainly used to move art...
python
def get_single_upstream_artifact_full_path(context, task_id, path): """Return the full path where an upstream artifact should be located. Artifact may not exist. If you want to be sure if does, use ``get_and_check_single_upstream_artifact_full_path()`` instead. This function is mainly used to move art...
[ "def", "get_single_upstream_artifact_full_path", "(", "context", ",", "task_id", ",", "path", ")", ":", "return", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "context", ".", "config", "[", "'work_dir'", "]", ",", "'cot'", ...
Return the full path where an upstream artifact should be located. Artifact may not exist. If you want to be sure if does, use ``get_and_check_single_upstream_artifact_full_path()`` instead. This function is mainly used to move artifacts to the expected location. Args: context (scriptworker.c...
[ "Return", "the", "full", "path", "where", "an", "upstream", "artifact", "should", "be", "located", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L382-L399
train
28,072
mozilla-releng/scriptworker
scriptworker/artifacts.py
get_optional_artifacts_per_task_id
def get_optional_artifacts_per_task_id(upstream_artifacts): """Return every optional artifact defined in ``upstream_artifacts``, ordered by taskId. Args: upstream_artifacts: the list of upstream artifact definitions Returns: dict: list of paths to downloaded artifacts ordered by taskId ...
python
def get_optional_artifacts_per_task_id(upstream_artifacts): """Return every optional artifact defined in ``upstream_artifacts``, ordered by taskId. Args: upstream_artifacts: the list of upstream artifact definitions Returns: dict: list of paths to downloaded artifacts ordered by taskId ...
[ "def", "get_optional_artifacts_per_task_id", "(", "upstream_artifacts", ")", ":", "# A given taskId might be defined many times in upstreamArtifacts. Thus, we can't", "# use a dict comprehension", "optional_artifacts_per_task_id", "=", "{", "}", "for", "artifact_definition", "in", "ups...
Return every optional artifact defined in ``upstream_artifacts``, ordered by taskId. Args: upstream_artifacts: the list of upstream artifact definitions Returns: dict: list of paths to downloaded artifacts ordered by taskId
[ "Return", "every", "optional", "artifact", "defined", "in", "upstream_artifacts", "ordered", "by", "taskId", "." ]
8e97bbd83b9b578565ec57904c966dd6ae4ef0ae
https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/artifacts.py#L402-L426
train
28,073
datamachine/twx.botapi
twx/botapi/botapi.py
set_chat_description
def set_chat_description(chat_id, description, **kwargs): """ Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. :param chat_id: Unique identifier for ...
python
def set_chat_description(chat_id, description, **kwargs): """ Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. :param chat_id: Unique identifier for ...
[ "def", "set_chat_description", "(", "chat_id", ",", "description", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "description", ")", ">", "255", ":", "raise", "ValueError", "(", "\"Chat description must be less than 255 characters.\"", ")", "# required args",...
Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @chan...
[ "Use", "this", "method", "to", "change", "the", "description", "of", "a", "supergroup", "or", "a", "channel", ".", "The", "bot", "must", "be", "an", "administrator", "in", "the", "chat", "for", "this", "to", "work", "and", "must", "have", "the", "appropr...
c85184da738169e8f9d6d8e62970540f427c486e
https://github.com/datamachine/twx.botapi/blob/c85184da738169e8f9d6d8e62970540f427c486e/twx/botapi/botapi.py#L2379-L2400
train
28,074
datamachine/twx.botapi
twx/botapi/botapi.py
send_audio
def send_audio(chat_id, audio, caption=None, duration=None, performer=None, title=None, reply_to_message_id=None, reply_markup=None, disable_notification=False, parse_mode=None, **kwargs): """ Use this method to send audio files, if you want Telegram clients to display them in the ...
python
def send_audio(chat_id, audio, caption=None, duration=None, performer=None, title=None, reply_to_message_id=None, reply_markup=None, disable_notification=False, parse_mode=None, **kwargs): """ Use this method to send audio files, if you want Telegram clients to display them in the ...
[ "def", "send_audio", "(", "chat_id", ",", "audio", ",", "caption", "=", "None", ",", "duration", "=", "None", ",", "performer", "=", "None", ",", "title", "=", "None", ",", "reply_to_message_id", "=", "None", ",", "reply_markup", "=", "None", ",", "disab...
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. For backward compatib...
[ "Use", "this", "method", "to", "send", "audio", "files", "if", "you", "want", "Telegram", "clients", "to", "display", "them", "in", "the", "music", "player", "." ]
c85184da738169e8f9d6d8e62970540f427c486e
https://github.com/datamachine/twx.botapi/blob/c85184da738169e8f9d6d8e62970540f427c486e/twx/botapi/botapi.py#L2599-L2668
train
28,075
datamachine/twx.botapi
twx/botapi/botapi.py
unban_chat_member
def unban_chat_member(chat_id, user_id, **kwargs): """ Use this method to unban a previously kicked user in a supergroup. The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work :param chat_id: Unique id...
python
def unban_chat_member(chat_id, user_id, **kwargs): """ Use this method to unban a previously kicked user in a supergroup. The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work :param chat_id: Unique id...
[ "def", "unban_chat_member", "(", "chat_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "# required args", "params", "=", "dict", "(", "chat_id", "=", "chat_id", ",", "user_id", "=", "user_id", ",", ")", "return", "TelegramBotRPCRequest", "(", "'unban...
Use this method to unban a previously kicked user in a supergroup. The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work :param chat_id: Unique identifier for the target chat or username of the target channel ...
[ "Use", "this", "method", "to", "unban", "a", "previously", "kicked", "user", "in", "a", "supergroup", ".", "The", "user", "will", "not", "return", "to", "the", "group", "automatically", "but", "will", "be", "able", "to", "join", "via", "link", "etc", "."...
c85184da738169e8f9d6d8e62970540f427c486e
https://github.com/datamachine/twx.botapi/blob/c85184da738169e8f9d6d8e62970540f427c486e/twx/botapi/botapi.py#L3442-L3464
train
28,076
datamachine/twx.botapi
twx/botapi/botapi.py
get_chat_member
def get_chat_member(chat_id, user_id, **kwargs): """ Use this method to get information about a member of a chat :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param user_id: Unique identifier of the target user :param kwarg...
python
def get_chat_member(chat_id, user_id, **kwargs): """ Use this method to get information about a member of a chat :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param user_id: Unique identifier of the target user :param kwarg...
[ "def", "get_chat_member", "(", "chat_id", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "# required args", "params", "=", "dict", "(", "chat_id", "=", "chat_id", ",", "user_id", "=", "user_id", ",", ")", "return", "TelegramBotRPCRequest", "(", "'getChat...
Use this method to get information about a member of a chat :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :param user_id: Unique identifier of the target user :param kwargs: Args that get passed down to :class:`TelegramBotRPCRequest...
[ "Use", "this", "method", "to", "get", "information", "about", "a", "member", "of", "a", "chat" ]
c85184da738169e8f9d6d8e62970540f427c486e
https://github.com/datamachine/twx.botapi/blob/c85184da738169e8f9d6d8e62970540f427c486e/twx/botapi/botapi.py#L3535-L3556
train
28,077
datamachine/twx.botapi
twx/botapi/botapi.py
get_file
def get_file(file_id, **kwargs): """ Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>...
python
def get_file(file_id, **kwargs): """ Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>...
[ "def", "get_file", "(", "file_id", ",", "*", "*", "kwargs", ")", ":", "# required args", "params", "=", "dict", "(", "file_id", "=", "file_id", ")", "return", "TelegramBotRPCRequest", "(", "'getFile'", ",", "params", "=", "params", ",", "on_result", "=", "...
Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken ...
[ "Use", "this", "method", "to", "get", "basic", "info", "about", "a", "file", "and", "prepare", "it", "for", "downloading", "." ]
c85184da738169e8f9d6d8e62970540f427c486e
https://github.com/datamachine/twx.botapi/blob/c85184da738169e8f9d6d8e62970540f427c486e/twx/botapi/botapi.py#L3941-L3961
train
28,078
datamachine/twx.botapi
twx/botapi/botapi.py
get_updates
def get_updates(offset=None, limit=None, timeout=None, allowed_updates=None, **kwargs): """ Use this method to receive incoming updates using long polling. .. note:: 1. This method will not work if an outgoing webhook is set up. 2. In order to avoid getting duplicate update...
python
def get_updates(offset=None, limit=None, timeout=None, allowed_updates=None, **kwargs): """ Use this method to receive incoming updates using long polling. .. note:: 1. This method will not work if an outgoing webhook is set up. 2. In order to avoid getting duplicate update...
[ "def", "get_updates", "(", "offset", "=", "None", ",", "limit", "=", "None", ",", "timeout", "=", "None", ",", "allowed_updates", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# optional parameters", "params", "=", "_clean_params", "(", "offset", "=", ...
Use this method to receive incoming updates using long polling. .. note:: 1. This method will not work if an outgoing webhook is set up. 2. In order to avoid getting duplicate updates, recalculate offset after each server response. :param allowed_updates: List the types of updates you want yo...
[ "Use", "this", "method", "to", "receive", "incoming", "updates", "using", "long", "polling", "." ]
c85184da738169e8f9d6d8e62970540f427c486e
https://github.com/datamachine/twx.botapi/blob/c85184da738169e8f9d6d8e62970540f427c486e/twx/botapi/botapi.py#L4097-L4142
train
28,079
nats-io/asyncio-nats-streaming
stan/aio/client.py
Client.connect
async def connect(self, cluster_id, client_id, nats=None, connect_timeout=DEFAULT_CONNECT_TIMEOUT, max_pub_acks_inflight=DEFAULT_MAX_PUB_ACKS_INFLIGHT, loop=None, ): """ Starts a session with a ...
python
async def connect(self, cluster_id, client_id, nats=None, connect_timeout=DEFAULT_CONNECT_TIMEOUT, max_pub_acks_inflight=DEFAULT_MAX_PUB_ACKS_INFLIGHT, loop=None, ): """ Starts a session with a ...
[ "async", "def", "connect", "(", "self", ",", "cluster_id", ",", "client_id", ",", "nats", "=", "None", ",", "connect_timeout", "=", "DEFAULT_CONNECT_TIMEOUT", ",", "max_pub_acks_inflight", "=", "DEFAULT_MAX_PUB_ACKS_INFLIGHT", ",", "loop", "=", "None", ",", ")", ...
Starts a session with a NATS Streaming cluster. :param cluster: Name of the cluster to which we will connect. :param nats: NATS connection to be borrowed for NATS Streaming.
[ "Starts", "a", "session", "with", "a", "NATS", "Streaming", "cluster", "." ]
344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5
https://github.com/nats-io/asyncio-nats-streaming/blob/344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5/stan/aio/client.py#L85-L162
train
28,080
nats-io/asyncio-nats-streaming
stan/aio/client.py
Client._process_ack
async def _process_ack(self, msg): """ Receives acks from the publishes via the _STAN.acks subscription. """ pub_ack = protocol.PubAck() pub_ack.ParseFromString(msg.data) # Unblock pending acks queue if required. if not self._pending_pub_acks_queue.empty(): ...
python
async def _process_ack(self, msg): """ Receives acks from the publishes via the _STAN.acks subscription. """ pub_ack = protocol.PubAck() pub_ack.ParseFromString(msg.data) # Unblock pending acks queue if required. if not self._pending_pub_acks_queue.empty(): ...
[ "async", "def", "_process_ack", "(", "self", ",", "msg", ")", ":", "pub_ack", "=", "protocol", ".", "PubAck", "(", ")", "pub_ack", ".", "ParseFromString", "(", "msg", ".", "data", ")", "# Unblock pending acks queue if required.", "if", "not", "self", ".", "_...
Receives acks from the publishes via the _STAN.acks subscription.
[ "Receives", "acks", "from", "the", "publishes", "via", "the", "_STAN", ".", "acks", "subscription", "." ]
344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5
https://github.com/nats-io/asyncio-nats-streaming/blob/344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5/stan/aio/client.py#L170-L190
train
28,081
nats-io/asyncio-nats-streaming
stan/aio/client.py
Client._process_msg
async def _process_msg(self, sub): """ Receives the msgs from the STAN subscriptions and replies. By default it will reply back with an ack unless manual acking was specified in one of the subscription options. """ while True: try: raw_msg = aw...
python
async def _process_msg(self, sub): """ Receives the msgs from the STAN subscriptions and replies. By default it will reply back with an ack unless manual acking was specified in one of the subscription options. """ while True: try: raw_msg = aw...
[ "async", "def", "_process_msg", "(", "self", ",", "sub", ")", ":", "while", "True", ":", "try", ":", "raw_msg", "=", "await", "sub", ".", "_msgs_queue", ".", "get", "(", ")", "msg", "=", "Msg", "(", ")", "msg_proto", "=", "protocol", ".", "MsgProto",...
Receives the msgs from the STAN subscriptions and replies. By default it will reply back with an ack unless manual acking was specified in one of the subscription options.
[ "Receives", "the", "msgs", "from", "the", "STAN", "subscriptions", "and", "replies", ".", "By", "default", "it", "will", "reply", "back", "with", "an", "ack", "unless", "manual", "acking", "was", "specified", "in", "one", "of", "the", "subscription", "option...
344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5
https://github.com/nats-io/asyncio-nats-streaming/blob/344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5/stan/aio/client.py#L192-L228
train
28,082
nats-io/asyncio-nats-streaming
stan/aio/client.py
Client.ack
async def ack(self, msg): """ Used to manually acks a message. :param msg: Message which is pending to be acked by client. """ ack_proto = protocol.Ack() ack_proto.subject = msg.proto.subject ack_proto.sequence = msg.proto.sequence await self._nc.publish(...
python
async def ack(self, msg): """ Used to manually acks a message. :param msg: Message which is pending to be acked by client. """ ack_proto = protocol.Ack() ack_proto.subject = msg.proto.subject ack_proto.sequence = msg.proto.sequence await self._nc.publish(...
[ "async", "def", "ack", "(", "self", ",", "msg", ")", ":", "ack_proto", "=", "protocol", ".", "Ack", "(", ")", "ack_proto", ".", "subject", "=", "msg", ".", "proto", ".", "subject", "ack_proto", ".", "sequence", "=", "msg", ".", "proto", ".", "sequenc...
Used to manually acks a message. :param msg: Message which is pending to be acked by client.
[ "Used", "to", "manually", "acks", "a", "message", "." ]
344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5
https://github.com/nats-io/asyncio-nats-streaming/blob/344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5/stan/aio/client.py#L230-L239
train
28,083
nats-io/asyncio-nats-streaming
stan/aio/client.py
Client.publish
async def publish(self, subject, payload, ack_handler=None, ack_wait=DEFAULT_ACK_WAIT, ): """ Publishes a payload onto a subject. By default, it will block until the message which has been published has been acked back. A...
python
async def publish(self, subject, payload, ack_handler=None, ack_wait=DEFAULT_ACK_WAIT, ): """ Publishes a payload onto a subject. By default, it will block until the message which has been published has been acked back. A...
[ "async", "def", "publish", "(", "self", ",", "subject", ",", "payload", ",", "ack_handler", "=", "None", ",", "ack_wait", "=", "DEFAULT_ACK_WAIT", ",", ")", ":", "stan_subject", "=", "''", ".", "join", "(", "[", "self", ".", "_pub_prefix", ",", "'.'", ...
Publishes a payload onto a subject. By default, it will block until the message which has been published has been acked back. An optional async handler can be publi :param subject: Subject of the message. :param payload: Payload of the message which wil be published. :param ack...
[ "Publishes", "a", "payload", "onto", "a", "subject", ".", "By", "default", "it", "will", "block", "until", "the", "message", "which", "has", "been", "published", "has", "been", "acked", "back", ".", "An", "optional", "async", "handler", "can", "be", "publi...
344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5
https://github.com/nats-io/asyncio-nats-streaming/blob/344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5/stan/aio/client.py#L241-L300
train
28,084
nats-io/asyncio-nats-streaming
stan/aio/client.py
Client._close
async def _close(self): """ Removes any present internal state from the client. """ # Remove the core NATS Streaming subscriptions. try: if self._hb_inbox_sid is not None: await self._nc.unsubscribe(self._hb_inbox_sid) self._hb_inbox =...
python
async def _close(self): """ Removes any present internal state from the client. """ # Remove the core NATS Streaming subscriptions. try: if self._hb_inbox_sid is not None: await self._nc.unsubscribe(self._hb_inbox_sid) self._hb_inbox =...
[ "async", "def", "_close", "(", "self", ")", ":", "# Remove the core NATS Streaming subscriptions.", "try", ":", "if", "self", ".", "_hb_inbox_sid", "is", "not", "None", ":", "await", "self", ".", "_nc", ".", "unsubscribe", "(", "self", ".", "_hb_inbox_sid", ")...
Removes any present internal state from the client.
[ "Removes", "any", "present", "internal", "state", "from", "the", "client", "." ]
344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5
https://github.com/nats-io/asyncio-nats-streaming/blob/344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5/stan/aio/client.py#L425-L452
train
28,085
nats-io/asyncio-nats-streaming
stan/aio/client.py
Client.close
async def close(self): """ Close terminates a session with NATS Streaming. """ # Remove the core NATS Streaming subscriptions. await self._close() req = protocol.CloseRequest() req.clientID = self._client_id msg = await self._nc.request( self...
python
async def close(self): """ Close terminates a session with NATS Streaming. """ # Remove the core NATS Streaming subscriptions. await self._close() req = protocol.CloseRequest() req.clientID = self._client_id msg = await self._nc.request( self...
[ "async", "def", "close", "(", "self", ")", ":", "# Remove the core NATS Streaming subscriptions.", "await", "self", ".", "_close", "(", ")", "req", "=", "protocol", ".", "CloseRequest", "(", ")", "req", ".", "clientID", "=", "self", ".", "_client_id", "msg", ...
Close terminates a session with NATS Streaming.
[ "Close", "terminates", "a", "session", "with", "NATS", "Streaming", "." ]
344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5
https://github.com/nats-io/asyncio-nats-streaming/blob/344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5/stan/aio/client.py#L454-L473
train
28,086
nats-io/asyncio-nats-streaming
stan/aio/client.py
Subscription.unsubscribe
async def unsubscribe(self): """ Remove subscription on a topic in this client. """ await self._nc.unsubscribe(self.sid) try: # Stop the processing task for the subscription. sub = self._sc._sub_map[self.inbox] sub._msgs_task.cancel() ...
python
async def unsubscribe(self): """ Remove subscription on a topic in this client. """ await self._nc.unsubscribe(self.sid) try: # Stop the processing task for the subscription. sub = self._sc._sub_map[self.inbox] sub._msgs_task.cancel() ...
[ "async", "def", "unsubscribe", "(", "self", ")", ":", "await", "self", ".", "_nc", ".", "unsubscribe", "(", "self", ".", "sid", ")", "try", ":", "# Stop the processing task for the subscription.", "sub", "=", "self", ".", "_sc", ".", "_sub_map", "[", "self",...
Remove subscription on a topic in this client.
[ "Remove", "subscription", "on", "a", "topic", "in", "this", "client", "." ]
344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5
https://github.com/nats-io/asyncio-nats-streaming/blob/344d28f645e6dd0e0b7938516b83e2e6f3c3c9f5/stan/aio/client.py#L508-L539
train
28,087
django-ldapdb/django-ldapdb
ldapdb/models/fields.py
datetime_from_ldap
def datetime_from_ldap(value): """Convert a LDAP-style datetime to a Python aware object. See https://tools.ietf.org/html/rfc4517#section-3.3.13 for details. Args: value (str): the datetime to parse """ if not value: return None match = LDAP_DATETIME_RE.match(value) if not ...
python
def datetime_from_ldap(value): """Convert a LDAP-style datetime to a Python aware object. See https://tools.ietf.org/html/rfc4517#section-3.3.13 for details. Args: value (str): the datetime to parse """ if not value: return None match = LDAP_DATETIME_RE.match(value) if not ...
[ "def", "datetime_from_ldap", "(", "value", ")", ":", "if", "not", "value", ":", "return", "None", "match", "=", "LDAP_DATETIME_RE", ".", "match", "(", "value", ")", "if", "not", "match", ":", "return", "None", "groups", "=", "match", ".", "groupdict", "(...
Convert a LDAP-style datetime to a Python aware object. See https://tools.ietf.org/html/rfc4517#section-3.3.13 for details. Args: value (str): the datetime to parse
[ "Convert", "a", "LDAP", "-", "style", "datetime", "to", "a", "Python", "aware", "object", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/models/fields.py#L293-L320
train
28,088
django-ldapdb/django-ldapdb
ldapdb/models/fields.py
LdapFieldMixin.get_db_prep_value
def get_db_prep_value(self, value, connection, prepared=False): """Prepare a value for DB interaction. Returns: - list(bytes) if not prepared - list(str) if prepared """ if prepared: return value if value is None: return [] value...
python
def get_db_prep_value(self, value, connection, prepared=False): """Prepare a value for DB interaction. Returns: - list(bytes) if not prepared - list(str) if prepared """ if prepared: return value if value is None: return [] value...
[ "def", "get_db_prep_value", "(", "self", ",", "value", ",", "connection", ",", "prepared", "=", "False", ")", ":", "if", "prepared", ":", "return", "value", "if", "value", "is", "None", ":", "return", "[", "]", "values", "=", "value", "if", "self", "."...
Prepare a value for DB interaction. Returns: - list(bytes) if not prepared - list(str) if prepared
[ "Prepare", "a", "value", "for", "DB", "interaction", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/models/fields.py#L113-L134
train
28,089
django-ldapdb/django-ldapdb
ldapdb/models/base.py
Model.build_rdn
def build_rdn(self): """ Build the Relative Distinguished Name for this entry. """ bits = [] for field in self._meta.fields: if field.db_column and field.primary_key: bits.append("%s=%s" % (field.db_column, getatt...
python
def build_rdn(self): """ Build the Relative Distinguished Name for this entry. """ bits = [] for field in self._meta.fields: if field.db_column and field.primary_key: bits.append("%s=%s" % (field.db_column, getatt...
[ "def", "build_rdn", "(", "self", ")", ":", "bits", "=", "[", "]", "for", "field", "in", "self", ".", "_meta", ".", "fields", ":", "if", "field", ".", "db_column", "and", "field", ".", "primary_key", ":", "bits", ".", "append", "(", "\"%s=%s\"", "%", ...
Build the Relative Distinguished Name for this entry.
[ "Build", "the", "Relative", "Distinguished", "Name", "for", "this", "entry", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/models/base.py#L34-L45
train
28,090
django-ldapdb/django-ldapdb
ldapdb/models/base.py
Model.delete
def delete(self, using=None): """ Delete this entry. """ using = using or router.db_for_write(self.__class__, instance=self) connection = connections[using] logger.debug("Deleting LDAP entry %s" % self.dn) connection.delete_s(self.dn) signals.post_delete.s...
python
def delete(self, using=None): """ Delete this entry. """ using = using or router.db_for_write(self.__class__, instance=self) connection = connections[using] logger.debug("Deleting LDAP entry %s" % self.dn) connection.delete_s(self.dn) signals.post_delete.s...
[ "def", "delete", "(", "self", ",", "using", "=", "None", ")", ":", "using", "=", "using", "or", "router", ".", "db_for_write", "(", "self", ".", "__class__", ",", "instance", "=", "self", ")", "connection", "=", "connections", "[", "using", "]", "logge...
Delete this entry.
[ "Delete", "this", "entry", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/models/base.py#L53-L61
train
28,091
django-ldapdb/django-ldapdb
ldapdb/models/base.py
Model._save_table
def _save_table(self, raw=False, cls=None, force_insert=None, force_update=None, using=None, update_fields=None): """ Saves the current instance. """ # Connection aliasing connection = connections[using] create = bool(force_insert or not self.dn) # Prepare field...
python
def _save_table(self, raw=False, cls=None, force_insert=None, force_update=None, using=None, update_fields=None): """ Saves the current instance. """ # Connection aliasing connection = connections[using] create = bool(force_insert or not self.dn) # Prepare field...
[ "def", "_save_table", "(", "self", ",", "raw", "=", "False", ",", "cls", "=", "None", ",", "force_insert", "=", "None", ",", "force_update", "=", "None", ",", "using", "=", "None", ",", "update_fields", "=", "None", ")", ":", "# Connection aliasing", "co...
Saves the current instance.
[ "Saves", "the", "current", "instance", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/models/base.py#L63-L148
train
28,092
django-ldapdb/django-ldapdb
ldapdb/models/base.py
Model.scoped
def scoped(base_class, base_dn): """ Returns a copy of the current class with a different base_dn. """ class Meta: proxy = True verbose_name = base_class._meta.verbose_name verbose_name_plural = base_class._meta.verbose_name_plural import re ...
python
def scoped(base_class, base_dn): """ Returns a copy of the current class with a different base_dn. """ class Meta: proxy = True verbose_name = base_class._meta.verbose_name verbose_name_plural = base_class._meta.verbose_name_plural import re ...
[ "def", "scoped", "(", "base_class", ",", "base_dn", ")", ":", "class", "Meta", ":", "proxy", "=", "True", "verbose_name", "=", "base_class", ".", "_meta", ".", "verbose_name", "verbose_name_plural", "=", "base_class", ".", "_meta", ".", "verbose_name_plural", ...
Returns a copy of the current class with a different base_dn.
[ "Returns", "a", "copy", "of", "the", "current", "class", "with", "a", "different", "base_dn", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/models/base.py#L151-L165
train
28,093
django-ldapdb/django-ldapdb
ldapdb/backends/ldap/base.py
DatabaseWrapper.get_connection_params
def get_connection_params(self): """Compute appropriate parameters for establishing a new connection. Computed at system startup. """ return { 'uri': self.settings_dict['NAME'], 'tls': self.settings_dict.get('TLS', False), 'bind_dn': self.settings_dic...
python
def get_connection_params(self): """Compute appropriate parameters for establishing a new connection. Computed at system startup. """ return { 'uri': self.settings_dict['NAME'], 'tls': self.settings_dict.get('TLS', False), 'bind_dn': self.settings_dic...
[ "def", "get_connection_params", "(", "self", ")", ":", "return", "{", "'uri'", ":", "self", ".", "settings_dict", "[", "'NAME'", "]", ",", "'tls'", ":", "self", ".", "settings_dict", ".", "get", "(", "'TLS'", ",", "False", ")", ",", "'bind_dn'", ":", "...
Compute appropriate parameters for establishing a new connection. Computed at system startup.
[ "Compute", "appropriate", "parameters", "for", "establishing", "a", "new", "connection", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/backends/ldap/base.py#L220-L236
train
28,094
django-ldapdb/django-ldapdb
ldapdb/backends/ldap/base.py
DatabaseWrapper.get_new_connection
def get_new_connection(self, conn_params): """Build a connection from its parameters.""" connection = ldap.ldapobject.ReconnectLDAPObject( uri=conn_params['uri'], retry_max=conn_params['retry_max'], retry_delay=conn_params['retry_delay'], bytes_mode=False)...
python
def get_new_connection(self, conn_params): """Build a connection from its parameters.""" connection = ldap.ldapobject.ReconnectLDAPObject( uri=conn_params['uri'], retry_max=conn_params['retry_max'], retry_delay=conn_params['retry_delay'], bytes_mode=False)...
[ "def", "get_new_connection", "(", "self", ",", "conn_params", ")", ":", "connection", "=", "ldap", ".", "ldapobject", ".", "ReconnectLDAPObject", "(", "uri", "=", "conn_params", "[", "'uri'", "]", ",", "retry_max", "=", "conn_params", "[", "'retry_max'", "]", ...
Build a connection from its parameters.
[ "Build", "a", "connection", "from", "its", "parameters", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/backends/ldap/base.py#L251-L275
train
28,095
django-ldapdb/django-ldapdb
ldapdb/backends/ldap/compiler.py
query_as_ldap
def query_as_ldap(query, compiler, connection): """Convert a django.db.models.sql.query.Query to a LdapLookup.""" if query.is_empty(): return if query.model._meta.model_name == 'migration' and not hasattr(query.model, 'object_classes'): # FIXME(rbarrois): Support migrations return ...
python
def query_as_ldap(query, compiler, connection): """Convert a django.db.models.sql.query.Query to a LdapLookup.""" if query.is_empty(): return if query.model._meta.model_name == 'migration' and not hasattr(query.model, 'object_classes'): # FIXME(rbarrois): Support migrations return ...
[ "def", "query_as_ldap", "(", "query", ",", "compiler", ",", "connection", ")", ":", "if", "query", ".", "is_empty", "(", ")", ":", "return", "if", "query", ".", "model", ".", "_meta", ".", "model_name", "==", "'migration'", "and", "not", "hasattr", "(", ...
Convert a django.db.models.sql.query.Query to a LdapLookup.
[ "Convert", "a", "django", ".", "db", ".", "models", ".", "sql", ".", "query", ".", "Query", "to", "a", "LdapLookup", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/backends/ldap/compiler.py#L37-L72
train
28,096
django-ldapdb/django-ldapdb
ldapdb/backends/ldap/compiler.py
where_node_as_ldap
def where_node_as_ldap(where, compiler, connection): """Parse a django.db.models.sql.where.WhereNode. Returns: (clause, [params]): the filter clause, with a list of unescaped parameters. """ bits, params = [], [] for item in where.children: if isinstance(item, WhereNode): ...
python
def where_node_as_ldap(where, compiler, connection): """Parse a django.db.models.sql.where.WhereNode. Returns: (clause, [params]): the filter clause, with a list of unescaped parameters. """ bits, params = [], [] for item in where.children: if isinstance(item, WhereNode): ...
[ "def", "where_node_as_ldap", "(", "where", ",", "compiler", ",", "connection", ")", ":", "bits", ",", "params", "=", "[", "]", ",", "[", "]", "for", "item", "in", "where", ".", "children", ":", "if", "isinstance", "(", "item", ",", "WhereNode", ")", ...
Parse a django.db.models.sql.where.WhereNode. Returns: (clause, [params]): the filter clause, with a list of unescaped parameters.
[ "Parse", "a", "django", ".", "db", ".", "models", ".", "sql", ".", "where", ".", "WhereNode", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/backends/ldap/compiler.py#L75-L107
train
28,097
django-ldapdb/django-ldapdb
ldapdb/backends/ldap/compiler.py
SQLCompiler.compile
def compile(self, node, *args, **kwargs): """Parse a WhereNode to a LDAP filter string.""" if isinstance(node, WhereNode): return where_node_as_ldap(node, self, self.connection) return super(SQLCompiler, self).compile(node, *args, **kwargs)
python
def compile(self, node, *args, **kwargs): """Parse a WhereNode to a LDAP filter string.""" if isinstance(node, WhereNode): return where_node_as_ldap(node, self, self.connection) return super(SQLCompiler, self).compile(node, *args, **kwargs)
[ "def", "compile", "(", "self", ",", "node", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "node", ",", "WhereNode", ")", ":", "return", "where_node_as_ldap", "(", "node", ",", "self", ",", "self", ".", "connection", ")...
Parse a WhereNode to a LDAP filter string.
[ "Parse", "a", "WhereNode", "to", "a", "LDAP", "filter", "string", "." ]
f3a35d3c8e42e7799d71e5d156ab97fb69e6b479
https://github.com/django-ldapdb/django-ldapdb/blob/f3a35d3c8e42e7799d71e5d156ab97fb69e6b479/ldapdb/backends/ldap/compiler.py#L113-L117
train
28,098
emilmont/pyStatParser
stat_parser/eval_parser.py
TreeOperations.to_spans
def to_spans(self): "Convert the tree to a set of nonterms and spans." s = set() self._convert_to_spans(self.tree, 1, s) return s
python
def to_spans(self): "Convert the tree to a set of nonterms and spans." s = set() self._convert_to_spans(self.tree, 1, s) return s
[ "def", "to_spans", "(", "self", ")", ":", "s", "=", "set", "(", ")", "self", ".", "_convert_to_spans", "(", "self", ".", "tree", ",", "1", ",", "s", ")", "return", "s" ]
Convert the tree to a set of nonterms and spans.
[ "Convert", "the", "tree", "to", "a", "set", "of", "nonterms", "and", "spans", "." ]
0e4990d7c1f0e3a0e0626ea2059ffd9030edf323
https://github.com/emilmont/pyStatParser/blob/0e4990d7c1f0e3a0e0626ea2059ffd9030edf323/stat_parser/eval_parser.py#L55-L59
train
28,099