code
stringlengths
1
18.2k
original IDs new_alignment = {} for k,v in alignment.items(): new_alignment[int_keys[k]]=v #Create an Alignment object from alignment dict new_alignment = Alignment(new_alignment,MolType=moltype) #Clean up res.cleanUp() del(seq_collection,int_map,int_keys,app,res,alignment) return new_alignment
def add_seqs_to_alignment(seqs, aln, moltype, params=None, accurate=False): """Returns an Alignment object from seqs and existing Alignment. seqs: a cogent.core.sequence.Sequence object, or data that can be used to build one. aln: an cogent.core.alignment.Alignment object, or data that can be used to build one params: ...
app.Parameters[MOLTYPE_MAP[moltype_string]].on() #Do not report progress app.Parameters['--quiet'].on() #Add aln_int_map as seed alignment app.Parameters['--seed'].on(\ app._tempfile_as_multiline_string(aln_int_map.toFasta())) #More accurate alignment, sacrificing performance. if accurate: app.Parameters['--globalpair'...
def align_two_alignments(aln1, aln2, moltype, params=None): """Returns an Alignment object from two existing Alignments. aln1, aln2: cogent.core.alignment.Alignment objects, or data that can be used to build them. - Mafft profile alignment only works with aligned sequences. Alignment object used to handle unaligned seq...
aln2_path = app._tempfile_as_multiline_string(aln2_int_map.toFasta()) filepaths = [aln1_path,aln2_path] #Get results using int_map as input to app res = app(filepaths) #Get alignment as dict out of results alignment = dict(parse_fasta(res['StdOut'])) #Make new dict mapping original IDs new_alignment = {} for k,v in ali...
def doQuery(self, url, method='GET', getParmeters=None, postParameters=None, files=None, extraHeaders={}, session={}): """Send a request to the server and return the result""" # Build headers headers = {} if not postParameters: postParameters = {} for key, value in extraHeaders.iteritems(): # Fixes #197 for values with...
poster.streaminghttp import register_openers import urllib2 import urllib # Register the streaming http handlers with urllib2 register_openers() # headers contains the necessary Content-Type and Content-Length # datagen is a generator object that yields the encoded parameters data = [] for x in postParameters: if isins...
on the method. r = requests.request(method.upper(), self.baseURI + '/' + url, params=getParmeters, stream=True, headers=headers, allow_redirects=True) return r
def ping(self): """Return true if the server successfully pinged""" randomToken = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for x in range(32)) r = self.doQuery('ping?data=' + randomToken) if r.status_code == 200: # Query ok ? if r.json()['data'] == randomToken: # Token equa...
def checkVersion(self): """Check if the server use the same version of our protocol""" r = self.doQuery('version') if r.status_code == 200: # Query ok ? data = r.json() if data['result'] == 'Ok' and data['version'] == self.PI_API_VERSION and data['protocol'] == self.PI_API_NAME: return True return False
def newMail(self, data, message): """Send a mail to a plugit server""" r = self.doQuery('mail', method='POST', postParameters={'response_id': str(data), 'message': str(message)}) if r.status_code == 200: # Query ok ? data = r.json() return data['result'] == 'Ok' return False
def getMedia(self, uri): """Return a tuple with a media and his content-type. Don't cache anything !""" r = self.doQuery('media/' + uri) if r.status_code == 200: content_type = 'application/octet-stream' if 'content-type' in r.headers: content_type = r.headers['content-type'] cache_control = None if 'cache-control' in ...
def getMeta(self, uri): """Return meta information about an action. Cache the result as specified by the server""" action = urlparse(uri).path mediaKey = self.cacheKey + '_meta_' + action mediaKey = mediaKey.replace(' ', '__') meta = cache.get(mediaKey, None) # Nothing found -> Retrieve it from the server and cache it ...
meta, expire) return meta
def getTemplate(self, uri, meta=None): """Return the template for an action. Cache the result. Can use an optional meta parameter with meta information""" if not meta: metaKey = self.cacheKey + '_templatesmeta_cache_' + uri meta = cache.get(metaKey, None) if not meta: meta = self.getMeta(uri) cache.set(metaKey, meta, 1...
template, None) # None = Cache forever return template
def component_offsetvectors(offsetvectors, n): """ Given an iterable of offset vectors, return the shortest list of the unique n-instrument offset vectors from which all the vectors in the input iterable can be constructed. This can be used to determine the minimal set of n-instrument coincs required to construct all o...
where the absolute offsets are significant due to the periodic wrapping of triggers around rings. """ # # collect unique instrument set / deltas combinations # delta_sets = {} for vect in offsetvectors: for instruments in iterutils.choices(sorted(vect), n): # NOTE: the arithmetic used to construct the # offsets *must* ...
def deltas(self): """ Dictionary of relative offsets. The keys in the result are pairs of keys from the offset vector, (a, b), and the values are the relative offsets, (offset[b] - offset[a]). Raises ValueError if the offsetvector is empty (WARNING: this behaviour might change in the future). Example: >>> x = offsetvec...
way they are. Expect them to change in the future. """ # FIXME: instead of raising ValueError when the # offsetvector is empty this should return an empty # dictionary. the inverse, .fromdeltas() accepts # empty dictionaries # NOTE: the arithmetic used to construct the offsets # *must* match the arithmetic used by # ti...
def contains(self, other): """ Returns True if offset vector @other can be found in @self, False otherwise. An offset vector is "found in" another offset vector if the latter contains all of the former's instruments and the relative offsets among those instruments are equal (the absolute offsets need not be). Example: ...
def normalize(self, **kwargs): """ Adjust the offsetvector so that a particular instrument has the desired offset. All other instruments have their offsets adjusted so that the relative offsets are preserved. The instrument to noramlize, and the offset one wishes it to have, are provided as a key-word argument. The ret...
0}) >>> a = offsetvector({"H1": -10, "H2": -10}) >>> a.normalize(L1 = 0, H2 = 5) offsetvector({'H2': 5, 'H1': 5}) """ # FIXME: should it be performed in place? if it should # be, the should there be no return value? for key, offset in sorted(kwargs.items()): if key in self: delta = offset - self[key] for key in self.ke...
def fromdeltas(cls, deltas): """ Construct an offsetvector from a dictionary of offset deltas as returned by the .deltas attribute. Example: >>> x = offsetvector({"H1": 0, "L1": 10, "V1": 20}) >>> y = offsetvector.fromdeltas(x.deltas) >>> y offsetvector({'V1': 20, 'H1': 0, 'L1': 10}) >>> y == x True See also .deltas, ....
def processGif(searchStr): ''' This function returns the url of the gif searched for with the given search parameters using the Giphy API. Thanks! Fails gracefully when it can't find a gif by returning an appropriate image url with the failure message on it. ''' # Sanitizing searchStr # TODO: Find a better way to do th...
:(") return -1 else: # Success! imgURL = parsed_json['data'][0]['images']['fixed_height']['url'] # print(imgURL) return imgURL
def feed(self, data): """ Main method for purifying HTML (overrided) """ self.reset_purified() HTMLParser.feed(self, data) return self.html()
def handle_starttag(self, tag, attrs): """ Handler of starting tag processing (overrided, private) """ self.log.debug( u'Encountered a start tag: {0} {1}'.format(tag, attrs) ) if tag in self.sanitizelist: self.level += 1 return if self.isNotPurify or tag in self.whitelist_keys: attrs = self.__attrs_str(tag, attrs) attr...
def handle_endtag(self, tag): """ Handler of ending tag processing (overrided, private) """ self.log.debug( u'Encountered an end tag : {0}'.format(tag) ) if tag in self.sanitizelist: self.level -= 1 return if tag in self.unclosedTags: return if self.isNotPurify or tag in self.whitelist_keys: self.data.append(u'</%s>' %...
def handle_data(self, data): """ Handler of processing data inside tag (overrided, private) """ self.log.debug( u'Encountered some data : {0}'.format(data) ) if not self.level: self.data.append(data)
def handle_entityref(self, name): """ Handler of processing entity (overrided, private) """ self.log.debug( u'Encountered entity : {0}'.format(name) ) if not self.removeEntity: self.data.append('&%s;' % name)
def __set_whitelist(self, whitelist=None): """ Update default white list by customer white list """ # add tag's names as key and list of enabled attributes as value for defaults self.whitelist = {} # tags that removed with contents self.sanitizelist = ['script', 'style'] if isinstance(whitelist, dict) and '*' in whitel...
def __attrs_str(self, tag, attrs): """ Build string of attributes list for tag """ enabled = self.whitelist.get(tag, ['*']) all_attrs = '*' in enabled items = [] for attr in attrs: key = attr[0] value = attr[1] or '' if all_attrs or key in enabled: items.append( u'%s="%s"' % (key, value,) ) return u' '.join(items)
def hex_from(val): """Returns hex string representation for a given value. :param bytes|str|unicode|int|long val: :rtype: bytes|str """ if isinstance(val, integer_types): hex_str = '%x' % val if len(hex_str) % 2: hex_str = '0' + hex_str return hex_str return hexlify(val)
def b64_from(val): """Returns base64 encoded bytes for a given int/long/bytes value. :param int|long|bytes val: :rtype: bytes|str """ if isinstance(val, integer_types): val = int_to_bytes(val) return b64encode(val).decode('ascii')
def set_output_format( output_format ): """ Sets output format; returns standard bits of table. These are: ttx: how to start a title for a set of tables xtt: how to end a title for a set of tables tx: how to start a table xt: how to close a table capx: how to start a caption for the table xcap: how to close a caption f...
'wiki': ttx = '== ' xtt = ' ==' tx = '' xt = '' capx = "'''" xcap = "'''" rx = '|' xr = '|' rspx = '|<|' xrsp = '>' cx = '|' xc = '|' hlx = '[' hxl = ' ' xhl = ']' elif output_format == "html": ttx = '<b>' xtt = '</b><hr>' tx = '<table border = "1">' xt = '</table><br><br>' capx = '<caption>' xcap = '</caption>' rx = '...
def smart_round( val, decimal_places = 2 ): """ For floats >= 10.**-(decimal_places - 1), rounds off to the valber of decimal places specified. For floats < 10.**-(decimal_places - 1), puts in exponential form then rounds off to the decimal places specified. @val: value to round; if val is not a float, just returns val...
def format_hyperlink( val, hlx, hxl, xhl ): """ Formats an html hyperlink into other forms. @hlx, hxl, xhl: values returned by set_output_format """ if '<a href="' in str(val) and hlx != '<a href="': val = val.replace('<a href="', hlx).replace('">', hxl, 1).replace('</a>', xhl) return val
def format_cell(val, round_floats = False, decimal_places = 2, format_links = False, hlx = '', hxl = '', xhl = ''): """ Applys smart_round and format_hyperlink to values in a cell if desired. """ if round_floats: val = smart_round(val, decimal_places = decimal_places) if format_links: val = format_hyperlink(val, hlx, h...
def format_header_cell(val): """ Formats given header column. This involves changing '_Px_' to '(', '_xP_' to ')' and all other '_' to spaces. """ return re.sub('_', ' ', re.sub(r'(_Px_)', '(', re.sub(r'(_xP_)', ')', str(val) )))
def get_row_data(row, column_name, cat_time_ns = True): """ Retrieves the requested column's data from the given row. @cat_time_ns: If the column_name has "_time" in it, will concatenate the column with any column having the same name but "_time_ns". """ column_name_ns = re.sub(r'_time', r'_time_ns', column_name) try: ...
def print_tables(xmldoc, output, output_format, tableList = [], columnList = [], round_floats = True, decimal_places = 2, format_links = True, title = None, print_table_names = True, unique_rows = False, row_span_columns = [], rspan_break_columns = []): """ Method to print tables in an xml file in other formats. Input ...
have a listed column, it's just skipped). To specify a column in a specific table, use table_name:column_name. Default is to print all columns. @round_floats: If turned on, will smart_round floats to specifed number of places. @format_links: If turned on, will convert any html hyperlinks to specified output_format. @de...
will prevent all cells from rowspanning across two rows in which values in the columns are diffrent. Default is to have no break columns. """ # get the tables to convert if tableList == []: tableList = [tb.getAttribute("Name") for tb in xmldoc.childNodes[0].getElementsByTagName(u'Table')] # set the output if output is ...
columnList if not (':' in col and col.split(':')[0] != table_name) ] requested_columns = sorted(set(requested_columns), key=requested_columns.index) actual_columns = [actual_column.getAttribute("Name").split(":")[-1] for actual_column in this_table.getElementsByTagName(u'Column') ] col_names = [col for col in requested...
[ str(format_cell( get_row_data(row, col_name), round_floats = round_floats, decimal_places = decimal_places, format_links = format_links, hlx = hlx, hxl = hxl, xhl = xhl )) for col_name in col_names ] if unique_rows and out_row == last_row: continue out_table.append(out_row) last_row = out_row rspan_count = {} for mm,...
and nn in rspan_indices: if val == out_table[next_row_idx][nn]: out_table[this_row_idx][nn] = '' if (this_row_idx, nn) in rspan_count: rspan_count[(next_row_idx,nn)] = rspan_count[(this_row_idx,nn)] + 1 del rspan_count[(this_row_idx,nn)] else: rspan_count[(next_row_idx,nn)] = 2 elif (this_row_idx, nn) in rspan_count: o...
def write_build_info(): """ Get VCS info from pycbc_glue/generate_vcs_info.py and add build information. Substitute these into pycbc_glue/git_version.py.in to produce pycbc_glue/git_version.py. """ date = branch = tag = author = committer = status = builder_name = build_date = "" id = "1.1.0" try: v = gvcsi.generate_gi...
's/@TAG@/%s/' % tag, '-e', 's/@AUTHOR@/%s/' % author, '-e', 's/@COMMITTER@/%s/' % committer, '-e', 's/@STATUS@/%s/' % status, '-e', 's/@BUILDER@/%s/' % builder_name, '-e', 's/@BUILD_DATE@/%s/' % build_date, 'misc/git_version.py.in') # FIXME: subprocess.check_call becomes available in Python 2.5 sed_retcode = subprocess...
def pad(self, val): """ :param val: :rtype: bytes """ padding = len(int_to_bytes(self._prime)) padded = int_to_bytes(val).rjust(padding, b'\x00') return padded
def hash(self, *args, **kwargs): """ :param args: :param kwargs: joiner - string to join values (args) as_bytes - bool to return hash bytes instead of default int :rtype: int|bytes """ joiner = kwargs.get('joiner', '').encode('utf-8') as_bytes = kwargs.get('as_bytes', False) def conv(arg): if isinstance(arg, integer_ty...
def generate_random(self, bits_len=None): """Generates a random value. :param int bits_len: :rtype: int """ bits_len = bits_len or self._bits_random return random().getrandbits(bits_len)
def get_common_secret(self, server_public, client_public): """u = H(PAD(A) | PAD(B)) :param int server_public: :param int client_public: :rtype: int """ return self.hash(self.pad(client_public), self.pad(server_public))
def get_client_premaster_secret(self, password_hash, server_public, client_private, common_secret): """S = (B - (k * g^x)) ^ (a + (u * x)) % N :param int server_public: :param int password_hash: :param int client_private: :param int common_secret: :rtype: int """ password_verifier = self.get_common_password_verifier(pa...
def get_server_premaster_secret(self, password_verifier, server_private, client_public, common_secret): """S = (A * v^u) ^ b % N :param int password_verifier: :param int server_private: :param int client_public: :param int common_secret: :rtype: int """ return pow((client_public * pow(password_verifier, common_secret, ...
def get_server_public(self, password_verifier, server_private): """B = (k*v + g^b) % N :param int password_verifier: :param int server_private: :rtype: int """ return ((self._mult * password_verifier) + pow(self._gen, server_private, self._prime)) % self._prime
def get_common_password_hash(self, salt): """x = H(s | H(I | ":" | P)) :param int salt: :rtype: int """ password = self._password if password is None: raise SRPException('User password should be in context for this scenario.') return self.hash(salt, self.hash(self._user, password, joiner=':'))
def get_common_session_key_proof(self, session_key, salt, server_public, client_public): """M = H(H(N) XOR H(g) | H(U) | s | A | B | K) :param bytes session_key: :param int salt: :param int server_public: :param int client_public: :rtype: bytes """ h = self.hash prove = h( h(self._prime) ^ h(self._gen), h(self._user), ...
def get_common_session_key_proof_hash(self, session_key, session_key_proof, client_public): """H(A | M | K) :param bytes session_key: :param bytes session_key_proof: :param int client_public: :rtype: bytes """ return self.hash(client_public, session_key_proof, session_key, as_bytes=True)
def get_user_data_triplet(self, base64=False): """( <_user>, <_password verifier>, <salt> ) :param base64: :rtype: tuple """ salt = self.generate_salt() verifier = self.get_common_password_verifier(self.get_common_password_hash(salt)) verifier = value_encode(verifier, base64) salt = value_encode(salt, base64) return se...
def add_input_file(self, filename): """ Add filename as a necessary input file for this DAG node. @param filename: input filename to add """ if filename not in self.__input_files: self.__input_files.append(filename)
def add_output_file(self, filename): """ Add filename as a output file for this DAG node. @param filename: output filename to add """ if filename not in self.__output_files: self.__output_files.append(filename)
def add_checkpoint_file(self, filename): """ Add filename as a checkpoint file for this DAG job. """ if filename not in self.__checkpoint_files: self.__checkpoint_files.append(filename)
def add_file_arg(self, filename): """ Add a file argument to the executable. Arguments are appended after any options and their order is guaranteed. Also adds the file name to the list of required input data for this job. @param filename: file to add as argument. """ self.__arguments.append(filename) if filename not in...
def get_opt( self, opt): """ Returns the value associated with the given command line option. Returns None if the option does not exist in the options list. @param opt: command line option """ if self.__options.has_key(opt): return self.__options[opt] return None
def add_file_opt(self, opt, filename): """ Add a command line option to the executable. The order that the arguments will be appended to the command line is not guaranteed, but they will always be added before any command line arguments. The name of the option is prefixed with double hyphen and the program is expected ...
def add_ini_opts(self, cp, section): """ Parse command line options from a given section in an ini file and pass to the executable. @param cp: ConfigParser object pointing to the ini file. @param section: section of the ini file to add to the options. """ for opt in cp.options(section): arg = string.strip(cp.get(sectio...
def write_sub_file(self): """ Write a submit file for this Condor job. """ if not self.__log_file: raise CondorSubmitError, "Log file not specified." if not self.__err_file: raise CondorSubmitError, "Error file not specified." if not self.__out_file: raise CondorSubmitError, "Output file not specified." if not self.__s...
'universe = ' + self.__universe + '\n' ) subfile.write( 'executable = ' + self.__executable + '\n' ) if self.__universe == 'grid': if self.__grid_type == 'gt2': subfile.write('grid_resource = %s %s\n' % (self.__grid_type, self.__grid_server)) if self.__grid_type == 'gt4': subfile.write('grid_resource = %s %s %s\n' % (s...
' "\n' ) for cmd in self.__condor_cmds.keys(): subfile.write( str(cmd) + " = " + str(self.__condor_cmds[cmd]) + '\n' ) subfile.write( 'log = ' + self.__log_file + '\n' ) if self.__in_file is not None: subfile.write( 'input = ' + self.__in_file + '\n' ) subfile.write( 'error = ' + self.__err_file + '\n' ) subfile.write(...
def set_grid_site(self,site): """ Set the grid site to run on. If not specified, will not give hint to Pegasus """ self.__grid_site=str(site) if site != 'local': self.set_executable_installed(False)
def add_var_opt(self, opt, short=False): """ Add a variable (or macro) option to the condor job. The option is added to the submit file and a different argument to the option can be set for each node in the DAG. @param opt: name of option to add. """ if opt not in self.__var_opts: self.__var_opts.append(opt) macro = se...
def add_var_condor_cmd(self, command): """ Add a condor command to the submit file that allows variable (macro) arguments to be passes to the executable. """ if command not in self.__var_cmds: self.__var_cmds.append(command) macro = self.__bad_macro_chars.sub( r'', command ) self.add_condor_cmd(command, '$(macro' + mac...
def add_var_arg(self,arg_index): """ Add a command to the submit file to allow variable (macro) arguments to be passed to the executable. """ try: self.__var_args[arg_index] except IndexError: if arg_index != self.__arg_index: raise CondorDAGJobError, "mismatch between job and node var_arg index" self.__var_args.append...
def add_pegasus_profile(self, namespace, key, value): """ Add a Pegasus profile to this job which will be written to the dax as <profile namespace="NAMESPACE" key="KEY">VALUE</profile> This can be used to add classads to particular jobs in the DAX @param namespace: A valid Pegasus namespace, e.g. condor. @param key: Th...
def add_input_file(self, filename): """ Add filename as a necessary input file for this DAG node. @param filename: input filename to add """ if filename not in self.__input_files: self.__input_files.append(filename) if not isinstance(self.job(), CondorDAGManJob): if self.job().get_universe() == 'grid': self.add_input_m...
def add_output_file(self, filename): """ Add filename as a output file for this DAG node. @param filename: output filename to add """ if filename not in self.__output_files: self.__output_files.append(filename) if not isinstance(self.job(), CondorDAGManJob): if self.job().get_universe() == 'grid': self.add_output_macro...
def add_checkpoint_file(self,filename): """ Add filename as a checkpoint file for this DAG node @param filename: checkpoint filename to add """ if filename not in self.__checkpoint_files: self.__checkpoint_files.append(filename) if not isinstance(self.job(), CondorDAGManJob): if self.job().get_universe() == 'grid': sel...
def get_input_files(self): """ Return list of input files for this DAG node and its job. """ input_files = list(self.__input_files) if isinstance(self.job(), CondorDAGJob): input_files = input_files + self.job().get_input_files() return input_files
def get_output_files(self): """ Return list of output files for this DAG node and its job. """ output_files = list(self.__output_files) if isinstance(self.job(), CondorDAGJob): output_files = output_files + self.job().get_output_files() return output_files
def get_checkpoint_files(self): """ Return a list of checkpoint files for this DAG node and its job. """ checkpoint_files = list(self.__checkpoint_files) if isinstance(self.job(), CondorDAGJob): checkpoint_files = checkpoint_files + self.job().get_checkpoint_files() return checkpoint_files
def add_macro(self,name,value): """ Add a variable (macro) for this node. This can be different for each node in the DAG, even if they use the same CondorJob. Within the CondorJob, the value of the macro can be referenced as '$(name)' -- for instance, to define a unique output or error file for each node. @param name: ...
def add_io_macro(self,io,filename): """ Add a variable (macro) for storing the input/output files associated with this node. @param io: macroinput or macrooutput @param filename: filename of input/output file """ io = self.__bad_macro_chars.sub( r'', io ) if io not in self.__opts: self.__opts[io] = filename else: if fi...
def add_var_condor_cmd(self, command, value): """ Add a variable (macro) condor command for this node. If the command specified does not exist in the CondorJob, it is added so the submit file will be correct. PLEASE NOTE: AS with other add_var commands, the variable must be set for all nodes that use the CondorJob inst...
def add_var_opt(self,opt,value,short=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. @param opt: option name. @param value: value of the option for this node in the DAG. """ macro = self.__bad_...
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: ...
def add_var_arg(self, arg): """ Add a variable (or macro) argument to the condor job. The argument is added to the submit file and a different value of the argument can be set for each node in the DAG. @param arg: name of option to add. """ self.__args.append(arg) self.__job.add_var_arg(self.__arg_index) self.__arg_ind...
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(...
def write_vars(self,fh): """ Write the variable (macro) options and arguments to the DAG file descriptor. @param fh: descriptor of open DAG file. """ if self.__macros.keys() or self.__opts.keys() or self.__args: fh.write( 'VARS ' + self.__name ) for k in self.__macros.keys(): fh.write( ' ' + str(k) + '="' + str(self.__...
def write_parents(self,fh): """ Write the parent/child relations for this job to the DAG file descriptor. @param fh: descriptor of open DAG file. """ for parent in self.__parents: fh.write( 'PARENT ' + str(parent) + ' CHILD ' + str(self) + '\n' )
def write_pre_script(self,fh): """ Write the pre script for the job, if there is one @param fh: descriptor of open DAG file. """ if self.__pre_script: fh.write( 'SCRIPT PRE ' + str(self) + ' ' + self.__pre_script + ' ' + ' '.join(self.__pre_script_args) + '\n' )
def write_post_script(self,fh): """ Write the post script for the job, if there is one @param fh: descriptor of open DAG file. """ if self.__post_script: fh.write( 'SCRIPT POST ' + str(self) + ' ' + self.__post_script + ' ' + ' '.join(self.__post_script_args) + '\n' )
def write_input_files(self, fh): """ Write as a comment into the DAG file the list of input files for this DAG node. @param fh: descriptor of open DAG file. """ for f in self.__input_files: print >>fh, "## Job %s requires input file %s" % (self.__name, f)
def write_output_files(self, fh): """ Write as a comment into the DAG file the list of output files for this DAG node. @param fh: descriptor of open DAG file. """ for f in self.__output_files: print >>fh, "## Job %s generates output file %s" % (self.__name, f)
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,CondorDAGManNode) ): raise CondorDAGNodeError, "Parent must be a CondorDAGNode or a CondorDAGManNo...
def get_cmd_tuple_list(self): """ Return a list of tuples containg the command line arguments """ # pattern to find DAGman macros pat = re.compile(r'\$\((.+)\)') argpat = re.compile(r'\d+') # first parse the options and replace macros with values options = self.job().get_opts() macros = self.get_opts() cmd_list = [] fo...
self.get_args() for a in args: m = pat.match(a) if m: arg_index = int(argpat.findall(a)[0]) try: cmd_list.append(("%s" % macros[arg_index], "")) except IndexError: cmd_list.append("") else: cmd_list.append(("%s" % a, "")) return cmd_list
def get_cmd_line(self): """ Return the full command line that will be used when this node is run by DAGman. """ cmd = "" cmd_list = self.get_cmd_tuple_list() for argument in cmd_list: cmd += ' '.join(argument) + " " return cmd
def add_maxjobs_category(self,categoryName,maxJobsNum): """ Add a category to this DAG called categoryName with a maxjobs of maxJobsNum. @param node: Add (categoryName,maxJobsNum) tuple to CondorDAG.__maxjobs_categories. """ self.__maxjobs_categories.append((str(categoryName),str(maxJobsNum)))