text stringlengths 81 112k |
|---|
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 ... |
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``... |
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 `... |
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
:... |
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... |
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
... |
return ImageStreamTag, give a FROM value
:param image: str, the FROM value from the Dockerfile
:return: str, ImageStreamTag
def get_imagestreamtag_from_image(image):
"""
return ImageStreamTag, give a FROM value
:param image: str, the FROM value from the Dockerfile
:return: str, ImageStreamTag... |
return time tuple from an RFC 3339-formatted time string
:param rfc3339: str, time in RFC 3339 format
:return: float, seconds since the Epoch
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: ... |
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... |
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' ... |
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
def wrap_name_from_git(prefix, suffix, *args, **kwargs):
"""
wraps the result of make_name_from_git in a suffix and postfix
adding separator... |
Take parse_version() output and standardize output from older
setuptools' parse_version() to match current setuptools.
def sanitize_version(version):
"""
Take parse_version() output and standardize output from older
setuptools' parse_version() to match current setuptools.
"""
if hasattr(version... |
returns the most preferred label name
if there isn't any correct name in the list
it will return newest label name
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
... |
Return dictionary, new label name indexed by old label name.
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:]:
newdic... |
Return tuple of (label name, label value)
Raises KeyError if label doesn't exist
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 sel... |
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.
def kerberos_ccache_init(pri... |
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 ... |
Find the data stored in the config_map
:return: dict, the json of the data data that was passed into the ConfigMap on creation
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
... |
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
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... |
:raises ValueError:
:raises pytablereader.error.ValidationError:
def to_table_data(self):
"""
:raises ValueError:
:raises pytablereader.error.ValidationError:
"""
self._validate_source_data()
header_list = []
for json_record in self._buffer:
... |
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
def list_builds(self, field_selector=None, koji_task_id=None, running=None,
labels=None):
"... |
:return: PodResponse object for pod relating to the build
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()
po... |
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... |
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
def create_build_from_buildrequest(self, build_request):
"""
render provided build_request and submit build ... |
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 ... |
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.
def _get_image_stream_info_for_build_request(self, build_request):
"""Return ImageStream, and ImageStreamTag name for base_... |
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... |
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... |
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 ... |
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... |
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'
def get_orchestrator_build_logs(self, build_id, f... |
Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported
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_... |
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... |
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... |
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
def create... |
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
def get_compression_exte... |
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
def create_config_map(self, name, data):
"""
... |
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
def get_config_map(self, name):
"""
Get a ConfigMap object from the server
... |
Context manager to disable retries on requests
:returns: OSBS object
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 |
Wipe the bolt database.
Calling this after HoverPy has been instantiated is
potentially dangerous. This function is mostly used
internally for unit tests.
def wipe(self):
"""
Wipe the bolt database.
Calling this after HoverPy has been instantiated is
potentiall... |
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)
def simulation(self, data=None):
"""
Gets... |
Gets / Sets the destination data.
def destination(self, name=""):
"""
Gets / Sets the destination data.
"""
if name:
return self._session.put(
self.__v2() + "/hoverfly/destination",
data={"destination": name}).json()
else:
... |
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)
def mode(self, mode=None):
"""
Gets / Sets the mode.
If no mode is provided, then this method acts ... |
Gets the metadata.
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 / Sets records.
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 the delays.
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").jso... |
Adds delays.
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
... |
Set the required environment variables to enable the use of hoverfly as a proxy.
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[
"HT... |
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.
def __writepid(self, pid):
"""
HoverFly fails to launch if it's already running on
the... |
Remove the PID file on shutdown, unfortunately
this may not get called if not given the time to
shut down.
def __rmpid(self):
"""
Remove the PID file on shutdown, unfortunately
this may not get called if not given the time to
shut down.
"""
import tempfil... |
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
def __kill_if_not_shut_properly(self):
"""
If the HoverFly proces... |
Start the hoverfly process.
This function waits until it can make contact
with the hoverfly API before returning.
def __start(self):
"""
Start the hoverfly process.
This function waits until it can make contact
with the hoverfly API before returning.
"""
... |
Stop the hoverfly process.
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
# warnin... |
Internal method. Turns arguments into flags.
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:
flag... |
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
... |
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 ... |
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 ... |
return dock json from existing build json
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 T... |
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.
def dock_json_get_plugin_conf(self, plugin_type, plugin_name):
"""
Return the configuration for a plugin.
Raises KeyError if there ... |
if config contains plugin, remove it
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)
b... |
if config has plugin, override it, else add it
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:
... |
Check whether a plugin is configured.
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):
... |
Create a file loader from the file extension to loading file.
Supported file extensions are as follows:
========================================= =====================================
Extension Loader
========================================... |
Create a file loader from a format name.
Supported file formats are as follows:
========================== ======================================
Format name Loader
========================== ======================================
``"csv"`` ... |
:return: Mappings of format-extension and loader class.
:rtype: dict
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(
... |
:return: Mappings of format-name and loader class.
:rtype: dict
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(
{... |
Find the image IDs the containers use.
:return: dict, image tag to docker ID
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")... |
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
def get_failure_reason(self):
"""
Find the reason a ... |
Return an error message based on atomic-reactor's metadata
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
... |
Create a file loader from the file extension to loading file.
Supported file extensions are as follows:
========================== =======================================
Extension Loader
========================== =======================================
... |
Create a file loader from a format name.
Supported file formats are as follows:
================ ======================================
Format name Loader
================ ======================================
``"csv"`` :py:class:`~.CsvTa... |
:return: Mappings of format extension and loader class.
:rtype: dict
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(
... |
:return: Mappings of format name and loader class.
:rtype: dict
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(
{... |
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 a LTSV file.
|load_source_desc_file|
:return:
Loaded table data.
|load_table_name_desc|
=================== ========================================
Format specifier Value after the replacement
... |
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... |
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 totals(self):
"""
Computes and returns dictionary containing home/away by player, shots and face-off totals
... |
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`
def filte... |
Return all home and away by player info sorted by either the provided key or function. Must provide
at least one of the two parameters. Can sort either ascending or descending.
:param sort_key: (def None) dict key to sort on
:param sort_func: (def None) sorting function
:param r... |
Return home/away by player info for the players on each team that are first in the provided category.
:param sort_key: str, the dictionary key to be sorted on
:returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py:func:`home_players` and :py:func:`away_players`
def top_by_... |
Return home/away by player info for the players on each team who come in first according to the
provided sorting function. Will perform ascending sort.
:param sort_func: function that yields the sorting quantity
:returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py... |
Encode one argument/object to json
def encode(obj):
"""
Encode one argument/object to json
"""
if hasattr(obj, 'json'):
return obj.json
if hasattr(obj, '__json__'):
return obj.__json__()
return dumps(obj) |
Encode a list of arguments
def encode_args(args, extra=False):
"""
Encode a list of arguments
"""
if not args:
return ''
methodargs = ', '.join([encode(a) for a in args])
if extra:
methodargs += ', '
return methodargs |
Establishes a socket connection to the zombie.js server and sends
Javascript instructions.
:param js: the Javascript string to execute
def _send(self, javascript):
"""
Establishes a socket connection to the zombie.js server and sends
Javascript instructions.
:param js:... |
Call a method on the zombie.js Browser instance and wait on a callback.
:param method: the method to call, e.g., html()
:param args: one of more arguments for the method
def wait(self, method, *args):
"""
Call a method on the zombie.js Browser instance and wait on a callback.
... |
Evaluate a browser method and CSS selector against the document
(or an optional context DOMNode) and return a single
:class:`zombie.dom.DOMNode` object, e.g.,
browser._node('query', 'body > div')
...roughly translates to the following Javascript...
browser.query('body > div')
... |
Execute a browser method that will return a list of elements.
Returns a list of the element indexes
def create_elements(self, method, args=[]):
"""
Execute a browser method that will return a list of elements.
Returns a list of the element indexes
"""
args = encode_arg... |
Fill a specified form field in the current document.
:param field: an instance of :class:`zombie.dom.DOMNode`
:param value: any string value
:return: self to allow function chaining.
def fill(self, field, value):
"""
Fill a specified form field in the current document.
... |
Evaluate a CSS selector against the document (or an optional context
:class:`zombie.dom.DOMNode`) and return a single
:class:`zombie.dom.DOMNode` object.
:param selector: a string CSS selector
(http://zombie.labnotes.org/selectors)
:param context: an (optional) i... |
Evaluate a CSS selector against the document (or an optional context
:class:`zombie.dom.DOMNode`) and return a list of
:class:`zombie.dom.DOMNode` objects.
:param selector: a string CSS selector
(http://zombie.labnotes.org/selectors)
:param context: an (optional)... |
Finds and returns a link ``<a>`` element (:class:`zombie.dom.DOMNode`).
You can use a CSS selector or find a link by its text contents (case
sensitive, but ignores leading/trailing spaces).
:param selector: an optional string CSS selector
(http://zombie.labnotes.org/sele... |
Used to set the ``value`` of form elements.
def value(self, value):
"""
Used to set the ``value`` of form elements.
"""
self.client.nowait(
'set_field', (Literal('browser'), self.element, value)) |
Fires a specified DOM event on the current node.
:param event: the name of the event to fire (e.g., 'click').
Returns the :class:`zombie.dom.DOMNode` to allow function chaining.
def fire(self, event):
"""
Fires a specified DOM event on the current node.
:param event: the name... |
Force all reports to be loaded and parsed instead of lazy loading on demand.
:returns: ``self`` or ``None`` if load fails
def load_all(self):
"""
Force all reports to be loaded and parsed instead of lazy loading on demand.
:returns: ``self`` or ``None`` if load fails
... |
Return the game meta information displayed in report banners including team names,
final score, game date, location, and attendance. Data format is
.. code:: python
{
'home': home,
'away': away,
'final': final,
... |
Ensures all values are encoded in UTF-8 and converts them to lowercase
def _utf8_encode(self, d):
"""
Ensures all values are encoded in UTF-8 and converts them to lowercase
"""
for k, v in d.items():
if isinstance(v, str):
d[k] = v.encode('utf8').low... |
Converts bool values to lowercase strings
def _bool_encode(self, d):
"""
Converts bool values to lowercase strings
"""
for k, v in d.items():
if isinstance(v, bool):
d[k] = str(v).lower()
return d |
Formats search parameters/values for use with API
:param \*\*kwargs: search parameters/values
def _options(self, **kwargs):
"""
Formats search parameters/values for use with API
:param \*\*kwargs: search parameters/values
"""
def _format_fq(d):... |
Calls the API and returns a dictionary of the search results
:param response_format: the format that the API uses for its response,
includes JSON (.json) and JSONP (.jsonp).
Defaults to '.json'.
:... |
Fully parses game summary report.
:returns: boolean success indicator
:rtype: bool
def parse(self):
"""Fully parses game summary report.
:returns: boolean success indicator
:rtype: bool """
r = super(GameSummRep, self).parse()
try:
self.parse_scoring_summary()
return r and ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.