sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def render_bump_release(self):
"""
If the bump_release plugin is present, configure it
"""
phase = 'prebuild_plugins'
plugin = 'bump_release'
if not self.pt.has_plugin_conf(phase, plugin):
return
if self.user_params.release.value:
self.pt.... | If the bump_release plugin is present, configure it | entailment |
def render_check_and_set_platforms(self):
"""
If the check_and_set_platforms plugin is present, configure it
"""
phase = 'prebuild_plugins'
plugin = 'check_and_set_platforms'
if not self.pt.has_plugin_conf(phase, plugin):
return
if self.user_params.ko... | If the check_and_set_platforms plugin is present, configure it | entailment |
def render_import_image(self, use_auth=None):
"""
Configure the import_image plugin
"""
# import_image is a multi-phase plugin
if self.user_params.imagestream_name.value is None:
self.pt.remove_plugin('exit_plugins', 'import_image',
'... | Configure the import_image plugin | entailment |
def render_tag_from_config(self):
"""Configure tag_from_config plugin"""
phase = 'postbuild_plugins'
plugin = 'tag_from_config'
if not self.has_tag_suffixes_placeholder():
return
unique_tag = self.user_params.image_tag.value.split(':')[-1]
tag_suffixes = {'un... | Configure tag_from_config plugin | entailment |
def render_pull_base_image(self):
"""Configure pull_base_image"""
phase = 'prebuild_plugins'
plugin = 'pull_base_image'
if self.user_params.parent_images_digests.value:
self.pt.set_plugin_arg(phase, plugin, 'parent_images_digests',
self.use... | Configure pull_base_image | entailment |
def get_user(self, username="~"):
"""
get info about user (if no user specified, use the one initiating request)
:param username: str, name of user to get info about, default="~"
:return: dict
"""
url = self._build_url("users/%s/" % username, _prepend_namespace=False)
... | get info about user (if no user specified, use the one initiating request)
:param username: str, name of user to get info about, default="~"
:return: dict | entailment |
def create_build(self, build_json):
"""
:return:
"""
url = self._build_url("builds/")
logger.debug(build_json)
return self._post(url, data=json.dumps(build_json),
headers={"Content-Type": "application/json"}) | :return: | entailment |
def get_all_build_configs_by_labels(self, label_selectors):
"""
Returns all builds matching a given set of label selectors. It is up to the
calling function to filter the results.
"""
labels = ['%s=%s' % (field, value) for field, value in label_selectors]
labels = ','.joi... | Returns all builds matching a given set of label selectors. It is up to the
calling function to filter the results. | entailment |
def get_build_config_by_labels(self, label_selectors):
"""
Returns a build config matching the given label
selectors. This method will raise OsbsException
if not exactly one build config is found.
"""
items = self.get_all_build_configs_by_labels(label_selectors)
... | Returns a build config matching the given label
selectors. This method will raise OsbsException
if not exactly one build config is found. | entailment |
def get_build_config_by_labels_filtered(self, label_selectors, filter_key, filter_value):
"""
Returns a build config matching the given label selectors, filtering against
another predetermined value. This method will raise OsbsException
if not exactly one build config is found after filt... | Returns a build config matching the given label selectors, filtering against
another predetermined value. This method will raise OsbsException
if not exactly one build config is found after filtering. | entailment |
def create_build_config(self, build_config_json):
"""
:return:
"""
url = self._build_url("buildconfigs/")
return self._post(url, data=build_config_json,
headers={"Content-Type": "application/json"}) | :return: | entailment |
def stream_logs(self, build_id):
"""
stream logs from build
:param build_id: str
:return: iterator
"""
kwargs = {'follow': 1}
# If connection is closed within this many seconds, give up:
min_idle_timeout = 60
# Stream logs, but be careful of the... | stream logs from build
:param build_id: str
:return: iterator | entailment |
def logs(self, build_id, follow=False, build_json=None, wait_if_missing=False):
"""
provide logs from build
:param build_id: str
:param follow: bool, fetch logs as they come?
:param build_json: dict, to save one get-build query
:param wait_if_missing: bool, if build does... | provide logs from build
:param build_id: str
:param follow: bool, fetch logs as they come?
:param build_json: dict, to save one get-build query
:param wait_if_missing: bool, if build doesn't exist, wait
:return: None, str or iterator | entailment |
def list_builds(self, build_config_id=None, koji_task_id=None,
field_selector=None, labels=None):
"""
List builds matching criteria
:param build_config_id: str, only list builds created from BuildConfig
:param koji_task_id: str, only list builds for Koji Task ID
... | List builds matching criteria
:param build_config_id: str, only list builds created from BuildConfig
:param koji_task_id: str, only list builds for Koji Task ID
:param field_selector: str, field selector for query
:return: HttpResponse | entailment |
def create_resource_quota(self, name, quota_json):
"""
Prevent builds being scheduled and wait for running builds to finish.
:return:
"""
url = self._build_k8s_url("resourcequotas/")
response = self._post(url, data=json.dumps(quota_json),
h... | Prevent builds being scheduled and wait for running builds to finish.
:return: | entailment |
def wait(self, build_id, states):
"""
:param build_id: wait for build to finish
:return:
"""
logger.info("watching build '%s'", build_id)
for changetype, obj in self.watch_resource("builds", build_id):
try:
obj_name = obj["metadata"]["name"]
... | :param build_id: wait for build to finish
:return: | entailment |
def adjust_attributes_on_object(self, collection, name, things, values, how):
"""
adjust labels or annotations on object
labels have to match RE: (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])? and
have at most 63 chars
:param collection: str, object collection e.g. 'builds'
... | adjust labels or annotations on object
labels have to match RE: (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])? and
have at most 63 chars
:param collection: str, object collection e.g. 'builds'
:param name: str, name of object
:param things: str, 'labels' or 'annotations'
:... | entailment |
def update_annotations_on_build(self, build_id, annotations):
"""
set annotations on build object
:param build_id: str, id of build
:param annotations: dict, annotations to set
:return:
"""
return self.adjust_attributes_on_object('builds', build_id,
... | set annotations on build object
:param build_id: str, id of build
:param annotations: dict, annotations to set
:return: | entailment |
def import_image(self, name, stream_import, tags=None):
"""
Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported
"""
# Get the JSON for the ImageStream
imagestream_json = self.get_image_stream(name).json()
logger... | Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported | entailment |
def import_image_tags(self, name, stream_import, tags, repository, insecure):
"""
Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported
"""
# Get the JSON for the ImageStream
imagestream_json = self.get_image_stream(name)... | Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported | entailment |
def str_on_2_unicode_on_3(s):
"""
argparse is way too awesome when doing repr() on choices when printing usage
:param s: str or unicode
:return: str on 2, unicode on 3
"""
if not PY3:
return str(s)
else: # 3+
if not isinstance(s, str):
return str(s, encoding="u... | argparse is way too awesome when doing repr() on choices when printing usage
:param s: str or unicode
:return: str on 2, unicode on 3 | entailment |
def load(self):
"""
Extract tabular data as |TableData| instances from a Line-delimited JSON file.
|load_source_desc_file|
:return:
Loaded table data iterator.
|load_table_name_desc|
:rtype: |TableData| iterator
:raises pytablereader.DataError:
... | Extract tabular data as |TableData| instances from a Line-delimited JSON file.
|load_source_desc_file|
:return:
Loaded table data iterator.
|load_table_name_desc|
:rtype: |TableData| iterator
:raises pytablereader.DataError:
If the data is invalid Li... | entailment |
def load(self):
"""
Load table data from a Google Spreadsheet.
This method consider :py:attr:`.source` as a path to the
credential JSON file to access Google Sheets API.
The method automatically search the header row start from
:py:attr:`.start_row`. The condition of th... | Load table data from a Google Spreadsheet.
This method consider :py:attr:`.source` as a path to the
credential JSON file to access Google Sheets API.
The method automatically search the header row start from
:py:attr:`.start_row`. The condition of the header row is that
all of ... | entailment |
def set_log_level(log_level):
"""
Set logging level of this module. Using
`logbook <https://logbook.readthedocs.io/en/stable/>`__ module for logging.
:param int log_level:
One of the log level of
`logbook <https://logbook.readthedocs.io/en/stable/api/base.html>`__.
Disabled logg... | Set logging level of this module. Using
`logbook <https://logbook.readthedocs.io/en/stable/>`__ module for logging.
:param int log_level:
One of the log level of
`logbook <https://logbook.readthedocs.io/en/stable/api/base.html>`__.
Disabled logging if ``log_level`` is ``logbook.NOTSET``... | entailment |
def buildconfig_update(orig, new, remove_nonexistent_keys=False):
"""Performs update of given `orig` BuildConfig with values from `new` BuildConfig.
Both BuildConfigs have to be represented as `dict`s.
This function:
- adds all key/value pairs to `orig` from `new` that are missing
- replaces values... | Performs update of given `orig` BuildConfig with values from `new` BuildConfig.
Both BuildConfigs have to be represented as `dict`s.
This function:
- adds all key/value pairs to `orig` from `new` that are missing
- replaces values in `orig` for keys that are in both
- removes key/value pairs from `... | entailment |
def checkout_git_repo(git_url, target_dir=None, commit=None, retry_times=GIT_MAX_RETRIES,
branch=None, depth=None):
"""
clone provided git repo to target_dir, optionally checkout provided commit
yield the ClonedRepoData and delete the repo when finished
:param git_url: str, git re... | clone provided git repo to target_dir, optionally checkout provided commit
yield the ClonedRepoData and delete the repo when finished
:param git_url: str, git repo to clone
:param target_dir: str, filesystem path where the repo should be cloned
:param commit: str, commit to checkout, SHA-1 or ref
:... | entailment |
def clone_git_repo(git_url, target_dir=None, commit=None, retry_times=GIT_MAX_RETRIES, branch=None,
depth=None):
"""
clone provided git repo to target_dir, optionally checkout provided commit
:param git_url: str, git repo to clone
:param target_dir: str, filesystem path where the rep... | clone provided git repo to target_dir, optionally checkout provided commit
:param git_url: str, git repo to clone
:param target_dir: str, filesystem path where the repo should be cloned
:param commit: str, commit to checkout, SHA-1 or ref
:param retry_times: int, number of retries for git clone
:pa... | entailment |
def reset_git_repo(target_dir, git_reference, retry_depth=None):
"""
hard reset git clone in target_dir to given git_reference
:param target_dir: str, filesystem path where the repo is cloned
:param git_reference: str, any valid git reference
:param retry_depth: int, if the repo was cloned with --s... | hard reset git clone in target_dir to given git_reference
:param target_dir: str, filesystem path where the repo is cloned
:param git_reference: str, any valid git reference
:param retry_depth: int, if the repo was cloned with --shallow, this is the expected
depth of the commit
... | entailment |
def get_imagestreamtag_from_image(image):
"""
return ImageStreamTag, give a FROM value
:param image: str, the FROM value from the Dockerfile
:return: str, ImageStreamTag
"""
ret = image
# Remove the registry part
ret = strip_registry_from_image(image)
# ImageStream names cannot co... | return ImageStreamTag, give a FROM value
:param image: str, the FROM value from the Dockerfile
:return: str, ImageStreamTag | entailment |
def get_time_from_rfc3339(rfc3339):
"""
return time tuple from an RFC 3339-formatted time string
:param rfc3339: str, time in RFC 3339 format
:return: float, seconds since the Epoch
"""
try:
# py 3
dt = dateutil.parser.parse(rfc3339, ignoretz=False)
return dt.timestamp... | return time tuple from an RFC 3339-formatted time string
:param rfc3339: str, time in RFC 3339 format
:return: float, seconds since the Epoch | entailment |
def sanitize_strings_for_openshift(str1, str2='', limit=LABEL_MAX_CHARS, separator='-',
label=True):
"""
OpenShift requires labels to be no more than 64 characters and forbids any characters other
than alphanumerics, ., and -. BuildConfig names are similar, but cannot cont... | OpenShift requires labels to be no more than 64 characters and forbids any characters other
than alphanumerics, ., and -. BuildConfig names are similar, but cannot contain /.
Sanitize and concatanate one or two strings to meet OpenShift's requirements. include an
equal number of characters from both string... | entailment |
def make_name_from_git(repo, branch, limit=53, separator='-', hash_size=5):
"""
return name string representing the given git repo and branch
to be used as a build name.
NOTE: Build name will be used to generate pods which have a
limit of 64 characters and is composed as:
<buildname>-<buil... | return name string representing the given git repo and branch
to be used as a build name.
NOTE: Build name will be used to generate pods which have a
limit of 64 characters and is composed as:
<buildname>-<buildnumber>-<podsuffix>
rhel7-1-build
Assuming '-XXXX' (5 chars) and '-build' ... | entailment |
def wrap_name_from_git(prefix, suffix, *args, **kwargs):
"""
wraps the result of make_name_from_git in a suffix and postfix
adding separators for each.
see docstring for make_name_from_git for a full list of parameters
"""
# 64 is maximum length allowed by OpenShift
# 2 is the number of das... | wraps the result of make_name_from_git in a suffix and postfix
adding separators for each.
see docstring for make_name_from_git for a full list of parameters | entailment |
def sanitize_version(version):
"""
Take parse_version() output and standardize output from older
setuptools' parse_version() to match current setuptools.
"""
if hasattr(version, 'base_version'):
if version.base_version:
parts = version.base_version.split('.')
else:
... | Take parse_version() output and standardize output from older
setuptools' parse_version() to match current setuptools. | entailment |
def get_name(self, label_type):
"""
returns the most preferred label name
if there isn't any correct name in the list
it will return newest label name
"""
if label_type in self._label_values:
return self._label_values[label_type][0]
else:
r... | returns the most preferred label name
if there isn't any correct name in the list
it will return newest label name | entailment |
def get_new_names_by_old():
"""Return dictionary, new label name indexed by old label name."""
newdict = {}
for label_type, label_names in Labels.LABEL_NAMES.items():
for oldname in label_names[1:]:
newdict[oldname] = Labels.LABEL_NAMES[label_type][0]
return ... | Return dictionary, new label name indexed by old label name. | entailment |
def get_name_and_value(self, label_type):
"""
Return tuple of (label name, label value)
Raises KeyError if label doesn't exist
"""
if label_type in self._label_values:
return self._label_values[label_type]
else:
return (label_type, self._df_labels[... | Return tuple of (label name, label value)
Raises KeyError if label doesn't exist | entailment |
def kerberos_ccache_init(principal, keytab_file, ccache_file=None):
"""
Checks whether kerberos credential cache has ticket-granting ticket that is valid for at least
an hour.
Default ccache is used unless ccache_file is provided. In that case, KRB5CCNAME environment
variable is set to the value of... | Checks whether kerberos credential cache has ticket-granting ticket that is valid for at least
an hour.
Default ccache is used unless ccache_file is provided. In that case, KRB5CCNAME environment
variable is set to the value of ccache_file if we successfully obtain the ticket. | entailment |
def load(self):
"""
Extract tabular data as |TableData| instances from a SQLite database
file. |load_source_desc_file|
:return:
Loaded table data iterator.
|load_table_name_desc|
=================== ==============================================
... | Extract tabular data as |TableData| instances from a SQLite database
file. |load_source_desc_file|
:return:
Loaded table data iterator.
|load_table_name_desc|
=================== ==============================================
Format specifier Value ... | entailment |
def get_data(self):
"""
Find the data stored in the config_map
:return: dict, the json of the data data that was passed into the ConfigMap on creation
"""
data = graceful_chain_get(self.json, "data")
if data is None:
return {}
data_dict = {}
... | Find the data stored in the config_map
:return: dict, the json of the data data that was passed into the ConfigMap on creation | entailment |
def get_data_by_key(self, name):
"""
Find the object stored by a JSON string at key 'name'
:return: str or dict, the json of the str or dict stored in the ConfigMap at that location
"""
data = graceful_chain_get(self.json, "data")
if data is None or name not in data:
... | Find the object stored by a JSON string at key 'name'
:return: str or dict, the json of the str or dict stored in the ConfigMap at that location | entailment |
def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
header_list = []
for json_record in self._buffer:
for key in json_record:
if key not in header_list:
... | :raises ValueError:
:raises pytablereader.error.ValidationError: | entailment |
def list_builds(self, field_selector=None, koji_task_id=None, running=None,
labels=None):
"""
List builds with matching fields
:param field_selector: str, field selector for Builds
:param koji_task_id: str, only list builds for Koji Task ID
:return: BuildResp... | List builds with matching fields
:param field_selector: str, field selector for Builds
:param koji_task_id: str, only list builds for Koji Task ID
:return: BuildResponse list | entailment |
def get_pod_for_build(self, build_id):
"""
:return: PodResponse object for pod relating to the build
"""
pods = self.os.list_pods(label='openshift.io/build.name=%s' % build_id)
serialized_response = pods.json()
pod_list = [PodResponse(pod) for pod in serialized_response["... | :return: PodResponse object for pod relating to the build | entailment |
def get_build_request(self, build_type=None, inner_template=None,
outer_template=None, customize_conf=None,
arrangement_version=DEFAULT_ARRANGEMENT_VERSION):
"""
return instance of BuildRequest or BuildRequestV2
:param build_type: str, unused
... | return instance of BuildRequest or BuildRequestV2
:param build_type: str, unused
:param inner_template: str, name of inner template for BuildRequest
:param outer_template: str, name of outer template for BuildRequest
:param customize_conf: str, name of customization config for BuildRequ... | entailment |
def create_build_from_buildrequest(self, build_request):
"""
render provided build_request and submit build from it
:param build_request: instance of build.build_request.BuildRequest
:return: instance of build.build_response.BuildResponse
"""
build_request.set_openshift_... | render provided build_request and submit build from it
:param build_request: instance of build.build_request.BuildRequest
:return: instance of build.build_response.BuildResponse | entailment |
def _get_existing_build_config(self, build_config):
"""
Uses the given build config to find an existing matching build config.
Build configs are a match if:
- metadata.labels.git-repo-name AND metadata.labels.git-branch AND
metadata.labels.git-full-repo are equal
OR
... | Uses the given build config to find an existing matching build config.
Build configs are a match if:
- metadata.labels.git-repo-name AND metadata.labels.git-branch AND
metadata.labels.git-full-repo are equal
OR
- metadata.labels.git-repo-name AND metadata.labels.git-branch are ... | entailment |
def _get_image_stream_info_for_build_request(self, build_request):
"""Return ImageStream, and ImageStreamTag name for base_image of build_request
If build_request is not auto instantiated, objects are not fetched
and None, None is returned.
"""
image_stream = None
image_... | Return ImageStream, and ImageStreamTag name for base_image of build_request
If build_request is not auto instantiated, objects are not fetched
and None, None is returned. | entailment |
def create_prod_build(self, *args, **kwargs):
"""
Create a production build
:param git_uri: str, URI of git repository
:param git_ref: str, reference to commit
:param git_branch: str, branch name
:param user: str, user name
:param component: str, not used anymore... | Create a production build
:param git_uri: str, URI of git repository
:param git_ref: str, reference to commit
:param git_branch: str, branch name
:param user: str, user name
:param component: str, not used anymore
:param target: str, koji target
:param architectu... | entailment |
def create_worker_build(self, **kwargs):
"""
Create a worker build
Pass through method to create_prod_build with the following
modifications:
- platform param is required
- release param is required
- arrangement_version param is required, which is us... | Create a worker build
Pass through method to create_prod_build with the following
modifications:
- platform param is required
- release param is required
- arrangement_version param is required, which is used to
select which worker_inner:n.json template... | entailment |
def create_orchestrator_build(self, **kwargs):
"""
Create an orchestrator build
Pass through method to create_prod_build with the following
modifications:
- platforms param is required
- arrangement_version param may be used to select which
orchestr... | Create an orchestrator build
Pass through method to create_prod_build with the following
modifications:
- platforms param is required
- arrangement_version param may be used to select which
orchestrator_inner:n.json template to use
- inner template set ... | entailment |
def get_build_logs(self, build_id, follow=False, build_json=None, wait_if_missing=False,
decode=False):
"""
provide logs from build
NOTE: Since atomic-reactor 1.6.25, logs are always in UTF-8, so if
asked to decode, we assume that is the encoding in use. Otherwise... | provide logs from build
NOTE: Since atomic-reactor 1.6.25, logs are always in UTF-8, so if
asked to decode, we assume that is the encoding in use. Otherwise, we
return the bytes exactly as they came from the container.
:param build_id: str
:param follow: bool, fetch logs as the... | entailment |
def get_orchestrator_build_logs(self, build_id, follow=False, wait_if_missing=False):
"""
provide logs from orchestrator build
:param build_id: str
:param follow: bool, fetch logs as they come?
:param wait_if_missing: bool, if build doesn't exist, wait
:return: generator... | provide logs from orchestrator build
:param build_id: str
:param follow: bool, fetch logs as they come?
:param wait_if_missing: bool, if build doesn't exist, wait
:return: generator yielding objects with attributes 'platform' and 'line' | entailment |
def import_image(self, name, tags=None):
"""
Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported
"""
stream_import_file = os.path.join(self.os_conf.get_build_json_store(),
'image_stream_... | Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported | entailment |
def import_image_tags(self, name, tags, repository, insecure=False):
"""Import image tags from specified container repository.
:param name: str, name of ImageStream object
:param tags: iterable, tags to be imported
:param repository: str, remote location of container image
... | Import image tags from specified container repository.
:param name: str, name of ImageStream object
:param tags: iterable, tags to be imported
:param repository: str, remote location of container image
in the format <registry>/<repository>
:param insecure... | entailment |
def ensure_image_stream_tag(self, stream, tag_name, scheduled=False,
source_registry=None, organization=None, base_image=None):
"""Ensures the tag is monitored in ImageStream
:param stream: dict, ImageStream object
:param tag_name: str, name of tag to check, with... | Ensures the tag is monitored in ImageStream
:param stream: dict, ImageStream object
:param tag_name: str, name of tag to check, without name of
ImageStream as prefix
:param scheduled: bool, if True, importPolicy.scheduled will be
set... | entailment |
def create_image_stream(self, name, docker_image_repository,
insecure_registry=False):
"""
Create an ImageStream object
Raises exception on error
:param name: str, name of ImageStream
:param docker_image_repository: str, pull spec for docker image
... | Create an ImageStream object
Raises exception on error
:param name: str, name of ImageStream
:param docker_image_repository: str, pull spec for docker image
repository
:param insecure_registry: bool, whether plain HTTP should be used
:return: response | entailment |
def get_compression_extension(self):
"""
Find the filename extension for the 'docker save' output, which
may or may not be compressed.
Raises OsbsValidationException if the extension cannot be
determined due to a configuration error.
:returns: str including leading dot,... | Find the filename extension for the 'docker save' output, which
may or may not be compressed.
Raises OsbsValidationException if the extension cannot be
determined due to a configuration error.
:returns: str including leading dot, or else None if no compression | entailment |
def create_config_map(self, name, data):
"""
Create an ConfigMap object on the server
Raises exception on error
:param name: str, name of configMap
:param data: dict, dictionary of data to be stored
:returns: ConfigMapResponse containing the ConfigMap with name and data... | Create an ConfigMap object on the server
Raises exception on error
:param name: str, name of configMap
:param data: dict, dictionary of data to be stored
:returns: ConfigMapResponse containing the ConfigMap with name and data | entailment |
def get_config_map(self, name):
"""
Get a ConfigMap object from the server
Raises exception on error
:param name: str, name of configMap to get from the server
:returns: ConfigMapResponse containing the ConfigMap with the requested name
"""
response = self.os.ge... | Get a ConfigMap object from the server
Raises exception on error
:param name: str, name of configMap to get from the server
:returns: ConfigMapResponse containing the ConfigMap with the requested name | entailment |
def retries_disabled(self):
"""
Context manager to disable retries on requests
:returns: OSBS object
"""
self.os.retries_enabled = False
yield
self.os.retries_enabled = True | Context manager to disable retries on requests
:returns: OSBS object | entailment |
def wipe(self):
"""
Wipe the bolt database.
Calling this after HoverPy has been instantiated is
potentially dangerous. This function is mostly used
internally for unit tests.
"""
try:
if os.isfile(self._dbpath):
os.remove(self._dbpath)... | Wipe the bolt database.
Calling this after HoverPy has been instantiated is
potentially dangerous. This function is mostly used
internally for unit tests. | entailment |
def simulation(self, data=None):
"""
Gets / Sets the simulation data.
If no data is passed in, then this method acts as a getter.
if data is passed in, then this method acts as a setter.
Keyword arguments:
data -- the simulation data you wish to set (default None)
... | Gets / Sets the simulation data.
If no data is passed in, then this method acts as a getter.
if data is passed in, then this method acts as a setter.
Keyword arguments:
data -- the simulation data you wish to set (default None) | entailment |
def destination(self, name=""):
"""
Gets / Sets the destination data.
"""
if name:
return self._session.put(
self.__v2() + "/hoverfly/destination",
data={"destination": name}).json()
else:
return self._session.get(
... | Gets / Sets the destination data. | entailment |
def mode(self, mode=None):
"""
Gets / Sets the mode.
If no mode is provided, then this method acts as a getter.
Keyword arguments:
mode -- this should either be 'capture' or 'simulate' (default None)
"""
if mode:
logging.debug("SWITCHING TO %s" % mod... | Gets / Sets the mode.
If no mode is provided, then this method acts as a getter.
Keyword arguments:
mode -- this should either be 'capture' or 'simulate' (default None) | entailment |
def metadata(self, delete=False):
"""
Gets the metadata.
"""
if delete:
return self._session.delete(self.__v1() + "/metadata").json()
else:
return self._session.get(self.__v1() + "/metadata").json() | Gets the metadata. | entailment |
def records(self, data=None):
"""
Gets / Sets records.
"""
if data:
return self._session.post(
self.__v1() + "/records", data=data).json()
else:
return self._session.get(self.__v1() + "/records").json() | Gets / Sets records. | entailment |
def delays(self, delays=[]):
"""
Gets / Sets the delays.
"""
if delays:
return self._session.put(
self.__v1() + "/delays", data=json.dumps(delays)).json()
else:
return self._session.get(self.__v1() + "/delays").json() | Gets / Sets the delays. | entailment |
def addDelay(self, urlPattern="", delay=0, httpMethod=None):
"""
Adds delays.
"""
print("addDelay is deprecated please use delays instead")
delay = {"urlPattern": urlPattern, "delay": delay}
if httpMethod:
delay["httpMethod"] = httpMethod
return self.... | Adds delays. | entailment |
def __enableProxy(self):
"""
Set the required environment variables to enable the use of hoverfly as a proxy.
"""
os.environ[
"HTTP_PROXY"] = self.httpProxy()
os.environ[
"HTTPS_PROXY"] = self.httpsProxy()
os.environ["REQUESTS_CA_BUNDLE"] = os.pat... | Set the required environment variables to enable the use of hoverfly as a proxy. | entailment |
def __writepid(self, pid):
"""
HoverFly fails to launch if it's already running on
the same ports. So we have to keep track of them using
temp files with the proxy port and admin port, containing
the processe's PID.
"""
import tempfile
d = tempfile.gettem... | HoverFly fails to launch if it's already running on
the same ports. So we have to keep track of them using
temp files with the proxy port and admin port, containing
the processe's PID. | entailment |
def __rmpid(self):
"""
Remove the PID file on shutdown, unfortunately
this may not get called if not given the time to
shut down.
"""
import tempfile
d = tempfile.gettempdir()
name = os.path.join(d, "hoverpy.%i.%i"%(self._proxyPort, self._adminPort))
... | Remove the PID file on shutdown, unfortunately
this may not get called if not given the time to
shut down. | entailment |
def __kill_if_not_shut_properly(self):
"""
If the HoverFly process on these given ports
did not shut down correctly, then kill the pid
before launching a new instance.
todo: this will kill existing HoverFly processes
on those ports indiscriminately
"""
imp... | If the HoverFly process on these given ports
did not shut down correctly, then kill the pid
before launching a new instance.
todo: this will kill existing HoverFly processes
on those ports indiscriminately | entailment |
def __start(self):
"""
Start the hoverfly process.
This function waits until it can make contact
with the hoverfly API before returning.
"""
logging.debug("starting %i" % id(self))
self.__kill_if_not_shut_properly()
self.FNULL = open(os.devnull, 'w')
... | Start the hoverfly process.
This function waits until it can make contact
with the hoverfly API before returning. | entailment |
def __stop(self):
"""
Stop the hoverfly process.
"""
if logging:
logging.debug("stopping")
self._process.terminate()
# communicate means we wait until the process
# was actually terminated, this removes some
# warnings in python3
self._... | Stop the hoverfly process. | entailment |
def __flags(self):
"""
Internal method. Turns arguments into flags.
"""
flags = []
if self._capture:
flags.append("-capture")
if self._spy:
flags.append("-spy")
if self._dbpath:
flags += ["-db-path", self._dbpath]
fl... | Internal method. Turns arguments into flags. | entailment |
def load(self):
"""
Extract tabular data as |TableData| instances from a JSON file.
|load_source_desc_file|
This method can be loading four types of JSON formats:
**(1)** Single table data in a file:
.. code-block:: json
:caption: Acceptable JSON Sc... | Extract tabular data as |TableData| instances from a JSON file.
|load_source_desc_file|
This method can be loading four types of JSON formats:
**(1)** Single table data in a file:
.. code-block:: json
:caption: Acceptable JSON Schema (1): single table
... | entailment |
def load(self):
"""
Extract tabular data as |TableData| instances from a MediaWiki file.
|load_source_desc_file|
:return:
Loaded table data iterator.
|load_table_name_desc|
=================== ==============================================
... | Extract tabular data as |TableData| instances from a MediaWiki file.
|load_source_desc_file|
:return:
Loaded table data iterator.
|load_table_name_desc|
=================== ==============================================
Format specifier Value after ... | entailment |
def load(self):
"""
Extract tabular data as |TableData| instances from a MediaWiki text
object.
|load_source_desc_text|
:return:
Loaded table data iterator.
|load_table_name_desc|
=================== =========================================... | Extract tabular data as |TableData| instances from a MediaWiki text
object.
|load_source_desc_text|
:return:
Loaded table data iterator.
|load_table_name_desc|
=================== ==============================================
Format specifier ... | entailment |
def get_dock_json(self):
""" return dock json from existing build json """
env_json = self.build_json['spec']['strategy']['customStrategy']['env']
try:
p = [env for env in env_json if env["name"] == "ATOMIC_REACTOR_PLUGINS"]
except TypeError:
raise RuntimeError("\... | return dock json from existing build json | entailment |
def dock_json_get_plugin_conf(self, plugin_type, plugin_name):
"""
Return the configuration for a plugin.
Raises KeyError if there are no plugins of that type.
Raises IndexError if the named plugin is not listed.
"""
match = [x for x in self.dock_json[plugin_type] if x.g... | Return the configuration for a plugin.
Raises KeyError if there are no plugins of that type.
Raises IndexError if the named plugin is not listed. | entailment |
def remove_plugin(self, plugin_type, plugin_name):
"""
if config contains plugin, remove it
"""
for p in self.dock_json[plugin_type]:
if p.get('name') == plugin_name:
self.dock_json[plugin_type].remove(p)
break | if config contains plugin, remove it | entailment |
def add_plugin(self, plugin_type, plugin_name, args_dict):
"""
if config has plugin, override it, else add it
"""
plugin_modified = False
for plugin in self.dock_json[plugin_type]:
if plugin['name'] == plugin_name:
plugin['args'] = args_dict
... | if config has plugin, override it, else add it | entailment |
def dock_json_has_plugin_conf(self, plugin_type, plugin_name):
"""
Check whether a plugin is configured.
"""
try:
self.dock_json_get_plugin_conf(plugin_type, plugin_name)
return True
except (KeyError, IndexError):
return False | Check whether a plugin is configured. | entailment |
def create_from_path(self):
"""
Create a file loader from the file extension to loading file.
Supported file extensions are as follows:
========================================= =====================================
Extension Loader
... | Create a file loader from the file extension to loading file.
Supported file extensions are as follows:
========================================= =====================================
Extension Loader
========================================... | entailment |
def create_from_format_name(self, format_name):
"""
Create a file loader from a format name.
Supported file formats are as follows:
========================== ======================================
Format name Loader
=========================... | Create a file loader from a format name.
Supported file formats are as follows:
========================== ======================================
Format name Loader
========================== ======================================
``"csv"`` ... | entailment |
def _get_extension_loader_mapping(self):
"""
:return: Mappings of format-extension and loader class.
:rtype: dict
"""
loader_table = self._get_common_loader_mapping()
loader_table.update(
{
"asp": HtmlTableTextLoader,
"aspx": H... | :return: Mappings of format-extension and loader class.
:rtype: dict | entailment |
def _get_format_name_loader_mapping(self):
"""
:return: Mappings of format-name and loader class.
:rtype: dict
"""
loader_table = self._get_common_loader_mapping()
loader_table.update(
{
"excel": ExcelTableFileLoader,
"json_lin... | :return: Mappings of format-name and loader class.
:rtype: dict | entailment |
def get_container_image_ids(self):
"""
Find the image IDs the containers use.
:return: dict, image tag to docker ID
"""
statuses = graceful_chain_get(self.json, "status", "containerStatuses")
if statuses is None:
return {}
def remove_prefix(image_id... | Find the image IDs the containers use.
:return: dict, image tag to docker ID | entailment |
def get_failure_reason(self):
"""
Find the reason a pod failed
:return: dict, which will always have key 'reason':
reason: brief reason for state
containerID (if known): ID of container
exitCode (if known): numeric exit code
"""
... | Find the reason a pod failed
:return: dict, which will always have key 'reason':
reason: brief reason for state
containerID (if known): ID of container
exitCode (if known): numeric exit code | entailment |
def get_error_message(self):
"""
Return an error message based on atomic-reactor's metadata
"""
error_reason = self.get_error_reason()
if error_reason:
error_message = error_reason.get('pod') or None
if error_message:
return "Error in pod: ... | Return an error message based on atomic-reactor's metadata | entailment |
def create_from_path(self):
"""
Create a file loader from the file extension to loading file.
Supported file extensions are as follows:
========================== =======================================
Extension Loader
====================... | Create a file loader from the file extension to loading file.
Supported file extensions are as follows:
========================== =======================================
Extension Loader
========================== =======================================
... | entailment |
def create_from_format_name(self, format_name):
"""
Create a file loader from a format name.
Supported file formats are as follows:
================ ======================================
Format name Loader
================ ===================... | Create a file loader from a format name.
Supported file formats are as follows:
================ ======================================
Format name Loader
================ ======================================
``"csv"`` :py:class:`~.CsvTa... | entailment |
def _get_extension_loader_mapping(self):
"""
:return: Mappings of format extension and loader class.
:rtype: dict
"""
loader_table = self._get_common_loader_mapping()
loader_table.update(
{
"htm": HtmlTableFileLoader,
"md": Mar... | :return: Mappings of format extension and loader class.
:rtype: dict | entailment |
def _get_format_name_loader_mapping(self):
"""
:return: Mappings of format name and loader class.
:rtype: dict
"""
loader_table = self._get_common_loader_mapping()
loader_table.update(
{
"excel": ExcelTableFileLoader,
"json_lin... | :return: Mappings of format name and loader class.
:rtype: dict | entailment |
def load(self):
"""
Extract tabular data as |TableData| instances from an Excel file.
|spreadsheet_load_desc|
:return:
Loaded |TableData| iterator.
|TableData| created for each sheet in the workbook.
|load_table_name_desc|
===============... | Extract tabular data as |TableData| instances from an Excel file.
|spreadsheet_load_desc|
:return:
Loaded |TableData| iterator.
|TableData| created for each sheet in the workbook.
|load_table_name_desc|
=================== ==============================... | entailment |
def load(self):
"""
Extract tabular data as |TableData| instances from a LTSV file.
|load_source_desc_file|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format specifier ... | Extract tabular data as |TableData| instances from a LTSV file.
|load_source_desc_file|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format specifier Value after the replacement
... | entailment |
def load(self):
"""
Extract tabular data as |TableData| instances from a LTSV text object.
|load_source_desc_text|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format spe... | Extract tabular data as |TableData| instances from a LTSV text object.
|load_source_desc_text|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format specifier Value after the replaceme... | entailment |
def totals(self):
"""
Computes and returns dictionary containing home/away by player, shots and face-off totals
:returns: dict of the form ``{ 'home/away': { 'all_keys': w_numeric_data } }``
"""
def agg(d):
keys = ['g','a','p','pm','pn','pim','s','ab','ms','h... | Computes and returns dictionary containing home/away by player, shots and face-off totals
:returns: dict of the form ``{ 'home/away': { 'all_keys': w_numeric_data } }`` | entailment |
def filter_players(self, pl_filter):
"""
Return the subset home and away players that satisfy the provided filter function.
:param pl_filter: function that takes a by player dictionary and returns bool
:returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py:f... | Return the subset home and away players that satisfy the provided filter function.
:param pl_filter: function that takes a by player dictionary and returns bool
:returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py:func:`home_players` and :py:func:`away_players` | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.