Package glue :: Package ligolw :: Package utils :: Module process
[hide private]
[frames] | no frames]

Module process

source code

A collection of utilities to assist applications in manipulating the process and process_params tables in LIGO Light-Weight XML documents.


Version: git id 8cbd1b7187ce3ed9a825d6ed11cc432f3cfde9a5

Date: 2017-12-05 15:29:36 +0000

Author: Kipp Cannon <kipp.cannon@ligo.org>, Larne Pekowsky <lppekows@physics.syr.edu>

Functions [hide private]
 
append_process(xmldoc, program=None, version=None, cvs_repository=None, cvs_entry_time=None, comment=None, is_online=False, jobid=0, domain=None, ifos=None)
Add an entry to the process table in xmldoc.
source code
 
append_process_params(xmldoc, process, params)
xmldoc is an XML document tree, process is the row in the process table for which these are the parameters, and params is a list of (name, type, value) tuples one for each parameter.
source code
 
doc_includes_process(xmldoc, program)
Return True if the process table in xmldoc includes entries for a program named program.
source code
 
get_process_params(xmldoc, program, param, require_unique_program=True)
Return a list of the values stored in the process_params table for params named param for the program(s) named program.
source code
 
get_username()
Try to retrieve the username from a variety of sources.
source code
 
process_params_from_dict(paramdict)
Generator function yields (name, type, value) tuples constructed from a dictionary of name/value pairs.
source code
 
register_to_ldbd(client, program, paramdict, version=u'0', cvs_repository=u'-', cvs_entry_time=0, comment=u'-', is_online=False, jobid=0, domain=None, ifos=u'-')
Register the current process and params to a database via a LDBDClient.
source code
 
register_to_xmldoc(xmldoc, program, paramdict, **kwargs)
Register the current process and params to an XML document.
source code
 
set_process_end_time(process)
Set the end time in a row in a process table to the current time.
source code
Variables [hide private]
  __package__ = 'glue.ligolw.utils'
Function Details [hide private]

append_process(xmldoc, program=None, version=None, cvs_repository=None, cvs_entry_time=None, comment=None, is_online=False, jobid=0, domain=None, ifos=None)

source code 

Add an entry to the process table in xmldoc. program, version, cvs_repository, comment, and domain should all be strings or unicodes. cvs_entry_time should be a string or unicode in the format "YYYY/MM/DD HH:MM:SS". is_online should be a boolean, jobid an integer. ifos should be an iterable (set, tuple, etc.) of instrument names.

See also register_to_xmldoc().

append_process_params(xmldoc, process, params)

source code 

xmldoc is an XML document tree, process is the row in the process table for which these are the parameters, and params is a list of (name, type, value) tuples one for each parameter.

See also process_params_from_dict(), register_to_xmldoc().

get_process_params(xmldoc, program, param, require_unique_program=True)

source code 

Return a list of the values stored in the process_params table for params named param for the program(s) named program. The values are returned as Python native types, not as the strings appearing in the XML document. If require_unique_program is True (default), then the document must contain exactly one program with the requested name, otherwise ValueError is raised. If require_unique_program is not True, then there must be at least one program with the requested name otherwise ValueError is raised.

get_username()

source code 

Try to retrieve the username from a variety of sources. First the environment variable LOGNAME is tried, if that is not set the environment variable USERNAME is tried, if that is not set the password database is consulted (only on Unix systems, if the import of the pwd module succeeds), finally if that fails KeyError is raised.

process_params_from_dict(paramdict)

source code 

Generator function yields (name, type, value) tuples constructed from a dictionary of name/value pairs. The tuples are suitable for input to append_process_params(). This is intended as a convenience for converting command-line options into process_params rows. The name values in the output have "--" prepended to them and all "_" characters replaced with "-". The type strings are guessed from the Python types of the values. If a value is a Python list (or instance of a subclass thereof), then one tuple is produced for each of the items in the list.

Example:

>>> list(process_params_from_dict({"verbose": True, "window": 4.0, "include": ["/tmp", "/var/tmp"]}))
[(u'--window', u'real_8', 4.0), (u'--verbose', None, None), (u'--include', u'lstring', '/tmp'), (u'--include', u'lstring', '/var/tmp')]

register_to_ldbd(client, program, paramdict, version=u'0', cvs_repository=u'-', cvs_entry_time=0, comment=u'-', is_online=False, jobid=0, domain=None, ifos=u'-')

source code 

Register the current process and params to a database via a LDBDClient. The program and paramdict arguments and any additional keyword arguments are the same as those for register_to_xmldoc(). Returns the new row from the process table.

register_to_xmldoc(xmldoc, program, paramdict, **kwargs)

source code 

Register the current process and params to an XML document. program is the name of the program. paramdict is a dictionary of name/value pairs that will be used to populate the process_params table; see process_params_from_dict() for information on how these name/value pairs are interpreted. Any additional keyword arguments are passed to append_process(). Returns the new row from the process table.