_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q244500
BroMultiLogReader.readrows
train
def readrows(self): """The readrows method reads simply 'combines' the rows of multiple files OR gunzips the file and then reads the rows """ # For each file (may be just one) create a BroLogReader and use it for self._filepath in self._files: # Check if the file...
python
{ "resource": "" }
q244501
most_recent
train
def most_recent(path, startswith=None, endswith=None): """Recursively inspect all files under a directory and return the most recent Args: path (str): the path of the directory to traverse startswith (str): the file name start with (optional) endswith (str): the file nam...
python
{ "resource": "" }
q244502
yara_match
train
def yara_match(file_path, rules): """Callback for a newly extracted file"""
python
{ "resource": "" }
q244503
LiveSimulator.readrows
train
def readrows(self): """Using the BroLogReader this method yields each row of the log file replacing timestamps, looping and emitting rows based on EPS rate """ # Loop forever or until max_rows is reached num_rows = 0 while True: # Yield the rows from the ...
python
{ "resource": "" }
q244504
BroLogReader._parse_bro_header
train
def _parse_bro_header(self, bro_log): """Parse the Bro log header section. Format example: #separator \x09 #set_separator , #empty_field (empty) #unset_field - #path httpheader_recon #fields ts origin us...
python
{ "resource": "" }
q244505
BroLogReader.make_dict
train
def make_dict(self, field_values): ''' Internal method that makes sure any dictionary elements are properly cast into the correct types. ''' data_dict = {} for key, value, field_type, converter in zip(self.field_names, field_values, self.field_types, self.type_converters): ...
python
{ "resource": "" }
q244506
str_to_mac
train
def str_to_mac(mac_string): """Convert a readable string to a MAC address Args: mac_string (str): a readable string (e.g. '01:02:03:04:05:06') Returns: str: a MAC address in hex form
python
{ "resource": "" }
q244507
inet_to_str
train
def inet_to_str(inet): """Convert inet object to a string Args: inet (inet struct): inet network address Returns: str: Printable/readable IP address """ # First try ipv4 and then ipv6 try:
python
{ "resource": "" }
q244508
str_to_inet
train
def str_to_inet(address): """Convert an a string IP address to a inet struct Args: address (str): String representation of address Returns: inet: Inet network address """ # First try ipv4 and then ipv6
python
{ "resource": "" }
q244509
signal_catcher
train
def signal_catcher(callback): """Catch signals and invoke the callback method""" def _catch_exit_signal(sig_num, _frame): print('Received signal {:d} invoking callback...'.format(sig_num)) callback() signal.signal(signal.SIGINT,
python
{ "resource": "" }
q244510
entropy
train
def entropy(string): """Compute entropy on the string""" p, lns = Counter(string), float(len(string))
python
{ "resource": "" }
q244511
DirWatcher.on_any_event
train
def on_any_event(self, event): """File created or modified"""
python
{ "resource": "" }
q244512
ReverseDNS.lookup
train
def lookup(self, ip_address): """Try to do a reverse dns lookup on the given ip_address""" # Is this already in our cache if self.ip_lookup_cache.get(ip_address): domain = self.ip_lookup_cache.get(ip_address) # Is the ip_address local or special elif not self.lookup...
python
{ "resource": "" }
q244513
DataFrameCache.add_rows
train
def add_rows(self, list_of_rows): """Add a list of rows to the DataFrameCache class""" for row in list_of_rows: self.row_deque.append(row)
python
{ "resource": "" }
q244514
DataFrameCache.update
train
def update(self): """Update the deque, removing rows based on time""" expire_time = time.time() -
python
{ "resource": "" }
q244515
Cache._compress
train
def _compress(self): """Internal method to compress the cache. This method will expire any old items in the cache, making the cache smaller"""
python
{ "resource": "" }
q244516
save_vtq
train
def save_vtq(): """Exit on Signal""" global vtq print('Saving VirusTotal
python
{ "resource": "" }
q244517
DummyEncoder.fit_transform
train
def fit_transform(self, df): """Fit method for the DummyEncoder""" self.index_ = df.index self.columns_ = df.columns self.cat_columns_ = df.select_dtypes(include=['category']).columns self.non_cat_columns_ = df.columns.drop(self.cat_columns_) self.cat_map_ = {col: df[col]...
python
{ "resource": "" }
q244518
_make_df
train
def _make_df(rows): """Internal Method to make and clean the dataframe in preparation for sending to Parquet""" # Make DataFrame df = pd.DataFrame(rows).set_index('ts') # TimeDelta Support: https://issues.apache.org/jira/browse/ARROW-835 for column in df.columns:
python
{ "resource": "" }
q244519
Context.create_queue
train
def create_queue(self, credentials): """Create a taskcluster queue. Args: credentials (dict): taskcluster credentials. """ if credentials: session = self.session or aiohttp.ClientSession(loop=self.event_loop) return Queue( options={
python
{ "resource": "" }
q244520
Context.write_json
train
def write_json(self, path, contents, message): """Write json to disk. Args: path (str): the path to write to contents (dict): the contents of the json blob message (str): the message to log """
python
{ "resource": "" }
q244521
Context.populate_projects
train
async def populate_projects(self, force=False): """Download the ``projects.yml`` file and populate ``self.projects``. This only sets it once, unless ``force`` is set. Args: force (bool, optional): Re-run the download, even if ``self.projects`` is already defined. De...
python
{ "resource": "" }
q244522
do_run_task
train
async def do_run_task(context, run_cancellable, to_cancellable_process): """Run the task logic. Returns the integer status of the task. args: context (scriptworker.context.Context): the scriptworker context. run_cancellable (typing.Callable): wraps future such that it'll cancel upon worker...
python
{ "resource": "" }
q244523
do_upload
train
async def do_upload(context, files): """Upload artifacts and return status. Returns the integer status of the upload. args: context (scriptworker.context.Context): the scriptworker context. files (list of str): list of files to be uploaded as artifacts Raises: Exception: on un...
python
{ "resource": "" }
q244524
run_tasks
train
async def run_tasks(context): """Run any tasks returned by claimWork. Returns the integer status of the task that was run, or None if no task was run. args: context (scriptworker.context.Context): the scriptworker context. Raises: Exception: on unexpected exception. Returns: ...
python
{ "resource": "" }
q244525
async_main
train
async def async_main(context, credentials): """Set up and run tasks for this iteration. http://docs.taskcluster.net/queue/worker-interaction/ Args: context (scriptworker.context.Context): the scriptworker context. """ conn = aiohttp.TCPConnector(limit=context.config['aiohttp_max_connection...
python
{ "resource": "" }
q244526
RunTasks.invoke
train
async def invoke(self, context): """Claims and processes Taskcluster work. Args: context (scriptworker.context.Context): context of worker Returns: status code of build """ try: # Note: claim_work(...) might not be safely interruptible! See ...
python
{ "resource": "" }
q244527
RunTasks.cancel
train
async def cancel(self): """Cancel current work.""" self.is_cancelled = True if self.future is not None: self.future.cancel() if self.task_process is not None:
python
{ "resource": "" }
q244528
request
train
async def request(context, url, timeout=60, method='get', good=(200, ), retry=tuple(range(500, 512)), return_type='text', **kwargs): """Async aiohttp request wrapper. Args: context (scriptworker.context.Context): the scriptworker context. url (str): the url to request ...
python
{ "resource": "" }
q244529
retry_request
train
async def retry_request(*args, retry_exceptions=(asyncio.TimeoutError, ScriptWorkerRetryException), retry_async_kwargs=None, **kwargs): """Retry the ``request`` function. Args: *args: the args to send to request() through retry_as...
python
{ "resource": "" }
q244530
makedirs
train
def makedirs(path): """Equivalent to mkdir -p. Args: path (str): the path to mkdir -p Raises: ScriptWorkerException: if path exists already and the realpath is not a dir. """ if path: if not os.path.exists(path):
python
{ "resource": "" }
q244531
rm
train
def rm(path): """Equivalent to rm -rf. Make sure ``path`` doesn't exist after this call. If it's a dir, shutil.rmtree(); if it's a file, os.remove(); if it doesn't exist, ignore. Args: path (str): the path to nuke. """
python
{ "resource": "" }
q244532
cleanup
train
def cleanup(context): """Clean up the work_dir and artifact_dir between task runs, then recreate. Args: context (scriptworker.context.Context): the scriptworker context. """ for name in 'work_dir', 'artifact_dir', 'task_log_dir':
python
{ "resource": "" }
q244533
calculate_sleep_time
train
def calculate_sleep_time(attempt, delay_factor=5.0, randomization_factor=.5, max_delay=120): """Calculate the sleep time between retries, in seconds. Based off of `taskcluster.utils.calculateSleepTime`, but with kwargs instead of constant `delay_factor`/`randomization_factor`/`max_delay`. The taskcluster ...
python
{ "resource": "" }
q244534
retry_async
train
async def retry_async(func, attempts=5, sleeptime_callback=calculate_sleep_time, retry_exceptions=Exception, args=(), kwargs=None, sleeptime_kwargs=None): """Retry ``func``, where ``func`` is an awaitable. Args: func (function): an awaitable function. ...
python
{ "resource": "" }
q244535
create_temp_creds
train
def create_temp_creds(client_id, access_token, start=None, expires=None, scopes=None, name=None): """Request temp TC creds with our permanent creds. Args: client_id (str): the taskcluster client_id to use access_token (str): the taskcluster access_token to use star...
python
{ "resource": "" }
q244536
filepaths_in_dir
train
def filepaths_in_dir(path): """Find all files in a directory, and return the relative paths to those files. Args: path (str): the directory path to walk Returns: list: the list of relative paths to all files inside of ``path`` or its subdirectories. """ filepaths = [] ...
python
{ "resource": "" }
q244537
get_hash
train
def get_hash(path, hash_alg="sha256"): """Get the hash of the file at ``path``. I'd love to make this async, but evidently file i/o is always ready Args: path (str): the path to the file to hash. hash_alg (str, optional): the algorithm to use. Defaults to 'sha256'. Returns: s...
python
{ "resource": "" }
q244538
load_json_or_yaml
train
def load_json_or_yaml(string, is_path=False, file_type='json', exception=ScriptWorkerTaskException, message="Failed to load %(file_type)s: %(exc)s"): """Load json or yaml from a filehandle or string, and raise a custom exception on failure. Args: string (str)...
python
{ "resource": "" }
q244539
write_to_file
train
def write_to_file(path, contents, file_type='text'): """Write ``contents`` to ``path`` with optional formatting. Small helper function to write ``contents`` to ``file`` with optional formatting. Args: path (str): the path to write to contents (str, object, or bytes): the contents to write ...
python
{ "resource": "" }
q244540
read_from_file
train
def read_from_file(path, file_type='text', exception=ScriptWorkerException): """Read from ``path``. Small helper function to read from ``file``. Args: path (str): the path to read from. file_type (str, optional): the type of file. Currently accepts ``text`` or ``binary``. Defau...
python
{ "resource": "" }
q244541
download_file
train
async def download_file(context, url, abs_filename, session=None, chunk_size=128): """Download a file, async. Args: context (scriptworker.context.Context): the scriptworker context. url (str): the url to download abs_filename (str): the path to download to session (aiohttp.Clien...
python
{ "resource": "" }
q244542
get_loggable_url
train
def get_loggable_url(url): """Strip out secrets from taskcluster urls. Args: url (str): the url to strip Returns: str: the loggable url """ loggable_url = url or "" for secret_string in ("bewit=", "AWSAccessKeyId=", "access_token="):
python
{ "resource": "" }
q244543
match_url_regex
train
def match_url_regex(rules, url, callback): """Given rules and a callback, find the rule that matches the url. Rules look like:: ( { 'schemes': ['https', 'ssh'], 'netlocs': ['hg.mozilla.org'], 'path_regexes': [ "^(?P<path>/...
python
{ "resource": "" }
q244544
add_enumerable_item_to_dict
train
def add_enumerable_item_to_dict(dict_, key, item): """Add an item to a list contained in a dict. For example: If the dict is ``{'some_key': ['an_item']}``, then calling this function will alter the dict to ``{'some_key': ['an_item', 'another_item']}``. If the key doesn't exist yet, the function initia...
python
{ "resource": "" }
q244545
get_single_item_from_sequence
train
def get_single_item_from_sequence( sequence, condition, ErrorClass=ValueError, no_item_error_message='No item matched condition', too_many_item_error_message='Too many items matched condition', append_sequence_to_error_message=True ): """Return an item from a python sequence based on the given c...
python
{ "resource": "" }
q244546
get_task
train
def get_task(config): """Read the task.json from work_dir. Args: config (dict): the running config, to find work_dir. Returns: dict: the contents of task.json Raises: ScriptWorkerTaskException: on error. """ path = os.path.join(config['work_dir'], "task.json") mes...
python
{ "resource": "" }
q244547
validate_json_schema
train
def validate_json_schema(data, schema, name="task"): """Given data and a jsonschema, let's validate it. This happens for tasks and chain of trust artifacts. Args: data (dict): the json to validate. schema (dict): the jsonschema to validate against. name (str, optional): the name of
python
{ "resource": "" }
q244548
validate_task_schema
train
def validate_task_schema(context, schema_key='schema_file'): """Validate the task definition. Args: context (scriptworker.context.Context): the scriptworker context. It must contain a task and the config pointing to the schema file schema_key: the key in `context.config` where the p...
python
{ "resource": "" }
q244549
validate_artifact_url
train
def validate_artifact_url(valid_artifact_rules, valid_artifact_task_ids, url): """Ensure a URL fits in given scheme, netloc, and path restrictions. If we fail any checks, raise a ScriptWorkerTaskException with ``malformed-payload``. Args: valid_artifact_rules (tuple): the tests to run, with ``...
python
{ "resource": "" }
q244550
sync_main
train
def sync_main(async_main, config_path=None, default_config=None, should_validate_task=True, loop_function=asyncio.get_event_loop): """Entry point for scripts using scriptworker. This function sets up the basic needs for a script to run. More specifically: * it creates the scriptworker con...
python
{ "resource": "" }
q244551
TaskProcess.stop
train
async def stop(self): """Stop the current task process. Starts with SIGTERM, gives the process 1 second to terminate, then kills it """ # negate pid so that signals apply to process group pgid = -self.process.pid try:
python
{ "resource": "" }
q244552
ed25519_private_key_from_string
train
def ed25519_private_key_from_string(string): """Create an ed25519 private key from ``string``, which is a seed. Args: string (str): the string to use as a seed. Returns: Ed25519PrivateKey: the private key """ try: return Ed25519PrivateKey.from_private_bytes(
python
{ "resource": "" }
q244553
ed25519_public_key_from_string
train
def ed25519_public_key_from_string(string): """Create an ed25519 public key from ``string``, which is a seed. Args: string (str): the string to use as a seed. Returns: Ed25519PublicKey: the public key """ try: return Ed25519PublicKey.from_public_bytes(
python
{ "resource": "" }
q244554
_ed25519_key_from_file
train
def _ed25519_key_from_file(fn, path): """Create an ed25519 key from the contents of ``path``. ``path`` is a filepath containing a base64-encoded ed25519 key seed. Args: fn (callable): the function to call with the contents from ``path`` path (str): the file path
python
{ "resource": "" }
q244555
ed25519_private_key_to_string
train
def ed25519_private_key_to_string(key): """Convert an ed25519 private key to a base64-encoded string. Args: key (Ed25519PrivateKey): the key to write to the file. Returns:
python
{ "resource": "" }
q244556
ed25519_public_key_to_string
train
def ed25519_public_key_to_string(key): """Convert an ed25519 public key to a base64-encoded string. Args: key (Ed25519PublicKey): the key to write to the file.
python
{ "resource": "" }
q244557
verify_ed25519_signature
train
def verify_ed25519_signature(public_key, contents, signature, message): """Verify that ``signature`` comes from ``public_key`` and ``contents``. Args: public_key (Ed25519PublicKey): the key to verify the signature contents (bytes): the contents that was signed signature (bytes): the sig...
python
{ "resource": "" }
q244558
get_reversed_statuses
train
def get_reversed_statuses(context): """Return a mapping of exit codes to status strings. Args: context (scriptworker.context.Context): the scriptworker context
python
{ "resource": "" }
q244559
get_repo
train
def get_repo(task, source_env_prefix): """Get the repo for a task. Args: task (ChainOfTrust or LinkOfTrust): the trust object to inspect source_env_prefix (str): The environment variable prefix that is used to get repository information. Returns: str: the
python
{ "resource": "" }
q244560
get_pull_request_number
train
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
python
{ "resource": "" }
q244561
get_and_check_project
train
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
{ "resource": "" }
q244562
get_and_check_tasks_for
train
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
{ "resource": "" }
q244563
get_repo_scope
train
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).
python
{ "resource": "" }
q244564
is_github_task
train
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
{ "resource": "" }
q244565
is_action
train
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
{ "resource": "" }
q244566
prepare_to_run_task
train
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
{ "resource": "" }
q244567
run_task
train
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
{ "resource": "" }
q244568
reclaim_task
train
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
{ "resource": "" }
q244569
complete_task
train
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
{ "resource": "" }
q244570
claim_work
train
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
{ "resource": "" }
q244571
raise_on_errors
train
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:
python
{ "resource": "" }
q244572
guess_task_type
train
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
python
{ "resource": "" }
q244573
check_interactive_docker_worker
train
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
{ "resource": "" }
q244574
verify_docker_image_sha
train
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
{ "resource": "" }
q244575
find_sorted_task_dependencies
train
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
{ "resource": "" }
q244576
build_task_dependencies
train
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
{ "resource": "" }
q244577
download_cot
train
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
{ "resource": "" }
q244578
download_cot_artifact
train
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
{ "resource": "" }
q244579
download_cot_artifacts
train
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
{ "resource": "" }
q244580
is_artifact_optional
train
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
python
{ "resource": "" }
q244581
get_all_artifacts_per_task_id
train
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
{ "resource": "" }
q244582
verify_link_ed25519_cot_signature
train
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
{ "resource": "" }
q244583
verify_cot_signatures
train
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
{ "resource": "" }
q244584
verify_task_in_task_graph
train
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
{ "resource": "" }
q244585
verify_link_in_task_graph
train
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
{ "resource": "" }
q244586
get_pushlog_info
train
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
{ "resource": "" }
q244587
get_scm_level
train
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
{ "resource": "" }
q244588
populate_jsone_context
train
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
{ "resource": "" }
q244589
get_in_tree_template
train
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
{ "resource": "" }
q244590
get_action_context_and_template
train
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
{ "resource": "" }
q244591
get_jsone_context_and_template
train
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
{ "resource": "" }
q244592
check_and_update_action_task_group_id
train
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
{ "resource": "" }
q244593
compare_jsone_task_definition
train
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
{ "resource": "" }
q244594
verify_parent_task
train
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
{ "resource": "" }
q244595
verify_docker_image_task
train
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.
python
{ "resource": "" }
q244596
check_num_tasks
train
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
{ "resource": "" }
q244597
verify_docker_worker_task
train
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
{ "resource": "" }
q244598
verify_scriptworker_task
train
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
{ "resource": "" }
q244599
verify_repo_matches_url
train
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
{ "resource": "" }