code stringlengths 1 18.2k |
|---|
def loadable_modules(self): '''The list of loadable module profile dictionaries.''' with self._mutex: if not self._loadable_modules: self._loadable_modules = [] for mp in self._obj.get_loadable_modules(): self._loadable_modules.append(utils.nvlist_to_dict(mp.properties)) return self._loadable_modules |
def loaded_modules(self): '''The list of loaded module profile dictionaries.''' with self._mutex: if not self._loaded_modules: self._loaded_modules = [] for mp in self._obj.get_loaded_modules(): self._loaded_modules.append(utils.nvlist_to_dict(mp.properties)) return self._loaded_modules |
def slaves(self): '''The list of slave managers of this manager, if any. This information can also be found by listing the children of this node that are of type @ref Manager. ''' with self._mutex: if not self._slaves: self._slaves = [c for c in self.children if c.is_manager] return self._slaves |
def authenticate_credentials(self, request, access_token): """ Authenticate the request, given the access token. """ try: token = oauth2_provider.oauth2.models.AccessToken.objects.select_related('user') # provider_now switches to timezone aware datetime when # the oauth2_provider version supports to it. token = token.g... |
def request(self, *args, **kwargs): """ The main purpose of this is to be a wrapper-like function to pass the api_token and all the other params to the requests that are being made :returns: An instance of RequestsHandler """ return RequestsHandler(*args, api_token=self.api_token, verify=self.mist_client.verify, job_id... |
def delete(self): """ Delete the cloud from the list of added clouds in mist.io service. :returns: A list of mist.clients' updated clouds. """ req = self.request(self.mist_client.uri + '/clouds/' + self.id) req.delete() self.mist_client.update_clouds() |
def enable(self): """ Enable the Cloud. :returns: A list of mist.clients' updated clouds. """ payload = { "new_state": "1" } data = json.dumps(payload) req = self.request(self.mist_client.uri+'/clouds/'+self.id, data=data) req.post() self.enabled = True self.mist_client.update_clouds() |
def disable(self): """ Disable the Cloud. :returns: A list of mist.clients' updated clouds. """ payload = { "new_state": "0" } data = json.dumps(payload) req = self.request(self.mist_client.uri+'/clouds/'+self.id, data=data) req.post() self.enabled = False self.mist_client.update_clouds() |
def sizes(self): """ Available machine sizes to be used when creating a new machine. :returns: A list of available machine sizes. """ req = self.request(self.mist_client.uri+'/clouds/'+self.id+'/sizes') sizes = req.get().json() return sizes |
def locations(self): """ Available locations to be used when creating a new machine. :returns: A list of available locations. """ req = self.request(self.mist_client.uri+'/clouds/'+self.id+'/locations') locations = req.get().json() return locations |
def networks(self): """ Available networks. :returns: A list of available networks associated to a provider. """ if self.provider in ['openstack', 'nephoscale']: req = self.request(self.mist_client.uri+'/clouds/'+self.id+'/networks') networks = req.get().json() return networks else: print "Network actions not supported... |
def images(self): """ Available images to be used when creating a new machine. :returns: A list of all available images. """ req = self.request(self.mist_client.uri+'/clouds/'+self.id+'/images') images = req.get().json() return images |
def search_image(self, search_term): """ Search for a specific image by providing a search term (mainly used with ec2's community and public images) :param search_term: Search term to be used when searching for images's names containing this term. :returns: A list of all images, whose names contain the given search_ter... |
def _list_machines(self): """ Request a list of all added machines. Populates self._machines dict with mist.client.model.Machine instances """ try: req = self.request(self.mist_client.uri+'/clouds/'+self.id+'/machines') machines = req.get().json() except: # Eg invalid cloud credentials machines = {} if machines: for ma... |
def machines(self, id=None, name=None, search=None): """ Property-like function to call the _list_machines function in order to populate self._machines dict :returns: A list of Machine instances. """ if self._machines is None: self._machines = {} self._list_machines() if id: return [self._machines[machine_id] for machi... |
def create_machine(self, name, key, image_id, location_id, size_id, image_extra="", disk="", script="", monitoring=False, ips=[], networks=[], location_name="", async=False, docker_command="", quantity=1, persist=False, fire_and_forget=True, timeout=6000, script_id="", script_params="", verbose=False, associate_floatin... |
'size': size_id, 'image_extra': image_extra, 'disk': disk, 'script': script, 'monitoring': monitoring, 'ips': ips, 'networks': networks, 'location_name': location_name, 'docker_command': docker_command, 'async': async, 'quantity': quantity, 'persist': persist, 'associate_floating_ip': associate_floating_ip, 'tags': tag... |
machines_created[state] = '%s/%s' % (creates.get(state, 'Undefined'), quantity) x.add_row(["Create:", machines_created['success'], machines_created['error'], machines_created['skipped'], machines_created['pending']]) if probes: probed_machines = {} for state in states: probed_machines[state] = '%s/%s' % (probes.get(sta... |
[]): if log.get('machine_name', '') == name and \ 'machine_creation_finished' in log.values(): machine_id = log['machine_id'] error = log.get('error') break else: sleep(5) continue if error: provision_finished = True else: for log in job.get('logs', []): if log.get('machine_id', '') == machine_id and \ 'post_deploy_fin... |
def _machine_actions(self, action): """ Actions for the machine (e.g. stop, start etc) :param action: Can be "reboot", "start", "stop", "destroy" :returns: An updated list of the added machines """ payload = { 'action': action } data = json.dumps(payload) req = self.request(self.mist_client.uri+'/clouds/'+self.cloud.id... |
def probe(self, key_id=None, ssh_user=None): """ If no parameter is provided, mist.io will try to probe the machine with the default :param key_id: Optional. Give if you explicitly want to probe with this key_id :param ssh_user: Optional. Give if you explicitly want a specific user :returns: A list of data received by ... |
def _toggle_monitoring(self, action, no_ssh=False): """ Enable or disable monitoring on a machine :param action: Can be either "enable" or "disable" """ payload = { 'action': action, 'name': self.name, 'no_ssh': no_ssh, 'public_ips': self.info['public_ips'], 'dns_name': self.info['extra'].get('dns_name', 'n/a') } data ... |
def get_stats(self, start=int(time()), stop=int(time())+10, step=10): """ Get stats of a monitored machine :param start: Time formatted as integer, from when to fetch stats (default now) :param stop: Time formatted as integer, until when to fetch stats (default +10 seconds) :param step: Step to fetch stats (default 10 ... |
def available_metrics(self): """ List all available metrics that you can add to this machine :returns: A list of dicts, each of which is a metric that you can add to a monitored machine """ req = self.request(self.mist_client.uri+"/clouds/"+self.cloud.id+"/machines/"+self.id+"/metrics") metrics = req.get().json() retur... |
def add_metric(self, metric_id): """ Add a metric to a monitored machine :param metric_id: Metric_id (provided by self.available_metrics) """ payload = { 'metric_id': metric_id } data = json.dumps(payload) req = self.request(self.mist_client.uri+"/clouds/"+self.cloud.id+"/machines/"+self.id+"/metrics", data=data) req.p... |
def remove_metric(self, metric_id): """ Remove a metric from a monitored machine :param metric_id: Metric_id (provided by self.get_stats() ) """ payload = { 'metric_id': metric_id } data = json.dumps(payload) req = self.request(self.mist_client.uri+"/clouds/"+self.cloud.id+"/machines/"+self.id+"/metrics", data=data) re... |
def add_python_plugin(self, name, python_file, value_type="gauge", unit=None): """ Add a custom python plugin to the collectd instance of a monitored plugin :param python_file: Path of the python file to be added as custom python plugin :param name: Name of the plugin :param value_type: Optional. Can be either "gauge" ... |
plugin_id = re.sub(pattern, "_", plugin_id) #Plugin id should not have double underscores while "__" in plugin_id: pattern = "\r?__" plugin_id = re.sub(pattern, "_", plugin_id) #Plugin id should not have underscore as first or last char if plugin_id[-1] == "_": plugin_id = plugin_id[:-2] if plugin_id[0] == "_": plugin_... |
def private(self): """ Return the private ssh-key :returns: The private ssh-key as string """ req = self.request(self.mist_client.uri+'/keys/'+self.id+"/private") private = req.get().json() return private |
def public(self): """ Return the public ssh-key :returns: The public ssh-key as string """ req = self.request(self.mist_client.uri+'/keys/'+self.id+"/public") public = req.get().json() return public |
def rename(self, new_name): """ Rename a key :param new_name: New name for the key (will also serve as the key's id) :returns: An updated list of added keys """ payload = { 'new_name': new_name } data = json.dumps(payload) req = self.request(self.mist_client.uri+'/keys/'+self.id, data=data) req.put() self.id = new_name... |
def set_default(self): """ Set this key as the default key :returns: An updated list of added keys """ req = self.request(self.mist_client.uri+'/keys/'+self.id) req.post() self.is_default = True self.mist_client.update_keys() |
def delete(self): """ Delete this key from mist.io :returns: An updated list of added keys """ req = self.request(self.mist_client.uri+'/keys/'+self.id) req.delete() self.mist_client.update_keys() |
def status(self, value): """ Property for getting or setting the bug status >>> bug.status = "REOPENED" """ if self._bug.get('id', None): if value in VALID_STATUS: self._bug['status'] = value else: raise BugException("Invalid status type was used") else: raise BugException("Can not set status unless there is a bug id."... |
def update(self): """ Update this object with the latest changes from Bugzilla >>> bug.status 'NEW' #Changes happen on Bugzilla >>> bug.update() >>> bug.status 'FIXED' """ if 'id' in self._bug: result = self._bugsy.request('bug/%s' % self._bug['id']) self._bug = dict(**result['bugs'][0]) else: raise BugException("Unabl... |
def get_comments(self): """ Obtain comments for this bug. Returns a list of Comment instances. """ bug = str(self._bug['id']) res = self._bugsy.request('bug/%s/comment' % bug) return [Comment(bugsy=self._bugsy, **comments) for comments in res['bugs'][bug]['comments']] |
def add_comment(self, comment): """ Adds a comment to a bug. If the bug object does not have a bug ID (ie you are creating a bug) then you will need to also call `put` on the :class:`Bugsy` class. >>> bug.add_comment("I like sausages") >>> bugzilla.put(bug) If it does have a bug id then this will immediately post to th... |
def add_tags(self, tags): """ Add tags to the comments """ if not isinstance(tags, list): tags = [tags] self._bugsy.request('bug/comment/%s/tags' % self._comment['id'], method='PUT', json={"add": tags}) |
def _readuntil(f, end=_TYPE_END): """Helper function to read bytes until a certain end byte is hit""" buf = bytearray() byte = f.read(1) while byte != end: if byte == b'': raise ValueError('File ended unexpectedly. Expected end byte {}.'.format(end)) buf += byte byte = f.read(1) return buf |
def _decode_buffer(f): """ String types are normal (byte)strings starting with an integer followed by ':' which designates the string’s length. Since there’s no way to specify the byte type in bencoded files, we have to guess """ strlen = int(_readuntil(f, _TYPE_SEP)) buf = f.read(strlen) if not len(buf) == strlen: rai... |
def bdecode(f_or_data): """ bdecodes data by looking up the type byte, and using it to look up the respective decoding function, which in turn is used to return the decoded object The parameter can be a file opened in bytes mode, bytes or a string (the last of which will be decoded) """ if isinstance(f_or_data, str): f... |
def _encode_buffer(string, f): """Writes the bencoded form of the input string or bytes""" if isinstance(string, str): string = string.encode() f.write(str(len(string)).encode()) f.write(_TYPE_SEP) f.write(string) |
def _encode_mapping(mapping, f): """Encodes the mapping items in lexical order (spec)""" f.write(_TYPE_DICT) for key, value in sorted(mapping.items()): _encode_buffer(key, f) bencode(value, f) f.write(_TYPE_END) |
def bencode(data, f=None): """ Writes a serializable data piece to f The order of tests is nonarbitrary, as strings and mappings are iterable. If f is None, it writes to a byte buffer and returns a bytestring """ if f is None: f = BytesIO() _bencode_to_file(data, f) return f.getvalue() else: _bencode_to_file(data, f) |
def main(args=None): """Decodes bencoded files to python syntax (like JSON, but with bytes support)""" import sys, pprint from argparse import ArgumentParser, FileType parser = ArgumentParser(description=main.__doc__) parser.add_argument('infile', nargs='?', type=FileType('rb'), default=sys.stdin.buffer, help='bencoded... |
def command(state, args): """Watch an anime.""" if len(args) < 2: print(f'Usage: {args[0]} {{ID|aid:AID}} [EPISODE]') return aid = state.results.parse_aid(args[1], default_key='db') anime = query.select.lookup(state.db, aid) if len(args) < 3: episode = anime.watched_episodes + 1 else: episode = int(args[2]) anime_files... |
def patch_connection(filename=':memory:'): """ ``filename``: rlite filename to store db in, or memory Patch the redis-py Connection and the static from_url() of Redis and StrictRedis to use RliteConnection """ if no_redis: raise Exception("redis package not found, please install redis-py via 'pip install redis'") Rlite... |
def fix_even_row_data_fc(fdata): """When the number of rows in fdata is even, there is a subtlety that must be taken care of if fdata is to satisfy the symmetry required for further processing. For an array length of 6,the data is align as [0 1 2 -3 -2 -1] this routine simply sets the row corresponding to the -3 index ... |
def sin_fc(fdata): """Apply sine in the Fourier domain.""" nrows = fdata.shape[0] ncols = fdata.shape[1] M = nrows / 2 fdata[int(M - 1), :] = 0 fdata[int(M + 1), :] = 0 work1 = np.zeros([nrows, ncols], dtype=np.complex128) work2 = np.zeros([nrows, ncols], dtype=np.complex128) work1[0, :] = fdata[-1, :] work1[1:, :] = f... |
def divsin_fc(fdata): """Apply divide by sine in the Fourier domain.""" nrows = fdata.shape[0] ncols = fdata.shape[1] L = int(nrows / 2) # Assuming nrows is even, which it should be. L2 = L - 2 # This is the last index in the recursion for division by sine. g = np.zeros([nrows, ncols], dtype=np.complex128) g[L2, :] = 2... |
def dphi_fc(fdata): """Apply phi derivative in the Fourier domain.""" nrows = fdata.shape[0] ncols = fdata.shape[1] B = int(ncols / 2) # As always, we assume nrows and ncols are even a = list(range(0, int(B))) ap = list(range(-int(B), 0)) a.extend(ap) dphi = np.zeros([nrows, ncols], np.complex128) for k in xrange(0, nr... |
def sinLdot_fc(tfdata, pfdata): """Apply sin of theta times the L operator to the data in the Fourier domain.""" dphi_fc(tfdata) sin_fc(pfdata) dtheta_fc(pfdata) return 1j * (tfdata - pfdata) |
def L_fc(fdata): """Apply L in the Fourier domain.""" fd = np.copy(fdata) dphi_fc(fdata) divsin_fc(fdata) dtheta_fc(fd) return (1j * fdata, -1j * fd) |
def extract(dump_files, extractors=ALL_EXTRACTORS): """ Extracts cites from a set of `dump_files`. :Parameters: dump_files : str | `file` A set of files MediaWiki XML dump files (expects: pages-meta-history) extractors : `list`(`extractor`) A list of extractors to apply to the text :Returns: `iterable` -- a generator o... |
def extract_cite_history(page, extractors): """ Extracts cites from the history of a `page` (`mwxml.Page`). :Parameters: page : `iterable`(`mwxml.Revision`) The page to extract cites from extractors : `list`(`extractor`) A list of extractors to apply to the text :Returns: `iterable` -- a generator of extracted cites ""... |
def extract_ids(text, extractors): """ Uses `extractors` to extract citation identifiers from a text. :Parameters: text : str The text to process extractors : `list`(`extractor`) A list of extractors to apply to the text :Returns: `iterable` -- a generator of extracted identifiers """ for extractor in extractors: for i... |
def add_members(self, rtcs): '''Add other RT Components to this composite component as members. This component must be a composite component. ''' if not self.is_composite: raise exceptions.NotCompositeError(self.name) for rtc in rtcs: if self.is_member(rtc): raise exceptions.AlreadyInCompositionError(self.name, rtc.ins... |
def remove_members(self, rtcs): '''Remove other RT Components from this composite component. rtcs is a list of components to remove. Each element must be either an rtctree.Component object or a string containing a component's instance name. rtctree.Component objects are more reliable. This component must be a composite... |
def is_member(self, rtc): '''Is the given component a member of this composition? rtc may be a Component object or a string containing a component's instance name. Component objects are more reliable. Returns False if the given component is not a member of this composition. Raises NotCompositeError if this component is... |
def members(self): '''Member components if this component is composite.''' with self._mutex: if not self._members: self._members = {} for o in self.organisations: # TODO: Search for these in the tree self._members[o.org_id] = o.obj.get_members() return self._members |
def organisations(self): '''The organisations of this composition.''' class Org: def __init__(self, sdo_id, org_id, members, obj): self.sdo_id = sdo_id self.org_id = org_id self.members = members self.obj = obj with self._mutex: if not self._orgs: for org in self._obj.get_owned_organizations(): owner = org.get_owner() ... |
def parent_org_sdo_ids(self): '''The SDO IDs of the compositions this RTC belongs to.''' return [sdo.get_owner()._narrow(SDOPackage.SDO).get_sdo_id() \ for sdo in self._obj.get_organizations() if sdo] |
def parent_organisations(self): '''The organisations this RTC belongs to.''' class ParentOrg: def __init__(self, sdo_id, org_id): self.sdo_id = sdo_id self.org_id = org_id with self._mutex: if not self._parent_orgs: for sdo in self._obj.get_organizations(): if not sdo: continue owner = sdo.get_owner() if owner: sdo_id ... |
def activate_in_ec(self, ec_index): '''Activate this component in an execution context. @param ec_index The index of the execution context to activate in. This index is into the total array of contexts, that is both owned and participating contexts. If the value of ec_index is greater than the length of @ref owned_ecs,... |
def deactivate_in_ec(self, ec_index): '''Deactivate this component in an execution context. @param ec_index The index of the execution context to deactivate in. This index is into the total array of contexts, that is both owned and participating contexts. If the value of ec_index is greater than the length of @ref owne... |
def get_ec(self, ec_handle): '''Get a reference to the execution context with the given handle. @param ec_handle The handle of the execution context to look for. @type ec_handle str @return A reference to the ExecutionContext object corresponding to the ec_handle. @raises NoECWithHandleError ''' with self._mutex: for e... |
def get_ec_index(self, ec_handle): '''Get the index of the execution context with the given handle. @param ec_handle The handle of the execution context to look for. @type ec_handle str @return The index into the owned + participated arrays, suitable for use in methods such as @ref activate_in_ec, or -1 if the EC was n... |
def get_state_string(self, add_colour=True): '''Get the state of this component as an optionally-coloured string. @param add_colour If True, ANSI colour codes will be added to the string. @return A string describing the state of this component. ''' with self._mutex: if self.state == self.INACTIVE: result = 'Inactive', ... |
def get_state_in_ec_string(self, ec_index, add_colour=True): '''Get the state of the component in an execution context as a string. @param ec_index The index of the execution context to check the state in. This index is into the total array of contexts, that is both owned and participating contexts. If the value of ec_... |
== self.UNKNOWN: result = 'Unknown', ['bold', 'red'] elif state == self.CREATED: result = 'Created', ['reset'] if add_colour: return utils.build_attr_string(result[1], supported=add_colour) + \ result[0] + utils.build_attr_string('reset', supported=add_colour) else: return result[0] |
def reset_in_ec(self, ec_index): '''Reset this component in an execution context. @param ec_index The index of the execution context to reset in. This index is into the total array of contexts, that is both owned and participating contexts. If the value of ec_index is greater than the length of @ref owned_ecs, that len... |
def state_in_ec(self, ec_index): '''Get the state of the component in an execution context. @param ec_index The index of the execution context to check the state in. This index is into the total array of contexts, that is both owned and participating contexts. If the value of ec_index is greater than the length of @ref... |
def refresh_state_in_ec(self, ec_index): '''Get the up-to-date state of the component in an execution context. This function will update the state, rather than using the cached value. This may take time, if the component is executing on a remote node. @param ec_index The index of the execution context to check the stat... |
def alive(self): '''Is this component alive?''' with self._mutex: if self.exec_contexts: for ec in self.exec_contexts: if self._obj.is_alive(ec): return True return False |
def owned_ec_states(self): '''The state of each execution context this component owns.''' with self._mutex: if not self._owned_ec_states: if self.owned_ecs: states = [] for ec in self.owned_ecs: states.append(self._get_ec_state(ec)) self._owned_ec_states = states else: self._owned_ec_states = [] return self._owned_ec_s... |
def owned_ecs(self): '''A list of the execution contexts owned by this component.''' with self._mutex: if not self._owned_ecs: self._owned_ecs = [ExecutionContext(ec, self._obj.get_context_handle(ec)) \ for ec in self._obj.get_owned_contexts()] return self._owned_ecs |
def participating_ec_states(self): '''The state of each execution context this component is participating in. ''' with self._mutex: if not self._participating_ec_states: if self.participating_ecs: states = [] for ec in self.participating_ecs: states.append(self._get_ec_state(ec)) self._participating_ec_states = states ... |
def participating_ecs(self): '''A list of the execution contexts this component is participating in. ''' with self._mutex: if not self._participating_ecs: self._participating_ecs = [ExecutionContext(ec, self._obj.get_context_handle(ec)) \ for ec in self._obj.get_participating_contexts()] return self._participating_ecs |
def state(self): '''The merged state of all the execution context states, which can be used as the overall state of this component. The order of precedence is: Error > Active > Inactive > Created > Unknown ''' def merge_state(current, new): if new == self.ERROR: return self.ERROR elif new == self.ACTIVE and current != ... |
return merged_state |
def get_extended_fsm_service(self): '''Get a reference to the ExtendedFsmService. @return A reference to the ExtendedFsmService object @raises InvalidSdoServiceError ''' with self._mutex: try: return self._obj.get_sdo_service(RTC.ExtendedFsmService._NP_RepositoryId)._narrow(RTC.ExtendedFsmService) except: raise excepti... |
def get_port_by_name(self, port_name): '''Get a port of this component by name.''' with self._mutex: for p in self.ports: if p.name == port_name: return p return None |
def get_port_by_ref(self, port_ref): '''Get a port of this component by reference to a CORBA PortService object. ''' with self._mutex: for p in self.ports: if p.object._is_equivalent(port_ref): return p return None |
def has_port_by_name(self, port_name): '''Check if this component has a port by the given name.''' with self._mutex: if self.get_port_by_name(port_name): return True return False |
def has_port_by_ref(self, port_ref): '''Check if this component has a port by the given reference to a CORBA PortService object. ''' with self._mutex: if self.get_port_by_ref(self, port_ref): return True return False |
def connected_inports(self): '''The list of all input ports belonging to this component that are connected to one or more other ports. ''' return [p for p in self.ports \ if p.__class__.__name__ == 'DataInPort' and p.is_connected] |
def connected_outports(self): '''The list of all output ports belonging to this component that are connected to one or more other ports. ''' return [p for p in self.ports \ if p.__class__.__name__ == 'DataOutPort' \ and p.is_connected] |
def connected_svcports(self): '''The list of all service ports belonging to this component that are connected to one or more other ports. ''' return [p for p in self.ports \ if p.__class__.__name__ == 'CorbaPort' and p.is_connected] |
def ports(self): '''The list of all ports belonging to this component.''' with self._mutex: if not self._ports: self._ports = [ports.parse_port(port, self) \ for port in self._obj.get_ports()] return self._ports |
def add_logger(self, cb, level='NORMAL', filters='ALL'): '''Add a callback to receive log events from this component. @param cb The callback function to receive log events. It must have the signature cb(name, time, source, level, message), where name is the name of the component the log record came from, time is a floa... |
uuid.uuid4() intf_type = obs._this()._NP_RepositoryId props = {'logger.log_level': level, 'logger.filter': filters} props = utils.dict_to_nvlist(props) sprof = SDOPackage.ServiceProfile(id=uuid_val.get_bytes(), interface_type=intf_type, service=obs._this(), properties=props) conf = self.object.get_configuration() res =... |
def remove_logger(self, cb_id): '''Remove a logger. @param cb_id The ID of the logger to remove. @raises NoLoggerError ''' if cb_id not in self._loggers: raise exceptions.NoLoggerError(cb_id, self.name) conf = self.object.get_configuration() res = conf.remove_service_profile(cb_id.get_bytes()) del self._loggers[cb_id] |
def activate_conf_set(self, set_name): '''Activate a configuration set by name. @raises NoSuchConfSetError ''' with self._mutex: if not set_name in self.conf_sets: raise exceptions.NoSuchConfSetError(set_name) self._conf.activate_configuration_set(set_name) |
def set_conf_set_value(self, set_name, param, value): '''Set a configuration set parameter value. @param set_name The name of the configuration set the destination parameter is in. @param param The name of the parameter to set. @param value The new value for the parameter. @raises NoSuchConfSetError, NoSuchConfParamErr... |
def active_conf_set(self): '''The currently-active configuration set.''' with self._mutex: if not self.conf_sets: return None if not self._active_conf_set: return None return self.conf_sets[self._active_conf_set] |
def active_conf_set_name(self): '''The name of the currently-active configuration set.''' with self._mutex: if not self.conf_sets: return '' if not self._active_conf_set: return '' return self._active_conf_set |
def conf_sets(self): '''The dictionary of configuration sets in this component, if any.''' with self._mutex: if not self._conf_sets: self._parse_configuration() return self._conf_sets |
def setup(self): """Setup cache tables.""" for table_spec in self._table_specs: with self._conn: table_spec.setup(self._conn) |
def teardown(self): """Cleanup cache tables.""" for table_spec in reversed(self._table_specs): with self._conn: table_spec.teardown(self._conn) |
def append_condition(statement, condition, key, value): """ >>> list = [] >>> append_condition(list, 'match', 'name', 'Jack') >>> list [{'match': {'name': 'Jack'}}] >>> dict = {} >>> append_condition(dict, 'match', 'name', 'Marry') >>> dict {'match': {'name': 'Marry'}} """ if isinstance(statement, list): statement.appe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.