text
stringlengths
81
112k
Plot the fitting given the fitted axis direction, the fitted center, the fitted radius and the data points. def show_fit(w_fit, C_fit, r_fit, Xs): '''Plot the fitting given the fitted axis direction, the fitted center, the fitted radius and the data points. ''' fig = plt.figure() ax = fig.gca(...
Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting to find how many characters before the first word found should be removed from the window def find_window(self, highlight_locations): """Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting to find how many characters before the first...
Private method for setting a cookie's value def __set(self, key, real_value, coded_value): """Private method for setting a cookie's value""" morse_set = self.get(key, StringMorsel()) morse_set.set(key, real_value, coded_value) dict.__setitem__(self, key, morse_set)
Try to login and set the internal session id. Please note: - Any failed login resets all existing session ids, even of other users. - SIDs expire after some time def login(self): """ Try to login and set the internal session id. Please note: - Any fai...
Calculate response for the challenge-response authentication def calculate_response(self, challenge, password): """Calculate response for the challenge-response authentication""" to_hash = (challenge + "-" + password).encode("UTF-16LE") hashed = hashlib.md5(to_hash).hexdigest() return "...
Returns a list of Actor objects for querying SmartHome devices. This is currently the only working method for getting temperature data. def get_actors(self): """ Returns a list of Actor objects for querying SmartHome devices. This is currently the only working method for getting tempe...
Return a actor identified by it's ain or return None def get_actor_by_ain(self, ain): """ Return a actor identified by it's ain or return None """ for actor in self.get_actors(): if actor.actor_id == ain: return actor
Call a switch method. Should only be used by internal library functions. def homeautoswitch(self, cmd, ain=None, param=None): """ Call a switch method. Should only be used by internal library functions. """ assert self.sid, "Not logged in" params = { ...
Get information about all actors This needs 1+(5n) requests where n = number of actors registered Deprecated, use get_actors instead. Returns a dict: [ain] = { 'name': Name of actor, 'state': Powerstate (boolean) 'present': Connected to server? (boo...
Return a list of devices. Deprecated, use get_actors instead. def get_devices(self): """ Return a list of devices. Deprecated, use get_actors instead. """ url = self.base_url + '/net/home_auto_query.lua' response = self.session.get(url, params={ 'sid'...
Return all available energy consumption data for the device. You need to divice watt_values by 100 and volt_values by 1000 to get the "real" values. :return: dict def get_consumption(self, deviceid, timerange="10"): """ Return all available energy consumption data for the devic...
Return the system logs since the last reboot. def get_logs(self): """ Return the system logs since the last reboot. """ assert BeautifulSoup, "Please install bs4 to use this method" url = self.base_url + "/system/syslog.lua" response = self.session.get(url, params={ ...
Returns True if the Hawk nonce has been seen already. def seen_nonce(id, nonce, timestamp): """ Returns True if the Hawk nonce has been seen already. """ key = '{id}:{n}:{ts}'.format(id=id, n=nonce, ts=timestamp) if cache.get(key): log.warning('replay attack? already processed nonce {k}' ...
FritzBox SmartHome Tool \b Provides the following functions: - A easy to use library for querying SmartHome actors - This CLI tool for testing - A carbon client for pipeing data into graphite def cli(context, host, username, password): """ FritzBox SmartHome Tool \b Provides the f...
Display a list of actors def actors(context): """Display a list of actors""" fritz = context.obj fritz.login() for actor in fritz.get_actors(): click.echo("{} ({} {}; AIN {} )".format( actor.name, actor.manufacturer, actor.productname, actor.acto...
Display energy stats of all actors def energy(context, features): """Display energy stats of all actors""" fritz = context.obj fritz.login() for actor in fritz.get_actors(): if actor.temperature is not None: click.echo("{} ({}): {:.2f} Watt current, {:.3f} wH total, {:.2f} °C".form...
Display energy stats of all actors def graphite(context, server, port, interval, prefix): """Display energy stats of all actors""" fritz = context.obj fritz.login() sid_ttl = time.time() + 600 # Find actors and create carbon keys click.echo(" * Requesting actors list") simple_chars = re.co...
Switch an actor's power to ON def switch_on(context, ain): """Switch an actor's power to ON""" context.obj.login() actor = context.obj.get_actor_by_ain(ain) if actor: click.echo("Switching {} on".format(actor.name)) actor.switch_on() else: click.echo("Actor not found: {}".fo...
Get an actor's power state def switch_state(context, ain): """Get an actor's power state""" context.obj.login() actor = context.obj.get_actor_by_ain(ain) if actor: click.echo("State for {} is: {}".format(ain,'ON' if actor.get_state() else 'OFF')) else: click.echo("Actor not found: {...
Toggle an actor's power state def switch_toggle(context, ain): """Toggle an actor's power state""" context.obj.login() actor = context.obj.get_actor_by_ain(ain) if actor: if actor.get_state(): actor.switch_off() click.echo("State for {} is now OFF".format(ain)) e...
Show system logs since last reboot def logs(context, format): """Show system logs since last reboot""" fritz = context.obj fritz.login() messages = fritz.get_logs() if format == "plain": for msg in messages: merged = "{} {} {}".format(msg.date, msg.time, msg.message.encode("UTF...
Returns the current power usage in milliWatts. Attention: Returns None if the value can't be queried or is unknown. def get_power(self): """ Returns the current power usage in milliWatts. Attention: Returns None if the value can't be queried or is unknown. """ value = se...
Returns the consumed energy since the start of the statistics in Wh. Attention: Returns None if the value can't be queried or is unknown. def get_energy(self): """ Returns the consumed energy since the start of the statistics in Wh. Attention: Returns None if the value can't be queried ...
Returns the current environment temperature. Attention: Returns None if the value can't be queried or is unknown. def get_temperature(self): """ Returns the current environment temperature. Attention: Returns None if the value can't be queried or is unknown. """ #raise N...
Returns the actual target temperature. Attention: Returns None if the value can't be queried or is unknown. def get_target_temperature(self): """ Returns the actual target temperature. Attention: Returns None if the value can't be queried or is unknown. """ value = self....
Sets the temperature in celcius def set_temperature(self, temp): """ Sets the temperature in celcius """ # Temperature is send to fritz.box a little weird param = 16 + ( ( temp - 8 ) * 2 ) if param < 16: param = 253 logger.info("Actor " + self.na...
https://<host>[:<port>]/ :return: str def get_openshift_base_uri(self): """ https://<host>[:<port>]/ :return: str """ deprecated_key = "openshift_uri" key = "openshift_url" val = self._get_value(deprecated_key, self.conf_section, deprecated_key) ...
url of OpenShift where builder will connect def get_builder_openshift_url(self): """ url of OpenShift where builder will connect """ key = "builder_openshift_url" url = self._get_deprecated(key, self.conf_section, key) if url is None: logger.warning("%r not found, falling ba...
helper method for generating nodeselector dict :param nodeselector_str: :return: dict def generate_nodeselector_dict(self, nodeselector_str): """ helper method for generating nodeselector dict :param nodeselector_str: :return: dict """ nodeselector = {} ...
search the configuration for entries of the form node_selector.platform :param platform: str, platform to search for, can be null :return dict def get_platform_node_selector(self, platform): """ search the configuration for entries of the form node_selector.platform :param platf...
Extract tabular data as |TableData| instances from a CSV 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 CSV text object. |load_source_desc_text| :return: Loaded table data. |load_table_name_desc| =================== ======================================== Format specifier Value after the replacemen...
set parameters according to specification these parameters are accepted: :param pulp_secret: str, resource name of pulp secret :param koji_target: str, koji tag with packages used to build the image :param kojiroot: str, URL from which koji packages are fetched :param kojihub: ...
Return True if this BuildConfig has ImageStreamTag trigger. def has_ist_trigger(self): """Return True if this BuildConfig has ImageStreamTag trigger.""" triggers = self.template['spec'].get('triggers', []) if not triggers: return False for trigger in triggers: if...
Sets secret for plugin, if no plugin specified it will also set general secret :param secret: str, secret name :param plugin: tuple, (plugin type, plugin name, argument name) :param mount_path: str, mount path of secret def set_secret_for_plugin(self, secret, plugin=None, mount_path=No...
:param secrets: dict, {(plugin type, plugin name, argument name): secret name} for example {('exit_plugins', 'koji_promote', 'koji_ssl_certs'): 'koji_ssl_certs', ...} def set_secrets(self, secrets): """ :param secrets: dict, {(plugin type, plugin name, argument name): secret name} ...
Remove matching entries from tag_and_push_registries (in-place) :param tag_and_push_registries: dict, uri -> dict :param version: str, 'version' to match against def remove_tag_and_push_registries(tag_and_push_registries, version): """ Remove matching entries from tag_and_push_registri...
Enable/disable plugins depending on supported registry API versions def adjust_for_registry_api_versions(self): """ Enable/disable plugins depending on supported registry API versions """ versions = self.spec.registry_api_versions.value if 'v2' not in versions: rais...
Remove trigger-related plugins when needed If there are no triggers defined, it's assumed the feature is disabled and all trigger-related plugins are removed. If there are triggers defined, and this is a custom base image, some trigger-related plugins do not apply. Add...
Remove certain plugins in order to handle the "scratch build" scenario. Scratch builds must not affect subsequent builds, and should not be imported into Koji. def adjust_for_scratch(self): """ Remove certain plugins in order to handle the "scratch build" scenario. Scratch build...
Disable plugins to handle builds depending on whether or not this is a build from a custom base image. def adjust_for_custom_base_image(self): """ Disable plugins to handle builds depending on whether or not this is a build from a custom base image. """ plugins = [] ...
if there is yum repo specified, don't pick stuff from koji def render_koji(self): """ if there is yum repo specified, don't pick stuff from koji """ phase = 'prebuild_plugins' plugin = 'koji' if not self.dj.dock_json_has_plugin_conf(phase, plugin): return ...
If the bump_release plugin is present, configure it def render_bump_release(self): """ If the bump_release plugin is present, configure it """ phase = 'prebuild_plugins' plugin = 'bump_release' if not self.dj.dock_json_has_plugin_conf(phase, plugin): return ...
if we have smtp_host and smtp_from, configure sendmail plugin, else remove it def render_sendmail(self): """ if we have smtp_host and smtp_from, configure sendmail plugin, else remove it """ phase = 'exit_plugins' plugin = 'sendmail' if not self.dj.dock_j...
Configure fetch_maven_artifacts plugin def render_fetch_maven_artifacts(self): """Configure fetch_maven_artifacts plugin""" phase = 'prebuild_plugins' plugin = 'fetch_maven_artifacts' if not self.dj.dock_json_has_plugin_conf(phase, plugin): return koji_hub = self.sp...
Configure tag_from_config plugin 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.spec.image_tag.value.split(':')[-1] ...
If a pulp registry is specified, use pulp_pull plugin def render_pulp_pull(self): """ If a pulp registry is specified, use pulp_pull plugin """ # pulp_pull is a multi-phase plugin phases = ('postbuild_plugins', 'exit_plugins') plugin = 'pulp_pull' for phase in ph...
If a pulp registry is specified, use the pulp plugin as well as the delete_from_registry to delete the image after sync def render_pulp_sync(self): """ If a pulp registry is specified, use the pulp plugin as well as the delete_from_registry to delete the image after sync """ ...
Configure the pulp_tag plugin. def render_pulp_tag(self): """ Configure the pulp_tag plugin. """ if not self.dj.dock_json_has_plugin_conf('postbuild_plugins', 'pulp_tag'): return pulp_registry = self.spec.pulp_registr...
Configure the group_manifests plugin. Group is always set to false for now. def render_group_manifests(self): """ Configure the group_manifests plugin. Group is always set to false for now. """ if not self.dj.dock_json_has_plugin_conf('postbuild_plugins', 'group_manifests'): ...
Configure the import_image plugin def render_import_image(self, use_auth=None): """ Configure the import_image plugin """ # import_image is a multi-phase plugin phases = ('postbuild_plugins', 'exit_plugins') plugin = 'import_image' for phase in phases: ...
Customize prod_inner for site specific customizations def render_customizations(self): """ Customize prod_inner for site specific customizations """ disable_plugins = self.customize_conf.get('disable_plugins', []) if not disable_plugins: logger.debug("No site-specif...
Sets the Build/BuildConfig object name def render_name(self, name, image_tag, platform): """Sets the Build/BuildConfig object name""" if self.scratch or self.isolated: name = image_tag # Platform name may contain characters not allowed by OpenShift. if platform: ...
Only used for setting up the testing framework. def setup_json_capture(osbs, os_conf, capture_dir): """ Only used for setting up the testing framework. """ try: os.mkdir(capture_dir) except OSError: pass finally: osbs.os._con.request = ResponseSaver(capture_dir, ...
get size of console: rows x columns :return: tuple, (int, int) def get_terminal_size(): """ get size of console: rows x columns :return: tuple, (int, int) """ try: rows, columns = subprocess.check_output(['stty', 'size']).split() except subprocess.CalledProcessError: # not...
get size of longest value in specific column :param col: str, column name :return int def _longest_val_in_column(self, col): """ get size of longest value in specific column :param col: str, column name :return int """ try: # +2 is for impli...
initialize all values based on provided input :return: None def _init(self): """ initialize all values based on provided input :return: None """ self.col_count = len(self.col_list) # list of lengths of longest entries in columns self.col_longest = self....
count all values needed to display whole table <><---terminal-width-----------><> <> HEADER | HEADER2 | HEADER3 <> <>---------+----------+---------<> kudos to PostgreSQL developers :return: None def _count_sizes(self): """ count all values needed to display...
iterate over all columns and get their longest values :return: dict, {"column_name": 132} def get_all_longest_col_lengths(self): """ iterate over all columns and get their longest values :return: dict, {"column_name": 132} """ response = {} for col in self.col_...
get a width of separator for current column :return: int def _separate(self): """ get a width of separator for current column :return: int """ if self.total_free_space is None: return 0 else: sepa = self.default_column_space ...
print provided table :return: None def render(self): """ print provided table :return: None """ print(self.format_str.format(**self.header), file=sys.stderr) print(self.header_format_str.format(**self.header_data), file=sys.stderr) for row in self.data:...
:raises ValidationError: def _validate_source_data(self): """ :raises ValidationError: """ try: jsonschema.validate(self._buffer, self._schema) except jsonschema.ValidationError as e: raise ValidationError(e)
:raises ValueError: :raises pytablereader.error.ValidationError: def to_table_data(self): """ :raises ValueError: :raises pytablereader.error.ValidationError: """ self._validate_source_data() self._loader.inc_table_count() yield TableData( s...
:raises ValueError: :raises pytablereader.error.ValidationError: def to_table_data(self): """ :raises ValueError: :raises pytablereader.error.ValidationError: """ self._validate_source_data() for table_key, json_records in six.iteritems(self._buffer): ...
:raises ValueError: :raises pytablereader.error.ValidationError: def to_table_data(self): """ :raises ValueError: :raises pytablereader.error.ValidationError: """ self._validate_source_data() for table_key, json_records in six.iteritems(self._buffer): ...
:raises ValueError: :raises pytablereader.error.ValidationError: def to_table_data(self): """ :raises ValueError: :raises pytablereader.error.ValidationError: """ self._validate_source_data() for table_key, json_records in six.iteritems(self._buffer): ...
set parameters in the user parameters these parameters are accepted: :param git_uri: str, uri of the git repository for the source :param git_ref: str, commit ID of the branch to be pulled :param git_branch: str, branch name of the branch to be pulled :param base_image: str, nam...
Sets data from reactor config def set_data_from_reactor_config(self): """ Sets data from reactor config """ reactor_config_override = self.user_params.reactor_config_override.value reactor_config_map = self.user_params.reactor_config_map.value data = None if rea...
Sets required secrets def _set_required_secrets(self, required_secrets, token_secrets): """ Sets required secrets """ if self.user_params.build_type.value == BUILD_TYPE_ORCHESTRATOR: required_secrets += token_secrets if not required_secrets: return ...
if config contains plugin, remove it def remove_plugin(self, phase, name, reason=None): """ if config contains plugin, remove it """ for p in self.template[phase]: if p.get('name') == name: self.template[phase].remove(p) if reason: ...
if config has plugin, override it, else add it def add_plugin(self, phase, name, args, reason=None): """ if config has plugin, override it, else add it """ plugin_modified = False for plugin in self.template[phase]: if plugin['name'] == name: plugin[...
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 get_plugin_conf(self, phase, name): """ Return the configuration for a plugin. Raises KeyError if there are no plugins of that ...
Check whether a plugin is configured. def has_plugin_conf(self, phase, name): """ Check whether a plugin is configured. """ try: self.get_plugin_conf(phase, name) return True except (KeyError, IndexError): return False
Remove certain plugins in order to handle the "scratch build" scenario. Scratch builds must not affect subsequent builds, and should not be imported into Koji. def adjust_for_scratch(self): """ Remove certain plugins in order to handle the "scratch build" scenario. Scratch build...
Remove certain plugins in order to handle the "isolated build" scenario. def adjust_for_isolated(self): """ Remove certain plugins in order to handle the "isolated build" scenario. """ if self.user_params.isolated.value: remove_plugins = [ ("p...
Remove plugins that don't work when building Flatpaks def adjust_for_flatpak(self): """ Remove plugins that don't work when building Flatpaks """ if self.user_params.flatpak.value: remove_plugins = [ ("prebuild_plugins", "resolve_composes"), #...
Customize template for site user specified customizations def render_customizations(self): """ Customize template for site user specified customizations """ disable_plugins = self.pt.customize_conf.get('disable_plugins', []) if not disable_plugins: logger.debug('No s...
if there is yum repo in user params, don't pick stuff from koji def render_koji(self): """ if there is yum repo in user params, don't pick stuff from koji """ phase = 'prebuild_plugins' plugin = 'koji' if not self.pt.has_plugin_conf(phase, plugin): return ...
If the bump_release plugin is present, configure it 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...
If the check_and_set_platforms plugin is present, configure it 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(ph...
Configure the import_image plugin 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 tag_from_config plugin 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(':...
Configure pull_base_image 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', ...
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 def get_user(self, username="~"): """ get info about user (if no user specified, use the one initiating request) :param us...
:return: 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"})
Returns all builds matching a given set of label selectors. It is up to the calling function to filter the results. 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 ...
Returns a build config matching the given label selectors. This method will raise OsbsException if not exactly one build config is found. def get_build_config_by_labels(self, label_selectors): """ Returns a build config matching the given label selectors. This method will raise ...
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. def get_build_config_by_labels_filtered(self, label_selectors, filter_key, filter_value): """ ...
:return: 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"})
stream logs from build :param build_id: str :return: iterator 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...
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 def logs(self, build_id, follow=False, build...
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 def list_builds(self, build_config_id=None, koji_t...
Prevent builds being scheduled and wait for running builds to finish. :return: 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/") ...
:param build_id: wait for build to finish :return: 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): ...
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' :...
set annotations on build object :param build_id: str, id of build :param annotations: dict, annotations to set :return: def update_annotations_on_build(self, build_id, annotations): """ set annotations on build object :param build_id: str, id of build :param an...
Import image tags from a Docker registry into an ImageStream :return: bool, whether tags were imported 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 """ ...
Import image tags from a Docker registry into an ImageStream :return: bool, whether tags were imported 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 import...
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 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, unic...
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...