rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
for tbl in dbtables.get_xml(connection).getElementsByTagName(ligolw.Table.tagName): tbl.sync_next_id()
dbtables.idmap_sync(connection)
def setup(target, check_same_thread=True): connection = sqlite3.connect(target, check_same_thread=check_same_thread) dbtables.DBTable_set_connection(connection) for tbl in dbtables.get_xml(connection).getElementsByTagName(ligolw.Table.tagName): tbl.sync_next_id() return connection
def update_ids(xmldoc, connection, verbose = False):
def update_ids(connection, verbose = False):
def update_ids(xmldoc, connection, verbose = False): """ For internal use only. """ table_elems = xmldoc.getElementsByTagName(ligolw.Table.tagName) for i, tbl in enumerate(table_elems): if verbose: print >>sys.stderr, "updating IDs: %d%%\r" % (100 * i / len(table_elems)), tbl.applyKeyMapping() if verbose: print >>sys.s...
table_elems = xmldoc.getElementsByTagName(ligolw.Table.tagName)
table_elems = dbtables.get_xml(connection).getElementsByTagName(ligolw.Table.tagName)
def update_ids(xmldoc, connection, verbose = False): """ For internal use only. """ table_elems = xmldoc.getElementsByTagName(ligolw.Table.tagName) for i, tbl in enumerate(table_elems): if verbose: print >>sys.stderr, "updating IDs: %d%%\r" % (100 * i / len(table_elems)), tbl.applyKeyMapping() if verbose: print >>sys.s...
print >>sys.stderr, "updating IDs: %d%%\r" % (100 * i / len(table_elems)),
print >>sys.stderr, "updating IDs: %d%%\r" % (100.0 * i / len(table_elems)),
def update_ids(xmldoc, connection, verbose = False): """ For internal use only. """ table_elems = xmldoc.getElementsByTagName(ligolw.Table.tagName) for i, tbl in enumerate(table_elems): if verbose: print >>sys.stderr, "updating IDs: %d%%\r" % (100 * i / len(table_elems)), tbl.applyKeyMapping() if verbose: print >>sys.s...
Iterate over a sequence of URLs and parse and insert each one into the database the dbtables.DBTable class is currently connected to. """
Iterate over a sequence of URLs, calling insert_from_url() on each, then build the indexes indicated by the metadata in lsctables.py. """
def insert_from_urls(connection, urls, preserve_ids = False, verbose = False): """ Iterate over a sequence of URLs and parse and insert each one into the database the dbtables.DBTable class is currently connected to. """ orig_DBTable_append = dbtables.DBTable.append if not preserve_ids: # enable ID remapping dbtables.i...
xmldoc = utils.load_url(url, verbose = verbose, gz = (url or "stdin").endswith(".gz")) if not preserve_ids: update_ids(xmldoc, connection, verbose) xmldoc.unlink()
insert_from_url(connection, url, preserve_ids = preserve_ids, verbose = verbose)
def insert_from_urls(connection, urls, preserve_ids = False, verbose = False): """ Iterate over a sequence of URLs and parse and insert each one into the database the dbtables.DBTable class is currently connected to. """ orig_DBTable_append = dbtables.DBTable.append if not preserve_ids: # enable ID remapping dbtables.i...
dbtables.build_indexes(connection, verbose) dbtables.DBTable.append = orig_DBTable_append def insert_from_xmldoc(connection, xmldoc, preserve_ids = False, verbose = False): """ Insert the tables from an in-ram XML document into the database at the given connection. """ orig_DBTable_append = dbtables.DBTable.append if...
def insert_from_urls(connection, urls, preserve_ids = False, verbose = False): """ Iterate over a sequence of URLs and parse and insert each one into the database the dbtables.DBTable class is currently connected to. """ orig_DBTable_append = dbtables.DBTable.append if not preserve_ids: # enable ID remapping dbtables.i...
fd, filename = tempfile.mkstemp(suffix = ".sqlite", dir = path) os.close(fd)
temporary_file = tempfile.NamedTemporaryFile(suffix = ".sqlite", dir = path) def new_unlink(self, orig_unlink = temporary_file.unlink): try: orig_unlink("%s-journal" % self) except: pass orig_unlink(self) temporary_file.unlink = new_unlink filename = temporary_file.name temporary_files[filename] = temporary_file
def mktmp(path, verbose = False): fd, filename = tempfile.mkstemp(suffix = ".sqlite", dir = path) os.close(fd) if verbose: print >>sys.stderr, "using '%s' as workspace" % filename # mkstemp() ignores umask, creates all files accessible # only by owner; we should respect umask. note that # os.umask() sets it, too, so ...
os.remove(working_filename)
del temporary_files[working_filename]
def discard_connection_filename(filename, working_filename, verbose = False): """ Like put_connection_filename(), but the working copy is simply deleted instead of being copied back to its original location. This is a useful performance boost if it is known that no modifications were made to the file, for example if qu...
self.__user_tag = None
def __init__(self, job): """ @param job: the CondorJob that this node corresponds to. """ if not isinstance(job, CondorDAGJob) and \ not isinstance(job,CondorDAGManJob): raise CondorDAGNodeError, \ "A DAG node must correspond to a Condor DAG job or Condor DAGMan job" self.__name = None self.__job = job self.__category ...
def set_user_tag(self,usertag): """ Set the user tag that is passed to the analysis code. @param user_tag: the user tag to identify the job """ self.__user_tag = usertag def get_user_tag(self): """ Returns the usertag string """ return self.__user_tag
def get_category(self): """ Get the category for this node in the DAG. """ return self.__category
if pidfile_pid.isdigit() and glue.utils.pid_exists(int(pidfile_pid)): raise RuntimeError, ("pidfile %s contains pid (%s) of a running " "process" % (lockfile, pidfile_pid)) else: print ("pidfile %s contains stale pid %s; writing new lock" % (lockfile, pidfile_pid))
if pidfile_pid.isdigit(): if glue.utils.pid_exists(int(pidfile_pid)): raise RuntimeError, ("pidfile %s contains pid (%s) of a running " "process" % (lockfile, pidfile_pid)) else: print ("pidfile %s contains stale pid %s; writing new lock" % (lockfile, pidfile_pid))
def get_lock(lockfile): """ Tries to write a lockfile containing the current pid. Excepts if the lockfile already contains the pid of a running process. Although this should prevent a lock from being granted twice, it can theoretically deny a lock unjustly in the unlikely event that the original process is gone but a...
print >> sys.stderr, "setting the temp_store_directory to %s" % temp_store_directory
print >> sys.stderr, "setting the temp_store_directory to %s ..." % temp_store_directory
def set_temp_store_directory( connection, temp_store_directory, verbose = False ): """ Sets the temp_store_directory parameter in sqlite. """ try: import sqlite3 except ImportError: # pre 2.5.x from pysqlite2 import dbapi2 as sqlite3 if verbose: print >> sys.stderr, "setting the temp_store_directory to %s" % temp_stor...
class cached_ilwdchar_class(ilwdchar): __slots__ = () table_name, column_name = key index_offset = len("%s:%s:" % key) def __conform__(self, protocol): return unicode(self) ilwdchar_class_cache[key] = cached_ilwdchar_class return cached_ilwdchar_class
pass class cached_ilwdchar_class(ilwdchar): __slots__ = () table_name, column_name = key index_offset = len("%s:%s:" % key) def __conform__(self, protocol): return unicode(self) ilwdchar_class_cache[key] = cached_ilwdchar_class return cached_ilwdchar_class
def get_ilwdchar_class(tbl_name, col_name): """ Searches the cache of pre-defined ilwdchar subclasses for a class whose table_name and column_name attributes match those provided. If a matching subclass is found it is returned; otherwise a new class is defined, added to the cache, and returned. Example: >>> process_...
[segment(11.0, 15)]
[segment(6.0, 15)]
def popitem(*args): raise NotImplementedError
{'H2': [segment(11.0, 15)], 'H1': [segment(5.0, 9.0)]}
{'H2': [segment(6.0, 15)], 'H1': [segment(0.0, 9.0)]}
def popitem(*args): raise NotImplementedError
working copy of a segmentlist object. The first is to initialize a new object from an existing one with
copy of a segmentlist object. The first is to initialize a new object from an existing one with >>> old = segmentlistdict()
def copy(self): """ Return a copy of the segmentlistdict object. The return value is a new object with a new offsets attribute, with references to the original keys, and shallow copies of the segment lists. Modifications made to the offset dictionary or segmentlists in the object returned by this method will not affe...
This creates a working copy of the dictionary, but not of its contents. That is, this creates new with references to the segmentlists in old, so changes to the segmentlists in either new or old are reflected in both. The second method is
This creates a copy of the dictionary, but not of its contents. That is, this creates new with references to the segmentlists in old, therefore changes to the segmentlists in either new or old are reflected in both. The second method is
def copy(self): """ Return a copy of the segmentlistdict object. The return value is a new object with a new offsets attribute, with references to the original keys, and shallow copies of the segment lists. Modifications made to the offset dictionary or segmentlists in the object returned by this method will not affe...
This creates a working copy of the dictionary and of the
This creates a copy of the dictionary and of the
def copy(self): """ Return a copy of the segmentlistdict object. The return value is a new object with a new offsets attribute, with references to the original keys, and shallow copies of the segment lists. Modifications made to the offset dictionary or segmentlists in the object returned by this method will not affe...
except ImportError, KeyError:
except (ImportError, KeyError):
def get_username(): """ 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 succedes), finally...
template = """ <profile namespace="dagman" key="priority">%s</profile>\n"""
template = """ <profile namespace="condor" key="priority">%s</profile>\n"""
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
parent.job().get_pegasus_exec_dir(), dax_basename + '_0') )
parent.job().get_pegasus_exec_dir(), dax_basename + '_0.cache') )
def recurse_pfn_cache(node,caches=[]): for parent in node._CondorDAGNode__parents: if isinstance(parent.job(), CondorDAGManJob): if parent.job().get_dax() is None: pass else: caches = recurse_pfn_cache(parent,caches) dax_name = os.path.basename(parent.job().get_dax()) dax_basename = '.'.join(dax_name.split('.')[0:-1]) ...
def update_ids(connection, verbose = False):
def update_ids(connection, xmldoc=None, verbose = False):
def update_ids(connection, verbose = False): """ For internal use only. """ table_elems = dbtables.get_xml(connection).getElementsByTagName(ligolw.Table.tagName) for i, tbl in enumerate(table_elems): if verbose: print >>sys.stderr, "updating IDs: %d%%\r" % (100.0 * i / len(table_elems)), tbl.applyKeyMapping() if verbos...
table_elems = dbtables.get_xml(connection).getElementsByTagName(ligolw.Table.tagName)
if xmldoc: table_elems = xmldoc.getElementsByTagName(ligolw.Table.tagName) else: table_elems = dbtables.get_xml(connection).getElementsByTagName(ligolw.Table.tagName)
def update_ids(connection, verbose = False): """ For internal use only. """ table_elems = dbtables.get_xml(connection).getElementsByTagName(ligolw.Table.tagName) for i, tbl in enumerate(table_elems): if verbose: print >>sys.stderr, "updating IDs: %d%%\r" % (100.0 * i / len(table_elems)), tbl.applyKeyMapping() if verbos...
utils.load_url(url, verbose = verbose, gz = (url or "stdin").endswith(".gz")).unlink()
xmldoc = utils.load_url(url, verbose = verbose, gz = (url or "stdin").endswith(".gz"))
def insert_from_url(connection, url, preserve_ids = False, verbose = False): """ Parse and insert the LIGO Light Weight document at the URL into the database the at the given connection. """ # # load document. this process inserts the document's contents into # the database. the document is unlinked to delete databas...
update_ids(connection, verbose)
update_ids(connection, xmldoc, verbose) xmldoc.unlink()
def insert_from_url(connection, url, preserve_ids = False, verbose = False): """ Parse and insert the LIGO Light Weight document at the URL into the database the at the given connection. """ # # load document. this process inserts the document's contents into # the database. the document is unlinked to delete databas...
connection.commit()
def insert_from_xmldoc(connection, xmldoc, preserve_ids = False, verbose = False): """ Insert the tables from an in-ram XML document into the database at the given connection. """ # # iterate over tables in the XML tree, reconstructing each inside # the database # for tbl in xmldoc.getElementsByTagName(ligolw.Table.ta...
update_ids(connection, verbose)
update_ids(connection, None, verbose)
def insert_from_xmldoc(connection, xmldoc, preserve_ids = False, verbose = False): """ Insert the tables from an in-ram XML document into the database at the given connection. """ # # iterate over tables in the XML tree, reconstructing each inside # the database # for tbl in xmldoc.getElementsByTagName(ligolw.Table.ta...
chisq = self.get_column('chisq') chisq_dof = self.get_column('chisq_dof') rchisq = chisq/ (2*chisq_dof - 2)
rchisq = self.get_column('chisq')/(2*self.get_column('chisq_dof') - 2)
def get_new_snr(self, index=6.0): # the kwarg 'index' is to be assigned to the parameter chisq_index occurring in the .ini files etc # the parameter nhigh gives the asymptotic behaviour d (ln chisq) / d (ln rho) at large rho # nhigh=2 means chisq~rho^2 along contours of new_snr as expected from the behaviour of mismatc...
if rchisq > 1.: return snr/ ((1+rchisq**(index/nhigh))/2)**(1./index) else: return snr
newsnr = snr/ (0.5*(1+rchisq**(index/nhigh)))**(1./index) numpy.putmask(newsnr, rchisq < 1, snr) return newsnr
def get_new_snr(self, index=6.0): # the kwarg 'index' is to be assigned to the parameter chisq_index occurring in the .ini files etc # the parameter nhigh gives the asymptotic behaviour d (ln chisq) / d (ln rho) at large rho # nhigh=2 means chisq~rho^2 along contours of new_snr as expected from the behaviour of mismatc...
['SUBDAG EXTERNAL', self.__name, self.__job.get_sub_file]) )
['SUBDAG EXTERNAL', self.__name, self.__job.get_sub_file()]) )
def write_job(self,fh): """ Write the DAG entry for this node's job to the DAG file descriptor. @param fh: descriptor of open DAG file. """ if isinstance(self.job(),CondorDAGManJob): # create an external subdag from this dag fh.write( ' '.join( ['SUBDAG EXTERNAL', self.__name, self.__job.get_sub_file]) ) if self.job()....
Move both the start and the end of the segment a distance x away from the other.
Return a new segment whose bounds are given by subtracting x from the segment's lower bound and adding x to the segment's upper bound.
def protract(self, x): """ Move both the start and the end of the segment a distance x away from the other. """ return self.__class__(self[0] - x, self[1] + x)
Move both the start and the end of the segment a distance x towards the the other.
Return a new segment whose bounds are given by adding x to the segment's lower bound and subtracting x from the segment's upper bound.
def contract(self, x): """ Move both the start and the end of the segment a distance x towards the the other. """ return self.__class__(self[0] + x, self[1] - x)
Return a new segment by adding x to the upper and lower bounds of this segment.
Return a new segment whose bounds are given by adding x to the segment's upper and lower bounds.
def shift(self, x): """ Return a new segment by adding x to the upper and lower bounds of this segment. """ return tuple.__new__(self.__class__, (self[0] + x, self[1] + x))
For each segment in the list, move both the start and the end a distance x away from the other. Coalesce the result. Segmentlist is modified in place.
Execute the .protract() method on each segment in the list and coalesce the result. Segmentlist is modified in place.
def protract(self, x): """ For each segment in the list, move both the start and the end a distance x away from the other. Coalesce the result. Segmentlist is modified in place. """ for i in xrange(len(self)): self[i] = self[i].protract(x) return self.coalesce()
For each segment in the list, move both the start and the end a distance x towards the other. Coalesce the result. Segmentlist is modified in place.
Execute the .contract() method on each segment in the list and coalesce the result. Segmentlist is modified in place.
def contract(self, x): """ For each segment in the list, move both the start and the end a distance x towards the other. Coalesce the result. Segmentlist is modified in place. """ for i in xrange(len(self)): self[i] = self[i].contract(x) return self.coalesce()
Shift the segmentlist by adding x to the upper and lower bounds of all segments. The algorithm is O(n) and does not require the list to be coalesced. Segmentlist is modified in place.
Execute the .shift() method on each segment in the list. The algorithm is O(n) and does not require the list to be coalesced nor does it coalesce the list. Segmentlist is modified in place.
def shift(self, x): """ Shift the segmentlist by adding x to the upper and lower bounds of all segments. The algorithm is O(n) and does not require the list to be coalesced. Segmentlist is modified in place. """ for i in xrange(len(self)): self[i] = self[i].shift(x) return self
dax_usertag = node.get_user_tag() if dax_usertag: pegasus_exec_subdir = os.path.join(dax_subdir,dax_usertag) else: pegasus_exec_subdir = dax_subdir xml += """--dir %s """ % pegasus_exec_subdir
xml += """--dir %s """ % dax_subdir
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
def __init__(self, tag, title="", secnum="1", pagenum="1", level=2):
def __init__(self, tag, title="", secnum="1", pagenum="1", level=2, open_by_default=False):
def __init__(self, tag, title="", secnum="1", pagenum="1", level=2): markup.page.__init__(self, mode="strict_html") self.pagenum = pagenum self.secnum = secnum self._title = title self.sections = {} self.section_ids = [] self.level = level self.tag = tag self.id = tag + self.secnum self.tables = 0 self.add('<div class=...
self.div(id="div_"+secnum , style='display:none;') def add_section(self, tag, title=""):
if open_by_default: style = 'display:block;' else: style = 'display:none;' self.div(id="div_"+secnum , style=style) def add_section(self, tag, title="", open_by_default=False):
def __init__(self, tag, title="", secnum="1", pagenum="1", level=2): markup.page.__init__(self, mode="strict_html") self.pagenum = pagenum self.secnum = secnum self._title = title self.sections = {} self.section_ids = [] self.level = level self.tag = tag self.id = tag + self.secnum self.tables = 0 self.add('<div class=...
self.sections[tag] = _section(tag, title=title, secnum=secnum, pagenum=self.pagenum, level=self.level+1)
self.sections[tag] = _section(tag, title=title, secnum=secnum, pagenum=self.pagenum, level=self.level+1, open_by_default=open_by_default)
def add_section(self, tag, title=""): secnum = "%s.%d" % (self.secnum, len(self.sections.values())+1) self.sections[tag] = _section(tag, title=title, secnum=secnum, pagenum=self.pagenum, level=self.level+1) self.section_ids.append([len(self.sections.values()), tag]) return self.sections[tag]
def add_section(self, tag, title="", level=2):
def add_section(self, tag, title="", level=2, open_by_default=False):
def add_section(self, tag, title="", level=2): """ """ secnum = len(self.sections.values()) + 1 self.section_ids.append([secnum, tag]) self.sections[tag] = _section(title=title, tag=tag, secnum=str(secnum), pagenum=str(self.pagenum), level=level) return self.sections[tag]
self.sections[tag] = _section(title=title, tag=tag, secnum=str(secnum), pagenum=str(self.pagenum), level=level)
self.sections[tag] = _section(title=title, tag=tag, secnum=str(secnum), pagenum=str(self.pagenum), level=level, open_by_default=open_by_default)
def add_section(self, tag, title="", level=2): """ """ secnum = len(self.sections.values()) + 1 self.section_ids.append([secnum, tag]) self.sections[tag] = _section(title=title, tag=tag, secnum=str(secnum), pagenum=str(self.pagenum), level=level) return self.sections[tag]
if not isinstance(node, CondorDAGNode): raise CondorDAGNodeError, "Parent must be a Condor DAG node"
if not isinstance(node, (CondorDAGNode,CondorDAGManNode) ): raise CondorDAGNodeError, "Parent must be a CondorDAGNode or a CondorDAGManNode"
def add_parent(self,node): """ Add a parent to this node. This node will not be executed until the parent node has run sucessfully. @param node: CondorDAGNode to add as a parent. """ if not isinstance(node, CondorDAGNode): raise CondorDAGNodeError, "Parent must be a Condor DAG node" self.__parents.append( node )
dagfile = open( self.__dag_file_path, 'w' )
dagfile = open( self.__dax_file_path, 'w' )
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so just return return try: dagfile = open( self.__dag_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
preamble = """\ <?xml version="1.0" encoding="UTF-8"?>
preamble = """<?xml version="1.0" encoding="UTF-8"?>
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so just return return try: dagfile = open( self.__dag_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
if isinstance(node, LSCDataFindNode):
if self.is_dax() and isinstance(node, LSCDataFindNode):
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so just return return try: dagfile = open( self.__dag_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
os.getcwd(),node.job().get_dag_directory(),subgax_name)
os.getcwd(),node.job().get_dag_directory(),subdag_name)
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so just return return try: dagfile = open( self.__dag_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
print >>dagfile, """<dag id="%s" file="%s">""" % (id, subdag_name)
print >>dagfile, """<dag id="%s" file="%s">""" % (id_tag, subdag_name)
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so just return return try: dagfile = open( self.__dag_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
print >>dagfile, """<dax id="%s" file="%s">""" % (id, subdax_name)
print >>dagfile, """<dax id="%s" file="%s">""" % (id_tag, subdax_name)
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so just return return try: dagfile = open( self.__dag_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
if re.match('.*-[0-9]*-[0-9]*\.xml', dirname):
if re.match('.*-[0-9]*-[0-9]*\.xml$', dirname):
def get_all_files_in_range(dirname, starttime, endtime, pad=64): """Returns all files in dirname and all its subdirectories whose names indicate that they contain segments in the range starttime to endtime""" ret = [] # Maybe the user just wants one file... if os.path.isfile(dirname): if re.match('.*-[0-9]*-[0-9]*\.x...
elif re.match('.*-[0-9]*-[0-9]*\.xml', filename):
elif re.match('.*-[0-9]*-[0-9]*\.xml$', filename):
def get_all_files_in_range(dirname, starttime, endtime, pad=64): """Returns all files in dirname and all its subdirectories whose names indicate that they contain segments in the range starttime to endtime""" ret = [] # Maybe the user just wants one file... if os.path.isfile(dirname): if re.match('.*-[0-9]*-[0-9]*\.x...
def script_dict():
def script_dict(fname):
def script_dict(): script = {} tog = create_toggle() script[tog] = 'javascript' script['http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'] = 'javascript' return (script, [tog])
tog = create_toggle()
tog = os.path.split(create_toggle(fname))[1]
def script_dict(): script = {} tog = create_toggle() script[tog] = 'javascript' script['http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'] = 'javascript' return (script, [tog])
return base_dir + '/' + os.path.split(out.rstrip('/'))[1]
return os.path.split(out.rstrip('/'))[1]
def copy_ihope_style(stylefile="cbcwebpage.css", base_dir="."): # FIXME this is a stupid way to find the path... changes to build scripts, set env var? path = which('ligo_data_find') if path: path = os.path.split(path)[0] else: print >>sys.stderr, "COULD NOT FIND STYLE FILES %s IN %s, ABORTING" % (stylefile, path) rai...
if not css: css = copy_ihope_style() scdict = script_dict()
if not css: css = copy_ihope_style(base_dir=path) scdict = script_dict(fname='%s/%s' % (path,"toggle.js"))
def __init__(self, title="cbc web page", path='./', css=None, script=None, pagenum=1, verbose=False): """ """ if not css: css = copy_ihope_style() scdict = script_dict() if not script: script = scdict[0] self.front = "" scriptfiles = scdict[1] self.verbose = verbose self._style = css self._title = title self._script = ...
self.subpages[tag] = cbcpage(title=title,css=self._style,script=self._script,pagenum=subpage_num)
self.subpages[tag] = cbcpage(title=title,path=self.path,css=self._style,script=self._script,pagenum=subpage_num)
def add_subpage(self, tag, title, link_text=None): """ """
msg = "%s does not have permission to update row entries" % subject msg += " created by %s (process_id %s)" % (dn, known_proc[pid][0]) raise ServerHandlerException, msg
msg = "\"%s\" does not match dn in existing row entries: " % subject msg += "%s (process_id %s)" % (dn, known_proc[pid][0]) logger.warn(msg)
uniq_def = (row[ifos_col],row[name_col],row[vers_col])
one of the segments in self. If self has length n, then if item is a scalar or a segment this operation is O(log n), if it is a segmentlist of m segments this operation is O(m
the segments in self. If self has length n, then if item is a scalar or a segment this operation is O(log n), if item is a segmentlist of m segments this operation is O(m
def __contains__(self, item): """ Returns True if the given object is wholly contained within one of the segments in self. If self has length n, then if item is a scalar or a segment this operation is O(log n), if it is a segmentlist of m segments this operation is O(m log n).
if (t_start <= (self.__data_end+int(d)+1) and t_end >= (self.__data_start-int(d)-1)):
if (t_start <= (self.get_data_end()+self.get_pad_data()+int(d)+1) \ and t_end >= (self.get_data_start()-self.get_pad_data()-int(d)-1)):
def set_cache(self,filename): """ Set the LAL frame cache to to use. The frame cache is passed to the job with the --frame-cache argument. @param filename: calibration file to use. """ if isinstance( filename, str ): # the name of a lal cache file created by a datafind node self.add_var_opt('frame-cache', filename) sel...
def insert(connection, urls, preserve_ids = False, verbose = False):
def insert_from_urls(connection, urls, preserve_ids = False, verbose = False):
def insert(connection, urls, preserve_ids = False, verbose = False): """ Iterate over a sequence of URLs and parse and insert each one into the database the dbtables.DBTable class is currently connected to. """ if not preserve_ids: # enable ID remapping dbtables.idmap_create(connection) dbtables.DBTable.append = dbtabl...
table_elems = xmldoc.getElementsByTagName(ligolw.Table.tagName) for tbl in table_elems:
for tbl in xmldoc.getElementsByTagName(ligolw.Table.tagName):
def insert_from_xmldoc(connection, xmldoc, preserve_ids = False, verbose = False): """ Insert the tables from an in-ram XML document into the database at the given connection. """ if not preserve_ids: # enable ID remapping dbtables.idmap_create(connection) dbtables.DBTable.append = dbtables.DBTable._remapping_append el...
os.path.join('bin','LSCdataFindcheck'),
def run(self): # remove the automatically generated user env scripts for script in [ 'glue-user-env.sh', 'glue-user-env.csh' ]: log.info( 'removing ' + script ) try: os.unlink(os.path.join('etc',script)) except: pass
git_id = check_call_out((git_path, 'log', '-1', '--pretty=%H'))
git_id = check_call_out((git_path, 'log', '-1', '--pretty=format:%H'))
def write_git_version(fileobj): """ Query git to determine current repository status and write a Python module with this information. Ex: >>> write_git_version(open("git_version.py", "w")) >>> import git_version >>> print git_version.id 1b0549019e992d0e001f3c28e8488946f825e873 """ git_path = check_call_out(('/usr/bin/...
git_udate = float(check_call_out((git_path, 'log', '-1', '--pretty=%ct')))
git_udate = float(check_call_out((git_path, 'log', '-1', '--pretty=format:%ct')))
def write_git_version(fileobj): """ Query git to determine current repository status and write a Python module with this information. Ex: >>> write_git_version(open("git_version.py", "w")) >>> import git_version >>> print git_version.id 1b0549019e992d0e001f3c28e8488946f825e873 """ git_path = check_call_out(('/usr/bin/...
git_author_name = check_call_out((git_path, 'log', '-1', '--pretty=%an')) git_author_email = check_call_out((git_path, 'log', '-1', '--pretty=%ae'))
git_author_name = check_call_out((git_path, 'log', '-1', '--pretty=format:%an')) git_author_email = check_call_out((git_path, 'log', '-1', '--pretty=format:%ae'))
def write_git_version(fileobj): """ Query git to determine current repository status and write a Python module with this information. Ex: >>> write_git_version(open("git_version.py", "w")) >>> import git_version >>> print git_version.id 1b0549019e992d0e001f3c28e8488946f825e873 """ git_path = check_call_out(('/usr/bin/...
git_committer_name = check_call_out((git_path, 'log', '-1', '--pretty=%cn')) git_committer_email = check_call_out((git_path, 'log', '-1', '--pretty=%ce'))
git_committer_name = check_call_out((git_path, 'log', '-1', '--pretty=format:%cn')) git_committer_email = check_call_out((git_path, 'log', '-1', '--pretty=format:%ce'))
def write_git_version(fileobj): """ Query git to determine current repository status and write a Python module with this information. Ex: >>> write_git_version(open("git_version.py", "w")) >>> import git_version >>> print git_version.id 1b0549019e992d0e001f3c28e8488946f825e873 """ git_path = check_call_out(('/usr/bin/...
far = [line.split(':')[1].split()[0] for line in log_data.splitlines() if \ 'False Alarm Rate' in line][0] except IndexError:
far = 1/(float(event['IFAR_year'])*365.0) except KeyError:
def populate_inspiral_tables(MBTA_frame, set_keys = MBTA_set_keys, \ event_id_dict = insp_event_id_dict): """ create xml file and populate the SnglInspiral and CoincInspiral tables from a coinc .gwf file from MBTA xmldoc: xml file to append the tables to MBTA_frame: frame file to get info about triggers from set_keys: ...
for f in input_filelist: print >>dagfile, """ <filename file="%s" link="input"/>""" % f
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
for f in inout_filelist: print >>dagfile, """ <filename file="%s" link="inout"/>""" % f
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
for f in output_filelist: print >>dagfile, """ <filename file="%s" link="output"/>""" % f
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
<file-server protocol="file" url="file://" mount-point="/home/dbrown/projects/cbc/dax/ihope-dax3.0/847555570-847641970">
<file-server protocol="file" url="file://" mount-point="%s">
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
<internal-mount-point mount-point="/home/dbrown/projects/cbc/dax/ihope-dax3.0/847555570-847641970" free-size="null" total-size="null"/>
<internal-mount-point mount-point="%s" free-size="null" total-size="null"/>
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
""" % (hostname,hostname)
""" % (hostname,hostname,pwd,pwd,pwd,pwd)
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
parent.job().get_pegasus_exec_dir(), '00/P1/P1.cache') )
parent.job().get_pegasus_exec_dir(), dax_basename + '_0') )
def recurse_pfn_cache(node,caches=[]): for parent in node._CondorDAGNode__parents: if isinstance(parent.job(), CondorDAGManJob): if parent.job().get_dax() is None: pass else: caches = recurse_pfn_cache(parent,caches) caches.append( os.path.join( parent.job().get_pegasus_exec_dir(), '00/P1/P1.cache') ) return caches
print >>dagfile, """\
print >>dagfile, """
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
template = """ <profile namespace="condor" key="universe">%s</profile>"""
template = """ <profile namespace="condor" key="universe">%s</profile>\n"""
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
print >>dagfile, xml
print >>dagfile, xml,
def write_abstract_dag(self): """ Write all the nodes in the workflow to the DAX file. """ if not self.__dax_file_path: # this workflow is not dax-compatible, so don't write a dax return try: dagfile = open( self.__dax_file_path, 'w' ) except: raise CondorDAGError, "Cannot open file " + self.__dag_file_path
from glue import LDRdataFindClient if isinstance( filename, LDRdataFindClient.lfnlist ): self.add_var_opt('glob-frame-data',' ') for lfn in filename: a, b, c, d = lfn.split('.')[0].split('-') t_start = int(c) t_end = int(c) + int(d) if (t_start <= (self.__data_end+int(d)+1) and t_end >= (self.__data_start-int(d)-1)):...
raise CondorDAGNodeError, "Unknown LFN cache format"
def set_cache(self,filename): """ Set the LAL frame cache to to use. The frame cache is passed to the job with the --frame-cache argument. @param filename: calibration file to use. """ if isinstance( filename, str ): # the name of a lal cache file created by a datafind node self.add_var_opt('frame-cache', filename) sel...
def parse(self):
def parse(self,type_regex=None):
def parse(self): """ Each line of the frame cache file is like the following:
count = 0 countIncluded = 0
def parse(self): """ Each line of the frame cache file is like the following:
count += 1
if type_filter and type_filter.search(line) is None: continue
def parse(self): """ Each line of the frame cache file is like the following:
msg = "The combination %s is not unique in the frame cache file" % str(key)
msg = "The combination %s is not unique in the frame cache file" \ % str(key)
def parse(self): """ Each line of the frame cache file is like the following:
countIncluded += 1 f.close() cache['gwf'] = gwfDict
f.close() cache['gwf'] = gwfDict
def parse(self): """ Each line of the frame cache file is like the following:
else: self.__lsync_cache = None
def __init__(self,cache_dir,log_dir,config_file,dax=0,lsync_cache_file=None): """ @param cache_dir: the directory to write the output lal cache files to. @param log_dir: the directory to write the stderr file to. @param config_file: ConfigParser object containing the path to the LSCdataFind executable in the [condor] s...
if certFile and keyFile: h = httplib.HTTPSConnection(server, key_file = keyFile, cert_file = certFile)
if cert and key: h = httplib.HTTPSConnection(server, key_file = key, cert_file = cert)
def get_output(self): """ Return the output file, i.e. the file containing the frame cache data. or the files itself as tuple (for DAX) """ if self.__dax: # we are a dax running in grid mode so we need to resolve the # frame file metadata into LFNs so pegasus can query the RLS if self.__lfn_list is None:
ligolw += '"x\''
ligolw += '"'
def xml(self): """Convert a table dictionary to LIGO lightweight XML""" if len(self.table) == 0: raise LIGOLwDBError, 'attempt to convert empty table to xml' ligolw = """\
ligolw += "%02x" % ord(ch) ligolw += '\'"'
ligolw += "%c" % ch ligolw += '"'
def xml(self): """Convert a table dictionary to LIGO lightweight XML""" if len(self.table) == 0: raise LIGOLwDBError, 'attempt to convert empty table to xml' ligolw = """\
ligolw += '"'+self.strtoxml.xlat(str(tupi))+'"'
ligolw += '"'+self.strtoxml.xlat(string_format_func(tupi))+'"'
def xml(self): """Convert a table dictionary to LIGO lightweight XML""" if len(self.table) == 0: raise LIGOLwDBError, 'attempt to convert empty table to xml' ligolw = """\
raise GitInvocationError, 'failed to run "%s"' % command
raise GitInvocationError, 'failed to run "%s"' % " ".join(command)
def check_call_out(command): """ Run the given command (with shell=False) and return the output as a string. Strip the output of enclosing whitespace. If the return code is non-zero, throw GitInvocationError. """ # start external command process p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PI...
if value: macro = self.__bad_macro_chars.sub( r'', opt ) self.__opts['macro' + macro] = value self.__job.add_var_opt(opt)
macro = self.__bad_macro_chars.sub( r'', opt ) self.__opts['macro' + macro] = value self.__job.add_var_opt(opt)
def add_var_opt(self,opt,value): """ Add a variable (macro) option for this node. If the option specified does not exist in the CondorJob, it is added so the submit file will be correct when written. @param opt: option name. @param value: value of the option for this node in the DAG. """ if value: macro = self.__bad_ma...
if filename: self.add_var_opt(opt,filename) if file_is_output_file: self.add_output_file(filename) else: self.add_input_file(filename)
self.add_var_opt(opt,filename) if file_is_output_file: self.add_output_file(filename) else: self.add_input_file(filename)
def add_file_opt(self,opt,filename,file_is_output_file=False): """ Add a variable (macro) option for this node. If the option specified does not exist in the CondorJob, it is added so the submit file will be correct when written. The value of the option is also added to the list of input files for the DAX. @param opt: ...
return self._impl(node, value, callback, default_callback) def serialize(self, node, value): def callback(subnode, subval): return subnode.serialize(subval) def default_callback(subnode): return subnode.serialize(subnode.default)
def default_callback(subnode): return subnode.default
return subnode.default
return subnode.serialize(subnode.default)
def default_callback(subnode): return subnode.default
date = datetime.date.today()
date = self._today()
def test_serialize_with_date(self): import datetime typ = self._makeOne() date = datetime.date.today() node = DummySchemaNode(None) result = typ.serialize(node, date) expected = datetime.datetime.combine(date, datetime.time()) expected = expected.replace(tzinfo=typ.default_tzinfo).isoformat() self.assertEqual(result, e...
import datetime typ = self._makeOne() dt = datetime.datetime.now() node = DummySchemaNode(None)
typ = self._makeOne() node = DummySchemaNode(None) dt = self._dt()
def test_serialize_with_naive_datetime(self): import datetime typ = self._makeOne() dt = datetime.datetime.now() node = DummySchemaNode(None) result = typ.serialize(node, dt) expected = dt.replace(tzinfo=typ.default_tzinfo).isoformat() self.assertEqual(result, expected)
import datetime
def test_serialize_with_tzware_datetime(self): import datetime import iso8601 typ = self._makeOne() dt = datetime.datetime.now() tzinfo = iso8601.iso8601.FixedOffset(1, 0, 'myname') dt = dt.replace(tzinfo=tzinfo) node = DummySchemaNode(None) result = typ.serialize(node, dt) expected = dt.isoformat() self.assertEqual(re...
dt = datetime.datetime.now()
dt = self._dt()
def test_serialize_with_tzware_datetime(self): import datetime import iso8601 typ = self._makeOne() dt = datetime.datetime.now() tzinfo = iso8601.iso8601.FixedOffset(1, 0, 'myname') dt = dt.replace(tzinfo=tzinfo) node = DummySchemaNode(None) result = typ.serialize(node, dt) expected = dt.isoformat() self.assertEqual(re...
date = datetime.date.today()
date = self._today()
def test_deserialize_date(self): import datetime import iso8601 date = datetime.date.today() typ = self._makeOne() formatted = date.isoformat() node = DummySchemaNode(None) result = typ.deserialize(node, formatted) expected = datetime.datetime.combine(result, datetime.time()) tzinfo = iso8601.iso8601.Utc() expected = e...
import datetime
def test_deserialize_success(self): import datetime import iso8601 typ = self._makeOne() dt = datetime.datetime.now() tzinfo = iso8601.iso8601.FixedOffset(1, 0, 'myname') dt = dt.replace(tzinfo=tzinfo) iso = dt.isoformat() node = DummySchemaNode(None) result = typ.deserialize(node, iso) self.assertEqual(result.isoforma...