_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q50400
watch._poll_trigger
train
def _poll_trigger(self): """ Trigger activity for the caller by writting a NUL to the self-pipe. """ try: os.write(self._poll_send, '\0'.encode('utf-8')) except Exception as e: log = self._getparam('log', self._discard) log.debug("Ignoring self-pip...
python
{ "resource": "" }
q50401
watch._trigger
train
def _trigger(self, fd, **params): """ We need events to fire on appearance because the code doesn't see the file until after it has been created. In WF_KQUEUE mode, this simulates triggering an event by firing a oneshot timer event to fire immediately (0 msecs). Because ...
python
{ "resource": "" }
q50402
watch._add_file
train
def _add_file(self, path, **params): """ Attempt to add a file to the system monitoring mechanism. """ log = self._getparam('log', self._discard, **params) fd = None try: fd = os.open(path, os.O_RDONLY) except Exception as e: if not self.paths[...
python
{ "resource": "" }
q50403
watch.commit
train
def commit(self, **params): """ Rebuild kevent operations by removing open files that no longer need to be watched, and adding new files if they are not currently being watched. This is done by comparing self.paths to self.paths_open. """ log = self._getparam('log', self._di...
python
{ "resource": "" }
q50404
watch.remove
train
def remove(self, paths, **params): """ Delete paths from the watched list. """ log = self._getparam('log', self._discard, **params) commit = self._getparam('commit', True, **params) if type(paths) is not list: paths = [paths] rebuild = False for ...
python
{ "resource": "" }
q50405
watch.scan
train
def scan(self, **params): """ This method should be called periodically if files were added with "missing=False". It will check for the appearance of missing files and ensure an event will be triggered for any that appear. It also needs to be called if the instance could be in ...
python
{ "resource": "" }
q50406
replace_ext
train
def replace_ext(filename, ext): """ Return new pathname formed by replacing extension in `filename` with `ext`. """ if ext.startswith('.'): ext = ext[1:] stem, _ = os.path.splitext(filename) return (stem + '.' + ext)
python
{ "resource": "" }
q50407
check_imagemagick_supported_format
train
def check_imagemagick_supported_format(fmt): """ Return ``True`` if `convert` can be run and reports supporting image format `fmt`. """ try: convert_output = check_output(['convert', '--version']) # `subprocess` raises `OSError` if the executable is not found except (CalledProcessError, ...
python
{ "resource": "" }
q50408
TmClient.get_experiments
train
def get_experiments(self): '''Gets information for all experiments. Returns ------- List[Dict[str, str]] id, name and description for each experiment See also -------- :func:`tmserver.api.experiment.get_experiments` :class:`tmlib.models.exper...
python
{ "resource": "" }
q50409
TmClient.create_experiment
train
def create_experiment(self, workflow_type, microscope_type, plate_format, plate_acquisition_mode): '''Creates the experiment. Parameters ---------- workflow_type: str workflow type microscope_type: str microscope type plate_format: int...
python
{ "resource": "" }
q50410
TmClient.rename_experiment
train
def rename_experiment(self, new_name): '''Renames the experiment. Parameters ---------- See also -------- :func:`tmserver.api.experiment.update_experiment` :class:`tmlib.models.experiment.ExperimentReference` ''' logger.info('rename experiment "%...
python
{ "resource": "" }
q50411
TmClient.delete_experiment
train
def delete_experiment(self): '''Deletes the experiment. See also -------- :func:`tmserver.api.experiment.delete_experiment` :class:`tmlib.models.experiment.ExperimentReference` :class:`tmlib.models.experiment.Experiment` ''' logger.info('delete experiment...
python
{ "resource": "" }
q50412
TmClient.delete_plate
train
def delete_plate(self, name): '''Deletes a plate. Parameters ---------- name: str name of the plate that should be deleted See also -------- :func:`tmserver.api.plate.delete_plate` :class:`tmlib.models.plate.Plate` ''' logger....
python
{ "resource": "" }
q50413
TmClient.rename_plate
train
def rename_plate(self, name, new_name): '''Renames a plate. Parameters ---------- name: str name of the plate that should be renamed new_name: str name that should be given to the plate See also -------- :func:`tmserver.api.plate....
python
{ "resource": "" }
q50414
TmClient.rename_acquisition
train
def rename_acquisition(self, plate_name, name, new_name): '''Renames an acquisition. Parameters ---------- plate_name: str name of the parent plate name: str name of the acquisition that should be renamed new_name: str name that should...
python
{ "resource": "" }
q50415
TmClient.delete_acquisition
train
def delete_acquisition(self, plate_name, name): '''Deletes an acquisition. Parameters ---------- plate_name: str name of the parent plate name: str name of the acquisition that should be deleted See also -------- :func:`tmserver.a...
python
{ "resource": "" }
q50416
TmClient.get_wells
train
def get_wells(self, plate_name=None): '''Gets information about wells. Parameters ---------- plate_name: str, optional name of the parent plate Returns ------- List[Dict[str, str]] id, name and description of each well See also ...
python
{ "resource": "" }
q50417
TmClient.get_microscope_files
train
def get_microscope_files(self, plate_name, acquisition_name): '''Gets status and name of files that have been registered for upload. Parameters ---------- plate_name: str name of the parent plate acquisition_name: str name of the parent acquisition ...
python
{ "resource": "" }
q50418
TmClient.upload_microscope_files
train
def upload_microscope_files(self, plate_name, acquisition_name, path, parallel=1, retry=5, convert=None, delete_after_upload=False, _deprecated_directory_option=False): ''' Uploads microscope files contained ...
python
{ "resource": "" }
q50419
TmClient.get_cycles
train
def get_cycles(self): '''Gets cycles. Returns ------- List[Dict[str, str]] information about each cycle See also -------- :func:`tmserver.api.cycle.get_cycles` :class:`tmlib.models.cycles.Cycle` ''' logger.info('get cycles of ...
python
{ "resource": "" }
q50420
TmClient.download_channel_image
train
def download_channel_image(self, channel_name, plate_name, well_name, well_pos_y, well_pos_x, cycle_index=0, tpoint=0, zplane=0, correct=True, align =False): '''Downloads a channel image. Parameters ---------- channel_name: str name of the channel ...
python
{ "resource": "" }
q50421
TmClient.download_channel_image_file
train
def download_channel_image_file(self, channel_name, plate_name, well_name, well_pos_y, well_pos_x, cycle_index, tpoint, zplane, correct, align, directory): '''Downloads a channel image and writes it to a `PNG` file on disk. Parameters ---------- channel_name: str...
python
{ "resource": "" }
q50422
TmClient.download_segmentation_image
train
def download_segmentation_image(self, mapobject_type_name, plate_name, well_name, well_pos_y, well_pos_x, tpoint=0, zplane=0, align = False): '''Downloads a segmentation image. Parameters ---------- plate_id: int ID of the parent experiment mapobject_type...
python
{ "resource": "" }
q50423
TmClient.upload_segmentation_image
train
def upload_segmentation_image(self, mapobject_type_name, plate_name, well_name, well_pos_y, well_pos_x, tpoint, zplane, image): '''Uploads a segmentation image. Parameters ---------- mapobject_type_name: str name of the segmented objects plate...
python
{ "resource": "" }
q50424
TmClient.rename_feature
train
def rename_feature(self, mapobject_type_name, name, new_name): '''Renames a feature. Parameters ---------- mapobject_type_name: str name of the segmented objects type name: str name of the feature that should be renamed new_name: str n...
python
{ "resource": "" }
q50425
TmClient.delete_feature
train
def delete_feature(self, mapobject_type_name, name): '''Deletes a feature. Parameters ---------- mapobject_type_name: str name of the segmented objects type name: str name of the feature that should be renamed See also -------- :f...
python
{ "resource": "" }
q50426
TmClient.rename_mapobject_type
train
def rename_mapobject_type(self, name, new_name): '''Renames a mapobject type. Parameters ---------- name: str name of the mapobject type that should be renamed new_name: str name that should be given to the mapobject type See also -------...
python
{ "resource": "" }
q50427
TmClient.delete_mapobject_type
train
def delete_mapobject_type(self, name): '''Deletes a mapobject type. Parameters ---------- name: str name of the mapobject type that should be renamed See also -------- :func:`tmserver.api.mapobject.delete_mapobject_type` :class:`tmlib.models....
python
{ "resource": "" }
q50428
TmClient.get_features
train
def get_features(self, mapobject_type_name): '''Gets features for a given object type. Parameters ---------- mapobject_type_name: str type of the segmented objects Returns ------- List[Dict[str, str]] information about each feature ...
python
{ "resource": "" }
q50429
TmClient.download_object_metadata
train
def download_object_metadata(self, mapobject_type_name, plate_name=None, well_name=None, well_pos_y=None, well_pos_x=None, tpoint=None): '''Downloads metadata for the given object type, which describes the position of each segmented object on the map. Parameters ---------- ...
python
{ "resource": "" }
q50430
TmClient.resubmit_workflow
train
def resubmit_workflow(self, stage_name=None, description=None): '''Resubmits the workflow. Parameters ---------- stage_name: str, optional name of the stage at which workflow should be resubmitted (when omitted workflow will be restarted from the beginning) ...
python
{ "resource": "" }
q50431
TmClient.kill_workflow
train
def kill_workflow(self): '''Kills the workflow. See also -------- :func:`tmserver.api.workflow.kill_workflow` :class:`tmlib.workflow.workflow.Workflow` ''' logger.info('kill workflow of experiment "%s"', self.experiment_name) content = dict() url ...
python
{ "resource": "" }
q50432
TmClient.get_tools_status
train
def get_tools_status(self, tool_name=None): '''Gets the status of tool jobs. Parameters ---------- tool_name: str, optional filter jobs by tool name Returns ------- dict status information about tool jobs See also -------...
python
{ "resource": "" }
q50433
DaapServer.serve_forever
train
def serve_forever(self): """ Run the DAAP server. Start by advertising the server via Bonjour. Then serve requests until CTRL + C is received. """ # Verify that the provider has a server. if self.provider.server is None: raise ValueError( "Can...
python
{ "resource": "" }
q50434
model_base
train
def model_base(bind_label=None, info=None): """Create a base declarative class """ Model = type('Model', (BaseModel,), {'__odm_abstract__': True}) info = {} Model.__table_args__ = table_args(info=info) if bind_label: info['bind_label'] = bind_label return Model
python
{ "resource": "" }
q50435
Mapper.register
train
def register(self, model, **attr): """Register a model or a table with this mapper :param model: a table or a :class:`.BaseModel` class :return: a Model class or a table """ metadata = self.metadata if not isinstance(model, Table): model_name = self._create_m...
python
{ "resource": "" }
q50436
Mapper.create_table
train
def create_table(self, name, *columns, **kwargs): """Create a new table with the same metadata and info """ targs = table_args(**kwargs) args, kwargs = targs[:-1], targs[-1] return Table(name, self.metadata, *columns, *args, **kwargs)
python
{ "resource": "" }
q50437
Mapper.database_all
train
def database_all(self): """Return a dictionary mapping engines with databases """ all = {} for engine in self.engines(): all[engine] = self._database_all(engine) return all
python
{ "resource": "" }
q50438
Mapper.table_create
train
def table_create(self, remove_existing=False): """Creates all tables. """ for engine in self.engines(): tables = self._get_tables(engine, create_drop=True) logger.info('Create all tables for %s', engine) try: self.metadata.create_all(engine, ta...
python
{ "resource": "" }
q50439
Mapper.table_drop
train
def table_drop(self): """Drops all tables. """ for engine in self.engines(): tables = self._get_tables(engine, create_drop=True) logger.info('Drop all tables for %s', engine) self.metadata.drop_all(engine, tables=tables)
python
{ "resource": "" }
q50440
Mapper._database_create
train
def _database_create(self, engine, database): """Create a new database and return a new url representing a connection to the new database """ logger.info('Creating database "%s" in "%s"', database, engine) database_operation(engine, 'create', database) url = copy(engine.u...
python
{ "resource": "" }
q50441
get_washing_regex
train
def get_washing_regex(): """Return a washing regex list.""" global _washing_regex if len(_washing_regex): return _washing_regex washing_regex = [ # Replace non and anti with non- and anti-. This allows a better # detection of keywords such as nonabelian. (re.compile(r"(\...
python
{ "resource": "" }
q50442
normalize_fulltext
train
def normalize_fulltext(fulltext): """Return a 'cleaned' version of the output provided by pdftotext.""" # We recognize keywords by the spaces. We need these to match the # first and last words of the document. fulltext = " " + fulltext + " " # Replace some weird unicode characters. fulltext = r...
python
{ "resource": "" }
q50443
cut_references
train
def cut_references(text_lines): """Return the text lines with the references cut.""" ref_sect_start = find_reference_section(text_lines) if ref_sect_start is not None: start = ref_sect_start["start_line"] end = find_end_of_reference_section(text_lines, start, ...
python
{ "resource": "" }
q50444
_replace_greek_characters
train
def _replace_greek_characters(line): """Replace greek characters in a string.""" for greek_char, replacement in iteritems(_GREEK_REPLACEMENTS): try: line = line.replace(greek_char, replacement) except UnicodeDecodeError: current_app.logger.exception("Unicode decoding erro...
python
{ "resource": "" }
q50445
MTSet.optimize
train
def optimize(self, G, params0=None, n_times=10, verbose=False, vmax=5, perturb=1e-3, factr=1e7): """ Optimize the model considering G """ # set params0 from null if params0 is None if params0 is None: if self.null is None: if verbose: print(".. fit...
python
{ "resource": "" }
q50446
MTSet.fitNullTraitByTrait
train
def fitNullTraitByTrait(self, verbose=False, cache=False, out_dir='./cache', fname=None, rewrite=False): """ Fit null model trait by trait """ read_from_file = False if cache: assert fname is not None, 'MultiTraitSetTest:: specify fname' if not os.path.exi...
python
{ "resource": "" }
q50447
MTSet.optimizeTraitByTrait
train
def optimizeTraitByTrait(self, G, verbose=False, n_times=10, factr=1e3): """ Optimize trait by trait """ assert self.nullST is not None, 'fit null model beforehand' RV = {} self.infoOptST = {} for p in range(self.P): trait_id = self.traitID[p] self.stSet.Y...
python
{ "resource": "" }
q50448
MTSet._initParams
train
def _initParams(self, init_method=None): """ this function initializes the paramenter and Ifilter """ if self.bgRE: if init_method=='random': params0 = {'covar': sp.randn(self._gpNull.covar.getNumberParams())} else: if self.P==1: ...
python
{ "resource": "" }
q50449
SerialisingFrontend.serialise
train
def serialise(self, obj): """ Take an object from the project or the runner and serialise it into a dictionary. Parameters ---------- obj : object An object to serialise. Returns ------- object A serialised version of the ...
python
{ "resource": "" }
q50450
Document.create
train
def create(self, prov_document, prov_format=None, refresh=False, **props): """ Create a document on ProvStore. :param prov_document: The document to be stored :param prov_format: The format of the document provided :param bool refresh: Whether or not to load back the document af...
python
{ "resource": "" }
q50451
Document.read_prov
train
def read_prov(self, document_id=None): """ Load the provenance of this document .. note:: This method is called automatically if needed when the :py:meth:`prov` property is accessed. Manual use of this method is unusual. :param document_id: (optional) set the docu...
python
{ "resource": "" }
q50452
Document.read_meta
train
def read_meta(self, document_id=None): """ Load metadata associated with the document .. note:: This method is called automatically if needed when a property is first accessed. You will not normally have to use this method manually. :param document_id: (optional) ...
python
{ "resource": "" }
q50453
Document.add_bundle
train
def add_bundle(self, prov_bundle, identifier): """ Verbose method of adding a bundle. Can also be done as: >>> api = Api() >>> document = api.document.get(148) >>> document.bundles['identifier'] = prov_bundle :param prov_bundle: The bundle to be added ...
python
{ "resource": "" }
q50454
Document.delete
train
def delete(self): """ Remove the document and all of its bundles from ProvStore. .. warning:: Cannot be undone. """ if self.abstract: raise AbstractDocumentException() self._api.delete_document(self.id) self._id = None return True
python
{ "resource": "" }
q50455
Document.name
train
def name(self): """ Name of document as seen on ProvStore """ if self._name: return self._name elif not self.abstract: return self.read_meta()._name raise EmptyDocumentException()
python
{ "resource": "" }
q50456
Document.public
train
def public(self): """ Is this document visible to anyone? """ if self._public: return self._public elif not self.abstract: return self.read_meta()._public raise EmptyDocumentException()
python
{ "resource": "" }
q50457
Document.owner
train
def owner(self): """ Username of document creator """ if self._owner: return self._owner elif not self.abstract: return self.read_meta()._owner raise EmptyDocumentException()
python
{ "resource": "" }
q50458
Document.views
train
def views(self): """ Number of views this document has received on ProvStore """ if self._views: return self._views elif not self.abstract: return self.read_meta()._views raise EmptyDocumentException()
python
{ "resource": "" }
q50459
Document.url
train
def url(self): """ URL of document on ProvStore :Example: >>> stored_document.url 'https://provenance.ecs.soton.ac.uk/store/documents/148' """ if not self.abstract: return "%s/documents/%i" % ("/".join(self._api.base_url.split("/")[:-2]), self.id)
python
{ "resource": "" }
q50460
ASTBuilder.build_ast
train
def build_ast(self): """Convert an top level parse tree node into an AST mod.""" n = self.root_node if n.type == syms.file_input: stmts = [] for i in range(len(n.children) - 1): stmt = n.children[i] if stmt.type == tokens.NEWLINE: ...
python
{ "resource": "" }
q50461
ASTBuilder.number_of_statements
train
def number_of_statements(self, n): """Compute the number of AST statements contained in a node.""" stmt_type = n.type if stmt_type == syms.compound_stmt: return 1 elif stmt_type == syms.stmt: return self.number_of_statements(n.children[0]) elif stmt_type =...
python
{ "resource": "" }
q50462
ASTBuilder.error
train
def error(self, msg, n): """Raise a SyntaxError with the lineno and col_offset set to n's.""" raise SyntaxError(msg, n.lineno, n.col_offset, filename=self.compile_info.filename)
python
{ "resource": "" }
q50463
ASTBuilder.set_context
train
def set_context(self, expr, ctx): """Set the context of an expression to Store or Del if possible.""" t = type(expr) try: # TODO: check if Starred is ok if t in (ast.Attribute, ast.Name): if type(ctx) == ast.Store(): mis.check_forbidden...
python
{ "resource": "" }
q50464
get_caller
train
def get_caller(*caller_class, **params): """ This is obsolete and references are being removed """ (frame, file, line, func, contextlist, index) = inspect.stack()[1] try: class_name = frame.f_locals["self"].__class__.__name__ except: class_name = None if class_name: name = class_name +...
python
{ "resource": "" }
q50465
version_cmp
train
def version_cmp(ver_a, ver_b): """ Compares two version strings in the dotted-numeric-label format. Returns -1 if a < b, 0 if a == b, and +1 if a > b. Inputs may include a prefix string that matches '^\w+[_-]', but both strings must start with the same prefix. If present, it is ignored for pu...
python
{ "resource": "" }
q50466
appname
train
def appname(path=None): """ Return a useful application name based on the program argument. A special case maps 'mod_wsgi' to a more appropriate name so web applications show up as our own. """ if path is None: path = sys.argv[0] name = os.path.basename(os.path.splitext(path)[0]) if name == 'mod...
python
{ "resource": "" }
q50467
statusfmt
train
def statusfmt(status): """ Format an exit status as text. """ if status == 0: msg = 'exited ok' elif os.WIFSIGNALED(status): msg = 'died on '+signame(os.WTERMSIG(status)) elif os.WIFEXITED(status) and os.WEXITSTATUS(status) > 0: msg = 'exited '+str(os.WEXITSTATUS(status)) ...
python
{ "resource": "" }
q50468
sys_maxfd
train
def sys_maxfd(): """ Returns the maximum file descriptor limit. This is guaranteed to return a useful int value. """ maxfd = None try: maxfd = int(resource.getrlimit(resource.RLIMIT_NOFILE)[0]) if maxfd == resource.RLIM_INFINITY: #...
python
{ "resource": "" }
q50469
print_email
train
def print_email(message, app): """Print mail to stream. Signal handler for email_dispatched signal. Prints by default the output to the stream specified in the constructor of InvenioMail. :param message: Message object. :param app: Flask application object. """ invenio_mail = app.extension...
python
{ "resource": "" }
q50470
Forest.predict
train
def predict(self, X, k=None, depth=None): """Predict response for X. The response to an input sample is computed as the sum of (1) the mean prediction of the trees in the forest (fixed effect) and (2) the estimated random effect. Parameters ---------- X : array-...
python
{ "resource": "" }
q50471
MixedForestTree.clear_data
train
def clear_data(self): ''' Free memory If many trees are grown this is an useful options since it is saving a lot of memory ''' if self.forest.verbose > 1: print('clearing up stuff') self.S = None self.Uy = None self.U = None
python
{ "resource": "" }
q50472
MixedForestTree.get_X_slice
train
def get_X_slice(self, rmind): '''get X with slicing''' if self.forest.optimize_memory_use: return self.forest.X[:, rmind][self.subsample] else: return self.X[:, rmind]
python
{ "resource": "" }
q50473
param_upload
train
def param_upload(field, path): """ Pack upload metadata. """ if not path: return None param = {} param['field'] = field param['path'] = path return param
python
{ "resource": "" }
q50474
extract
train
def extract(filepath, taxonomy, output_mode, output_limit, spires, match_mode, detect_author_keywords, extract_acronyms, rebuild_cache, only_core_tags, no_cache): """Run keyword extraction on given PDF file for given taxonomy.""" if not filepath or not taxonomy: print("No PDF fil...
python
{ "resource": "" }
q50475
watch._build
train
def _build(self, name, **params): """ Rebuild operations by removing open modules that no longer need to be watched, and adding new modules if they are not currently being watched. This is done by comparing self.modules to watch_files.paths_open """ log = self._getparam('log...
python
{ "resource": "" }
q50476
watch.remove
train
def remove(self, name, **params): """ Delete a command from the watched list. This involves removing the command from the inverted watch list, then possibly rebuilding the event set if any modules no longer need watching. """ log = self._getparam('log', self._discard, **para...
python
{ "resource": "" }
q50477
user_info
train
def user_info(access_token, request): """ Return basic information about a user. Limited to OAuth clients that have receieved authorization to the 'user_info' scope. """ user = access_token.user data = { 'username': user.username, 'first_name': user.first_name, 'last_name': user.last_name...
python
{ "resource": "" }
q50478
Or.evaluate
train
def evaluate(self, values): """Evaluate the "OR" expression Check if the left "or" right expression evaluate to True. """ return self.left.evaluate(values) or self.right.evaluate(values)
python
{ "resource": "" }
q50479
colorize
train
def colorize(text, color): """ Colorizes given text using given color. :param text: Text to colorize. :type text: unicode :param color: *ANSI* escape code name. :type color: unicode :return: Colorized text. :rtype: unicode """ escape_code = getattr(AnsiEscapeCodes, color, None)...
python
{ "resource": "" }
q50480
_fmt_context
train
def _fmt_context(arg_list, context): """ Iterate on performing a format operation until the formatting makes no further changes. This allows for the substitution of context values that themselves have context values. To prevent infinite loops due to direct or indirect self-reference, the total num...
python
{ "resource": "" }
q50481
event_target.command
train
def command(self, details): """ Handles executing a command-based event. This starts the command as specified in the 'commands' section of the task config. A separate event is registered to handle the command exit. This simply logs the exit status. """ log = self._...
python
{ "resource": "" }
q50482
event_target.command_exit
train
def command_exit(self, details): """ Handle the event when a utility command exits. """ log = self._params.get('log', self._discard) pid = self._key status = details why = statusfmt(status) if status: log.warning("pid %d for %s(%s) %s", pid, self._...
python
{ "resource": "" }
q50483
event_target.proc_exit
train
def proc_exit(self, details): """ Handle the event when one of the task processes exits. """ log = self._params.get('log', self._discard) pid = self._key exit_code = details why = statusfmt(exit_code) proc = None for p in self._parent._proc_state: ...
python
{ "resource": "" }
q50484
event_target.signal
train
def signal(self, details): """ Send a signal to all task processes. """ log = self._params.get('log', self._discard) if '_signal' not in dir(self._parent) or not callable(getattr(self._parent, '_signal')): log.error("Event parent '%s' has no '_signal' method", self._name)...
python
{ "resource": "" }
q50485
Context._get_list
train
def _get_list(self, value, context=None): """ Get a configuration value. The result is None if "value" is None, otherwise the result is a list. "value" may be a list, dict, or str value. If a list, each element of the list may be a list, dict, or str value, and the val...
python
{ "resource": "" }
q50486
legion._context_build
train
def _context_build(self, pending=False): """ Create a context dict from standard legion configuration. The context is constructed in a standard way and is passed to str.format() on configuration. The context consists of the entire os.environ, the config 'defines', and a set of p...
python
{ "resource": "" }
q50487
legion._get_http_services
train
def _get_http_services(self, http_list): """ Returns a list of httpd.HttpService instances which describe the HTTP services that should be started. The is built from the settings.http section of the configuration. The first element of that section is adjusted according to parame...
python
{ "resource": "" }
q50488
legion._manage_http_servers
train
def _manage_http_servers(self): """ Compares the running services with the current settings configuration and adjusts the running services to match it if different. The services are identified only by their postion in the server list, so a change than only involves a position mo...
python
{ "resource": "" }
q50489
legion._load_roles
train
def _load_roles(self): """ Load the roles, one per line, from the roles file. This is called at startup and whenever the roles file changes. Note that it is not strictly an error for the roles file to be missing but a warning is logged in case that was not intended. ...
python
{ "resource": "" }
q50490
legion.set_roles_file
train
def set_roles_file(self, path): """ Load all roles from the roles file, and watch for future role changes. When the roles file changes, it will be read and the current configuration re-applied so that any role-induced changes are processed. Once loaded, the roles are pr...
python
{ "resource": "" }
q50491
legion.set_config_file
train
def set_config_file(self, path): """ Set the config file. The contents must be valid YAML and there must be a top-level element 'tasks'. The listed tasks will be started according to their configuration, and the file will be watched for future changes. The changes will be acti...
python
{ "resource": "" }
q50492
legion.set_own_module
train
def set_own_module(self, path): """ This is provided so the calling process can arrange for processing to be stopped and a LegionReset exception raised when any part of the program's own module tree changes. """ log = self._params.get('log', self._discard) self._name ...
python
{ "resource": "" }
q50493
legion.task_add
train
def task_add(self, t, periodic=None): """ Register a task in this legion. "periodic" should be None, or a callback function which will be called periodically when the legion is otherwise idle. """ name = t.get_name() if name in self._tasknames: raise Task...
python
{ "resource": "" }
q50494
legion.task_del
train
def task_del(self, t): """ Remove a task in this legion. If the task has active processes, an attempt is made to stop them before the task is deleted. """ name = t._name if name in self._tasknames: del self._tasknames[name] self._tasks.discard(t) ...
python
{ "resource": "" }
q50495
legion.module_del
train
def module_del(self, key): """ Deregister from python module change events. """ if key in self._module_event_map: del self._module_event_map[key] if key in self._watch_modules.names: self._watch_modules.remove(key)
python
{ "resource": "" }
q50496
legion.file_del
train
def file_del(self, key, paths=None): """ Deregister a task for file event changes. If paths is None, all paths assoicated with the task will be deregistered. """ if paths is None: paths = [] for path in self._file_event_map: if key in self._fi...
python
{ "resource": "" }
q50497
legion._reap
train
def _reap(self): """ Reap all processes that have exited. We try to reap bursts of processes so that groups that cluster will tend to restart in the configured order. """ log = self._params.get('log', self._discard) try: cnt = len(os.read(self._watch_chil...
python
{ "resource": "" }
q50498
task._reset_state
train
def _reset_state(self): """ State flags. These hold the time of the change in the particular state, or None if there has been no such state change yet. starting - Indicates the task is in the process of starting. This flag inhibits further startup attempts. ...
python
{ "resource": "" }
q50499
task._context_build
train
def _context_build(self, pending=False): """ Create a context dict from standard task configuration. The context is constructed in a standard way and is passed to str.format() on configuration. The context consists of the entire os.environ, the config 'defines', and a set of pre...
python
{ "resource": "" }