rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if row.type not in metaio.Types:
if row.type not in types.Types:
def append(self, row): if row.type not in metaio.Types: raise ligolw.ElementError, "ProcessParamsTable.append(): unrecognized type \"%s\"" % row.type LSCTableMulti.append(self, row)
class SegmentError(exceptions.Exception): def __init__(self, args=None): self.args = args
def __init__(self, args=None): self.args = args
universe = the condor universe to run the job in executable = the executable to run queue = number of jobs to queue
universe = the condor universe to run the job in. executable = the executable to run. queue = number of jobs to queue.
def __init__(self, universe, executable, queue): """ universe = the condor universe to run the job in executable = the executable to run queue = number of jobs to queue """ self.__universe = universe self.__executable = executable self.__queue = queue
arg = command line argument to add value = value to pass to the argument (None for no argument)
arg = command line argument to add. value = value to pass to the argument (None for no argument).
def add_arg(self, arg, value): """ Add a command line argument to the executable. arg = command line argument to add value = value to pass to the argument (None for no argument) """ self.__arguments[arg] = value
cp = ConfigParser object pointing to the ini file section = section of the ini file to add to the arguments
cp = ConfigParser object pointing to the ini file. section = section of the ini file to add to the arguments.
def add_ini_args(self, cp, section): """ Parse command line arguments from a given section in an ini file and pass to the executable. cp = ConfigParser object pointing to the ini file section = section of the ini file to add to the arguments """ for opt in cp.options(section): arg = string.strip(cp.get(section,opt)) se...
value = email address or never for no notification
value = email address or never for no notification.
def set_notifcation(self, value): """ Set the email address to send notification to. value = email address or never for no notification """ self.__notification = value
path = path to log file
path = path to log file.
def set_log_file(self, path): """ Set the Condor log file. path = path to log file """ self.__log_file = path
path = path to stderr file
path = path to stderr file.
def set_stderr_file(self, path): """ Set the file to which Condor directs the stderr of the job. path = path to stderr file """ self.__err_file = path
path = path to stdout file
path = path to stdout file.
def set_stdout_file(self, path): """ Set the file to which Condor directs the stdout of the job. path = path to stdout file """ self.__out_file = path
path = path to submit file
path = path to submit file.
def set_sub_file(self, path): """ Set the name of the file to write the Condor submit file to when write_sub_file() is called. path = path to submit file """ self.__sub_file_path = path
path = path to submit file
path = path to submit file.
def get_sub_file(self): """ Get the name of the file which the Condor submit file will be written to when write_sub_file() is called. path = path to submit file """ return self.__sub_file_path
universe = the condor universe to run the job in executable = the executable to run in the DAG """ CondorJob.__init__(self, executable, universe, 1)
universe = the condor universe to run the job in. executable = the executable to run in the DAG. """ CondorJob.__init__(self, universe, executable, 1)
def __init__(self, universe, executable): """ universe = the condor universe to run the job in executable = the executable to run in the DAG """ CondorJob.__init__(self, executable, universe, 1) self.__notifcation = 'never' self.__var_args = []
each node in the DAG arg = name of option to add
each node in the DAG. arg = name of option to add.
def add_var_arg(self, arg): """ 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 fot each node in the DAG arg = name of option to add """ if arg not in self.__var_args: self.__var_args.append(arg) self.add_arg(arg,'$(' + arg + '...
job = the CondorJob that this node corresponds to
job = the CondorJob that this node corresponds to.
def __init__(self, job): """ job = the CondorJob that this node corresponds to """ if not isinstance(job, CondorDAGJob): raise CondorDAGNodeError, "A DAG node must correspond to a Condor DAG job" self.__name = None self.__job = job self.__vars = {} self.__retry = 0 self.__parents = [] self.set_name()
Return the CondorJob that this node is associated with
Return the CondorJob that this node is associated with.
def job(self): """ Return the CondorJob that this node is associated with """ return self.__job
Generate a unique name for this node in the DAG
Generate a unique name for this node in the DAG.
def set_name(self): """ Generate a unique name for this node in the DAG """ t = str( long( time.time() * 1000 ) ) r = str( long( random.random() * 100000000000000000L ) ) a = str( self.__class__ ) self.__name = md5.md5(t + r + a).hexdigest()
var = option name value = value of the option for this node in the DAG
var = option name. value = value of the option for this node in the DAG.
def add_var(self,var,value): """ Add the a variable (macro) arguments 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. var = option name value = value of the option for this node in the DAG """ self.__vars[var] = value self.__job.add_va...
Set the number of times that this node in the DAG should retry retry = number of times to retry node
Set the number of times that this node in the DAG should retry. retry = number of times to retry node.
def set_retry(self, retry): """ Set the number of times that this node in the DAG should retry retry = number of times to retry node """ self.__retry = retry
Write the DAG entry for this node to the DAG file descriptor fh = descriptor of open DAG file
Write the DAG entry for this node to the DAG file descriptor. fh = descriptor of open DAG file.
def write(self,fh): """ Write the DAG entry for this node to the DAG file descriptor fh = descriptor of open DAG file """ fh.write( 'JOB ' + self.__name + ' ' + self.__job.get_sub_file() + '\n' ) fh.write( 'RETRY ' + self.__name + ' ' + str(self.__retry) + '\n' ) if self.__vars.keys(): fh.write( 'VARS ' + self.__name ...
Set the Condor log file to be used by this CondorJob log = path of Condor log file
Set the Condor log file to be used by this CondorJob. log = path of Condor log file.
def set_log_file(self,log): """ Set the Condor log file to be used by this CondorJob log = path of Condor log file """ self.__job.set_log_file(log)
node = CondorDAGNode to add as a parent
node = CondorDAGNode to add as a parent.
def add_parent(self,node): """ Add a parent to this node. This node will not be executed until the parent node has run sucessfully. node = CondorDAGNode to add as a parent """ if not isinstance(node, CondorDAGNode): raise CondorDAGNodeError, "Parent must be a Condor DAG node" self.__parents.append( str(node) )
path = path to DAG file
path = path to DAG file.
def set_dag_file(self, path): """ Set the name of the file into which the DAG is written. path = path to DAG file """ self.__dag_file_path = path
node = CondorDAGNode to add to the CondorDAG
node = CondorDAGNode to add to the CondorDAG.
def add_node(self,node): """ Add a CondorDAGNode to this DAG. The CondorJob that the node uses is also added to the list of Condor jobs in the DAG so that a list of the submit files needed by the DAG can be maintained. Each unique CondorJob will be added once to prevent duplicate submit files being written. node = Cond...
cp = ConfigParser object that contains the configuration for this job
cp = ConfigParser object that contains the configuration for this job.
def __init__(self,cp): """ cp = ConfigParser object that contains the configuration for this job """ self.__cp = cp self.__channel = string.strip(self.__cp.get('input','channel'))
sec = ini file section opt = option from section sec
sec = ini file section. opt = option from section sec.
def get_config(self,sec,opt): """ Get the configration variable in a particular section of this jobs ini file. sec = ini file section opt = option from section sec """ return string.strip(self.__cp.get(sec,opt))
Returns the name of the calibration file to use for the given IFO ifo = name of interferomener (e.g. L1, H1 or H2)
Returns the name of the calibration file to use for the given IFO. ifo = name of interferomener (e.g. L1, H1 or H2).
def calibration(self,ifo): """ Returns the name of the calibration file to use for the given IFO ifo = name of interferomener (e.g. L1, H1 or H2) """ cal_path = string.strip(self.__cp.get('calibration','path')) cal_file = string.strip(self.__cp.get('calibration',ifo)) cal = os.path.join(cal_path,cal_file) return cal
class SegmentError(exceptions.Exception): def __init__(self, args=None): self.args = args
def set_cache(self,file): self.add_var('frame-cache', file)
def gps_processor(object):
def gps_processor(self):
def gps_processor(object): """ Performs a consistancy check on start and end gps times along with the duration parameter. If the three fields are not None, makes sure they are consistent.
def ifo_processor(object):
def ifo_processor(self):
def ifo_processor(object): """ Checks given interferometer against list of accepted interferometers. returns 0 if found, an error string if not. """ ifo = self.attr['interferometer']['Value'] accepted_ifos = self.attr['interferometer']['Accepted_values'] if not ifo: return "Interferomter(s) must be specified. Accepted ...
return "Interferometer \"%s\" was not found in the list of accepted interferometers. Valid ifos are %s." % (ifo, str(accepted_ifos))
return "Interferometer \"%s\" was not found in the list of accepted interferometers. Valid ifos are any combination of the following: %s." % (ifo, str(accepted_ifos))
def ifo_processor(object): """ Checks given interferometer against list of accepted interferometers. returns 0 if found, an error string if not. """ ifo = self.attr['interferometer']['Value'] accepted_ifos = self.attr['interferometer']['Accepted_values'] if not ifo: return "Interferomter(s) must be specified. Accepted ...
def site_processor(object):
def site_processor(self):
def site_processor(object): """ Check given site against list of accepted sites. returns 0 if found, an error string if not """ site = self.attr['site']['Value'] if not site: return site # split site list sitelist = list(site) accepted_sites = self.attr['site']['Accepted_values'] for mysite in sitelist: if not accepted...
def filetype_processor(self): """ Makes sure that the file type (a.k.a. file extension), matches one that is allowed in the database. """ thistype = self.attr['fileType']['Value'] accepted_types = self.attr['fileType']['Accepted_values'] if not accepted_types.count(thistype): return "File type \"%s\" is not accepted. A...
def site_processor(object): """ Check given site against list of accepted sites. returns 0 if found, an error string if not """ site = self.attr['site']['Value'] if not site: return site # split site list sitelist = list(site) accepted_sites = self.attr['site']['Accepted_values'] for mysite in sitelist: if not accepted...
'Requirements':['size']
'Test_method':None
def __init__(self): self.attr = {
'Requirements':['md5']
'Test_method':None
def __init__(self): self.attr = {
'UserSet':False, 'Cli_arg_long':None, 'Cli_arg_short':None,
'UserSet':True, 'Cli_arg_long':"interferometer", 'Cli_arg_short':"i",
def __init__(self): self.attr = {
'Requirements':None
'Test_method':getattr(self,"ifo_processor")
def __init__(self): self.attr = {
'Requirements':None
'Test_method':getattr(self,"site_processor")
def __init__(self): self.attr = {
'Test_method':None
'Test_method':getattr(self,"filetype_processor")
def __init__(self): self.attr = {
'Test_method':None
'Test_method':getattr(self,"gps_processor")
def __init__(self): self.attr = {
'Requirements':['gpsEnd']
'Test_method':getattr(self,"gps_processor")
def __init__(self): self.attr = {
'Requirements':['duration']
'Test_method':getattr(self,"gps_processor")
def __init__(self): self.attr = {
'Requirements':None
'Test_method':None
def __init__(self): self.attr = {
'Requirements':None
'Test_method':getattr(self,"group_processor")
def __init__(self): self.attr = {
'Description':"Name of file's creator. That is the person ran the code which generated the data.", 'Requirements':None
'Description':"Name of file's creator. That is the person that ran the code which generated this data.", 'Test_method':None
def __init__(self): self.attr = {
'Description':"An arbitrary comment describing this file. e.g. \"generated Big Bang Search v0.1a. with fftw v12.2.4\". (quotes on command line are necessary)", 'Requirements':None
'Description':"An arbitrary comment describing this file. e.g. \"generated Big Bang Search v0.1a. with fftw v16.2.4 alpha\". (quotes on command line are necessary)", 'Test_method':None
def __init__(self): self.attr = {
print >>sys.stderr, "Filename %s does not exist. Skipping." % filename
msg = "Filename %s does not exist (or is a directory)." % (filename,) print >>sys.stderr, "%s Skipping." % msg failures.append((filename,msg))
def publish(self,attributes = {}, filelist = []): """ Adds a lfn <-> pfn mapping. After checking for existance of previous mapping, and calculating md5s and any file format specific checksums? """ # authentication stuff #blah # import use specified attributes self.attr = attributes # dumb importation at the moment # at...
pfn = filename
def publish(self,attributes = {}, filelist = []): """ Adds a lfn <-> pfn mapping. After checking for existance of previous mapping, and calculating md5s and any file format specific checksums? """ # authentication stuff #blah # import use specified attributes self.attr = attributes # dumb importation at the moment # at...
try: for field,vals in self.attr.iteritems(): if vals['Test_method'] is not None: result = vals['Test_method']() if result: failures.append((filename,result)) raise LSCfileAddException, "Error, skipping file: %s" % (result,) except LSCfileAddException, e: print >>sys.stderr, e continue
def publish(self,attributes = {}, filelist = []): """ Adds a lfn <-> pfn mapping. After checking for existance of previous mapping, and calculating md5s and any file format specific checksums? """ # authentication stuff #blah # import use specified attributes self.attr = attributes # dumb importation at the moment # at...
self.shortop = self.shortop + ":" + field
self.shortop = self.shortop + field + ":"
def __init__(self): """ Sets up appropriate strings and dictionaries. The parameters here should reflect available database fields. """ LSCfileAddMetadataAttr.__init__(self) #Initializes some shorthand variables from the attr dictionary. for field, vals in self.attr.iteritems(): if vals['UserSet']: if vals['Cli_arg_sho...
pass
exit = "NO" for op in self.shortop.split(":"): for field,vals in self.attr.iteritems(): if vals['Cli_arg_short'] == op: exit = "YES" print >>sys.stderr, "Option collision shortop is \"%s\"\nField is %s" % (op,field) for op in self.longop: for field,vals in self.attr.iteritems(): if vals['Cli_arg_short'] == op: exit = "...
def class_sanity_check(self): """ Meant to be run by the programmer to make sure that this class is sane. For example, this checks to make sure the attribute dictionary is self consistant (should be in LSCfileAddMetadataAttr...), but also compares with non-metadata specific CLI args to make sure nothing gets clobbered ...
print >>sys.stderr, "shoptop %s\nlongop %s" % (self.shortop,str(self.longop))
def get_user_parameters(self): """ Grabs data from command line, user environment, etc. and sets the appropriate variables to be used later. """ try: opts, args = getopt.getopt(sys.argv[1:], self.shortop, self.longop) except getopt.GetoptError: print >>sys.stderr, "Error parsing command line" ## DEBUG print >>sys.stder...
logger.debug("removing process row for key %s" % str(uniq_proc))
logger.debug("removing known process row for key %s" % str(uniq_proc))
def insertdmt(self, arg): """ Insert LIGO_LW xml data from the DMT in the metadata database. For DMT inserts, we need to check for existing process_id and segment_definer_id rows and change the contents of the table to be inserted accordingly. We must also update the end_time of any existing entries in the process tabl...
logger.debug("%s updating process_id %s" % (dn, known_proc[pid][0]))
logger.debug('"%s" updating process_id %s' % (dn, known_proc[pid][0]))
def insertdmt(self, arg): """ Insert LIGO_LW xml data from the DMT in the metadata database. For DMT inserts, we need to check for existing process_id and segment_definer_id rows and change the contents of the table to be inserted accordingly. We must also update the end_time of any existing entries in the process tabl...
logger.debug("removing segment_definer row for key %s" % str(uniq_def))
logger.debug("removing known segment_definer row for key %s" % str(uniq_def))
uniq_def = (row[run_col],row[ifos_col],row[name_col],row[vers_col])
db_seg_def_id = ligomd.curs.fetchone() if not db_seg_def_id:
db_seg_def_id = ligomd.curs.fetchall() if len(db_seg_def_id) == 0:
uniq_def = (row[run_col],row[ifos_col],row[name_col],row[vers_col])
dmt_seg_def_dict[uniq_def] = db_seg_def_id[0]
dmt_seg_def_dict[uniq_def] = db_seg_def_id[0][0]
uniq_def = (row[run_col],row[ifos_col],row[name_col],row[vers_col])
def __init__(self, dbname, dbuser = '', dbpasswd = ''):
def __init__(self, dbname, dbuser = '', dbpasswd = '', debug = False):
def __init__(self, dbname, dbuser = '', dbpasswd = ''): """ Open a connection to the state segment database.
self.debug = True
self.debug = debug
def __init__(self, dbname, dbuser = '', dbpasswd = ''): """ Open a connection to the state segment database.
self.cursor.commit()
self.db.commit()
def close(self): """ Close the connection to the database. """ try: now = gpstime.GpsSecondsFromPyUTC(time.time()) sql = "UPDATE process SET (end_time) = (?) WHERE process_id = '%s'" % self.process_id self.cursor.execute(sql,tuple([now])) self.cursor.commit() except Exception, e: msg = "Error inserting end_time into da...
finally:
try:
def close(self): """ Close the connection to the database. """ try: now = gpstime.GpsSecondsFromPyUTC(time.time()) sql = "UPDATE process SET (end_time) = (?) WHERE process_id = '%s'" % self.process_id self.cursor.execute(sql,tuple([now])) self.cursor.commit() except Exception, e: msg = "Error inserting end_time into da...
'STATEVEC%d.%d' % (ver, val), 0,
'STATEVEC.%d.%d' % (ver, val), 0,
def publish_state(self, ifo, start_time, start_time_ns, end_time, end_time_ns, ver, val ): """ Publish a state segment for a state vector in the database """
print ("DEBUG: create a new state vec type (%d,%d)" % \ (ver,val)), self.state_vec[(ver,val)]
print ("DEBUG: created a new state vec type (%d,%d), id = " % \ (ver,val)), print tuple([self.state_vec[(ver,val)]])
def publish_state(self, ifo, start_time, start_time_ns, end_time, end_time_ns, ver, val ): """ Publish a state segment for a state vector in the database """
print "DEBUG: inserted with segment_id", segment_id
print "DEBUG: inserted with segment_id " print tuple([segment_id])
def publish_state(self, ifo, start_time, start_time_ns, end_time, end_time_ns, ver, val ): """ Publish a state segment for a state vector in the database """
class SnglInspiralIDs(ILWD): def __init__(self, n = 0): ILWD.__init__(self, "sngl_inspiral", "event_id", n)
def set_end(self, gps): self.end_time, self.end_time_ns = gps.seconds, gps.nanoseconds
metaio.StripTableName(SnglInspiralTable.tableName),
def __init__(self, n = 0): ILWD.__init__(self, "coinc_event", "coinc_event_id", n)
metaio.StripTableName(SnglInspiralTable.tableName): SnglInspiralIDs,
def __init__(self, n = 0): ILWD.__init__(self, "ligolw_mon", "event_id", n)
if ( int(e[0]) == 8003 and e[1] == -9999 ):
logger.debug( "OperationalError: %s" % str(e) ) if ( int(e[0]) == 8003 and e[1] == -99999 ):
def distinctAttribute(self, arg): """ Find distinct values for an attribute. Corresponds to the DISTINCT method in the LSCsegFindServer RPC protocol.
if ( int(e[0]) == 8003 and e[1] == -9999 ):
logger.debug( "OperationalError: %s" % str(e) ) if ( int(e[0]) == 8003 and e[1] == -99999 ):
def segmentFindWithMetadata_vx(self, arg): """ Given a list of attributes to query on, the first of which is the segfind client/server communication protocol version. Corresponds to the METASEGSVX method in the LSCsegFindServer RPC protocol.
if comment != None:
if comment is not None:
def new_param(name, type, value, comment = None): """ Construct a LIGO Light Weight XML Param document subtree. """ elem = Param({"Name": "%s:param" % name, "Type": type}) elem.pcdata = value if comment != None: elem.appendChild(ligolw.Comment()) elem.childNodes[-1].pcdata = comment return elem
if t in types.IntTypes: self.pytype = int elif t in types.FloatTypes: self.pytype = float elif t in types.StringTypes: self.pytype = str else: raise TypeError, t
self.pytype = types.ToPyType[t]
def __init__(self, *attrs): """ Initialize a new Param element. """ ligolw.Param.__init__(self, *attrs) try: t = self.getAttribute("Type") except KeyError: # default t = "lstring" if t in types.IntTypes: self.pytype = int elif t in types.FloatTypes: self.pytype = float elif t in types.StringTypes: self.pytype = str els...
global logger, max_bytes, xmlparser, dbobj, xmlparser, lwtparser, rls
global logger, max_bytes, xmlparser, lwtparser, dbobj, rls global dmt_proc_dict, dmt_seg_def_dict
def initialize(configuration,log): # define the global variables used by the server global logger, max_bytes, xmlparser, dbobj, xmlparser, lwtparser, rls # initialize the logger logger = log logger.info("Initializing server module %s" % __name__ ) # initialize the database hash table dbobj = ldbd.LIGOMetadataDatabase...
global logger, max_bytes, xmlparser, dbobj, xmlparser, lwtparser, rls
global logger, max_bytes, xmlparser, lwtparser, dbobj, rls global dmt_proc_dict, dmt_seg_def_dict
def shutdown(): global logger, max_bytes, xmlparser, dbobj, xmlparser, lwtparser, rls logger.info("Shutting down server module %s" % __name__ ) if rls: del rls del lwtparser del xmlparser del dbobj del dmt_proc_dict del dmt_seg_def_dict
global logger, max_bytes
global logger global max_bytes
def handle(self): """ This method does all the work of servicing a request to the server. See the documentation for the standard module SocketServer.
for b in other: self.split(b[0])
for seg in other: if bool(seg): self.split(seg[0])
def __isub__(self, other): """ Replace the segmentlist with the difference between itself and another. """ for b in other: self.split(b[0]) try: i = 0 for b in other: while self[i][1] <= b[0]: i += 1 while self[i] in b: self[i:i+1] = [] while self[i][0] < b[1]: self[i] -= b i += 1 except IndexError: pass return self
for b in other: while self[i][1] <= b[0]: i += 1 while self[i] in b: self[i:i+1] = [] while self[i][0] < b[1]: self[i] -= b i += 1
for seg in other: if bool(seg): while self[i][1] <= seg[0]: i += 1 while self[i] in seg: self[i:i+1] = [] while self[i][0] < seg[1]: self[i] -= seg i += 1
def __isub__(self, other): """ Replace the segmentlist with the difference between itself and another. """ for b in other: self.split(b[0]) try: i = 0 for b in other: while self[i][1] <= b[0]: i += 1 while self[i] in b: self[i:i+1] = [] while self[i][0] < b[1]: self[i] -= b i += 1 except IndexError: pass return self
version_tag = " (%s)" % tag[1]
version_tag = " (%s)" % tag[1:]
def getZopeVersion(self): """See zope.app.applicationcontrol.interfaces.IZopeVersion""" if self.result is not None: return self.result
lines = header(name, 'varchar', 'integer')
lines = header(name, ['varchar'], 'integer')
def pgsql_delete(name, tables, key): lines = header(name, 'varchar', 'integer') lines.append('begin') for table in tables: line = "delete from %s where %s = $1 ;" % (table, key) lines.append(line) lines.append('return 0 ;') lines.append('end ;') lines.append("' language 'plpgsql';") return '\n'.join(lines) + '\n'
clause = "name like 'hwaddr_%' and value='%s'" % machine
clause = "name like 'hwaddr_%'" + " and value='%s'" % machine
def approve_machine_ids(self): machine = self.current.machine table = 'current_environment' clause = "name like 'hwaddr_%' and value='%s'" % machine fields = ["'machines' as section", 'name as option', 'value'] rows = self.cursor.select(fields=fields, table=table, clause=clause) for row in rows: self.cursor.insert(tabl...
sline = ['deb', '%s/updates' %source.uri, '%s/updates' % suite, 'main contrib non-free']
sline = ['deb', source.uri, '%s/updates' % suite, 'main contrib non-free']
def make_sources_list(cfg, target, suite): section = 'debrepos' aptdir = os.path.join(target, 'etc', 'apt') makepaths(aptdir) sources_list = file(os.path.join(aptdir, 'sources.list'), 'w') source = RepositorySource() source.uri = cfg.get('installer', 'http_mirror') source.suite = suite source.set_path() sources_list.wr...
if cfg.has_option(section, loption) and cfg[loption] == 'true':
if cfg.has_option(section, loption) and cfg.get(section, loption) == 'true':
def make_sources_list(cfg, target, suite): section = 'debrepos' aptdir = os.path.join(target, 'etc', 'apt') makepaths(aptdir) sources_list = file(os.path.join(aptdir, 'sources.list'), 'w') source = RepositorySource() source.uri = cfg.get('installer', 'http_mirror') source.suite = suite source.set_path() sources_list.wr...
if cfg.has_option(section, coption) and cfg[coption] == 'true':
if cfg.has_option(section, coption) and cfg.get(section, coption) == 'true':
def make_sources_list(cfg, target, suite): section = 'debrepos' aptdir = os.path.join(target, 'etc', 'apt') makepaths(aptdir) sources_list = file(os.path.join(aptdir, 'sources.list'), 'w') source = RepositorySource() source.uri = cfg.get('installer', 'http_mirror') source.suite = suite source.set_path() sources_list.wr...
runlog('echo mounting target %s to %s ' % (pdev, self.target)
runlog('echo mounting target %s to %s ' % (pdev, self.target))
def ready_target(self): self._check_target() makepaths(self.target) device = self.machine.array_hack(self.machine.current.machine_type) clause = Eq('filesystem', self.machine.current.filesystem) clause &= Gt('partition', '0') table = 'filesystem_mounts natural join mounts' mounts = self.cursor.select(table=table, claus...
os.spawnlpe(os.P_NOWAIT, '/home/umeboshi/bin/paella-kde-management',
os.spawnlpe(os.P_NOWAIT, 'paella-kde-management',
def run_tbar(self, button=None, data=None): if data == 'profiles': self.workspace[data] = ProfileGenWin(self.conn, self.dbname) elif data == 'machines': self.workspace[data] = MainMachineWin(self.conn) elif data == 'traits': self.workspace[data] = TraitManagerWin(self.conn) elif data == 'families': self.workspace[data]...
yes = 'bash -c "yes | %s' % cmd
yes = 'bash -c "yes | %s"' % cmd
def create_raid_partition(devices, pnum, mdnum, raidlevel=1): opts = '--create /dev/md%d' % mdnum opts = '%s --force -l%d -n%d' % (opts, raidlevel, len(devices)) devices = ['%s%d' % (device, pnum) for device in devices] cmd = 'mdadm %s %s' % (opts, ' '.join(devices)) yes = 'bash -c "yes | %s' % cmd return runlog(yes)
while size: experience, status, level, _class, charname = unpack(LD_INFO, data.read(szLD_INFO))
while size > 0: try: experience, status, level, _class, charname = unpack(LD_INFO, data.read(szLD_INFO)) except: size = size - szLD_INFO continue
def get_ladder(file): try: size = stat(file)[6] data = open(file, "rb") except: print "Error opening %s for read" % file exit() maxtype, checksum = unpack(LD_HEAD, data.read(szLD_HEAD)) size = size - szLD_HEAD head = [] for i in range(maxtype): type, offset, number = unpack(LD_INDEX, data.read(szLD_INDEX)) size = s...
output.write(templates[mode]['entry'] % (charname, ch['level'], ch['class'], ch['experience']))
output.write(templates[mode]['entry'] % (count, charname, ch['level'], ch['class'], ch['experience']))
def generate(ladder, mode, output, max): output.write(templates[mode]['header']) for _type in ladder.keys(): count = 1 output.write(templates[mode]['summary'] % desc[_type]) output.write(templates[mode]['tbheader']) for ch in ladder[_type]: if ch['prefix']: charname = "%s %s" % (ch['prefix'], ch['charname']) else: c...
def create_stopwords_dict(filename=cfg_path_to_stopwords_file):
def create_stopwords(filename=cfg_path_to_stopwords_file):
def create_stopwords_dict(filename=cfg_path_to_stopwords_file): """Create stopword dictionary out of FILENAME.""" try: filename = open(filename, 'r') except: return {} lines = filename.readlines() filename.close() stopdict = {} for line in lines: stopdict[string.rstrip(line)] = 1 return stopdict
stopwords = get_stopwords()
stopwords = create_stopwords()
def create_stopwords_dict(filename=cfg_path_to_stopwords_file): """Create stopword dictionary out of FILENAME.""" try: filename = open(filename, 'r') except: return {} lines = filename.readlines() filename.close() stopdict = {} for line in lines: stopdict[string.rstrip(line)] = 1 return stopdict
def account_list_alerts(uid, action="", id_alert=0, id_basket=0,old_id_basket=0,newname=""):
def account_list_alerts(uid, action="", id_alert=0,id_basket=0,old_id_basket=0,newname="",value=""):
def account_list_alerts(uid, action="", id_alert=0, id_basket=0,old_id_basket=0,newname=""): i=0 # set variables out = "" options = "" id_user = uid # XXX list=[] SQL_query = """ SELECT q.id, q.urlargs, a.id_user, a.id_query, a.id_basket, a.alert_name, a.frequency, a.notification, DATE_FORMAT(a.date_creation,'%%d %%b %...
out = "" options = ""
def account_list_alerts(uid, action="", id_alert=0, id_basket=0,old_id_basket=0,newname=""): i=0 # set variables out = "" options = "" id_user = uid # XXX list=[] SQL_query = """ SELECT q.id, q.urlargs, a.id_user, a.id_query, a.id_basket, a.alert_name, a.frequency, a.notification, DATE_FORMAT(a.date_creation,'%%d %%b %...
list=[]
out = ""
def account_list_alerts(uid, action="", id_alert=0, id_basket=0,old_id_basket=0,newname=""): i=0 # set variables out = "" options = "" id_user = uid # XXX list=[] SQL_query = """ SELECT q.id, q.urlargs, a.id_user, a.id_query, a.id_basket, a.alert_name, a.frequency, a.notification, DATE_FORMAT(a.date_creation,'%%d %%b %...
query_result = run_sql(SQL_query) if len(query_result) > 0: for row in query_result : i+=1 list += ["""<A href="../youralerts.py/modify?idq=%d&name=%s&freq=%s&notif=%s&idb=%d&old_idb=%d">%s</A> """%(row[0],row[5],row[6],row[7],id_basket,old_id_basket,row[5])] options += """<OPTION value=%d>%s</OPTION>""" % (i,row[5])
query_result = run_sql(SQL_query) out += """<FORM name="displayalert" action="../youralerts.py/list" method="post">"""
def account_list_alerts(uid, action="", id_alert=0, id_basket=0,old_id_basket=0,newname=""): i=0 # set variables out = "" options = "" id_user = uid # XXX list=[] SQL_query = """ SELECT q.id, q.urlargs, a.id_user, a.id_query, a.id_basket, a.alert_name, a.frequency, a.notification, DATE_FORMAT(a.date_creation,'%%d %%b %...
for l in range(0,i): out +="" out+=list[l] if isGuestUser(uid) : out += warning_guest_user(type="alerts") return out
out += """<SELECT name="id_alert"><OPTION value="0">- alert name -</OPTION>""" for row in query_result : if len(query_result)>0: alert_selected = " selected" alert_name = row[0] else: alert_selected = "" out += """<OPTION>%s</OPTION>""" % (row[5]) out += """</SELECT>\n""" out += """&nbsp;<CODE class="blocknote">"""\ ""...
def account_list_alerts(uid, action="", id_alert=0, id_basket=0,old_id_basket=0,newname=""): i=0 # set variables out = "" options = "" id_user = uid # XXX list=[] SQL_query = """ SELECT q.id, q.urlargs, a.id_user, a.id_query, a.id_basket, a.alert_name, a.frequency, a.notification, DATE_FORMAT(a.date_creation,'%%d %%b %...
sql = 'insert into %s (session_key, session_object, uid) values ("%s","%s",%s)'\ % (self.__class__.__tableName, self.id, repr, int(self.getUid()))
sql = 'INSERT INTO %s (session_key, session_expiry, session_object, uid) values ("%s","%s","%s","%s")' % \ (self.__class__.__tableName, self.id, self.get_access_time()+60*60*24*2, repr, int(self.getUid()))
def save( self ): """method that tries to insert the session as NEW in the DB. If this fails (giving an integrity error) it means the session already exists there and it must be updated, so it performs the corresponding SQL update """ repr = self.__getRepr().replace("'", "\\\'") repr = repr.replace('"', '\\\"') try: s...
sql = 'update %s set uid=%s, session_object="%s" where session_key="%s"'%(self.__class__.__tableName, int(self.getUid()), repr, self.id)
sql = 'UPDATE %s SET uid=%s, session_expiry=%s, session_object="%s" WHERE session_key="%s"' % \ (self.__class__.__tableName, int(self.getUid()), self.get_access_time()+60*60*24*2, repr, self.id)
def save( self ): """method that tries to insert the session as NEW in the DB. If this fails (giving an integrity error) it means the session already exists there and it must be updated, so it performs the corresponding SQL update """ repr = self.__getRepr().replace("'", "\\\'") repr = repr.replace('"', '\\\"') try: s...
def _set_access_time (self, resolution): now = time.time() if now - self._Session__access_time > resolution: self._Session__access_time = now run_sql("UPDATE session SET session_expiry=%d WHERE session_key='%s'" % (now+60*60*24*2, self.id))
def save( self ): """method that tries to insert the session as NEW in the DB. If this fails (giving an integrity error) it means the session already exists there and it must be updated, so it performs the corresponding SQL update """ repr = self.__getRepr().replace("'", "\\\'") repr = repr.replace('"', '\\\"') try: s...
apache_password_line_for_user = os.popen("grep %s %s" % (user,cfg_apache_password_file), 'r').read() password_apache = string.split(string.strip(apache_password_line_for_user),":")[1]
pipe_input, pipe_output = os.popen2(["/bin/grep", "^" + user + ":", cfg_apache_password_file], 'r') line = pipe_output.readlines()[0] password_apache = string.split(string.strip(line),":")[1]
def auth_apache_user_p(user, password): """Check whether user-supplied credentials correspond to valid Apache password data file. Return 0 in case of failure, 1 in case of success.""" try: apache_password_line_for_user = os.popen("grep %s %s" % (user,cfg_apache_password_file), 'r').read() password_apache = string.spli...
if 1==1:
name = "name" if table == "rnkMETHOD": name = "NAME" try:
def get_current_name(ID, ln, rtype, table): """Returns a list of the names, either with the name in the current language, the default language, or just the name from the given table ln - a language supported by cdsware type - the type of value wanted, like 'ln', 'sn'""" #try: if 1==1: res = "" if ID: res = run_sql("SE...
res = run_sql("SELECT id_%s,value FROM %sname where type='%s' and ln='%s' and id_%s=%s" % (table, table, rtype,ln, table, ID))
res = run_sql("SELECT id_%s,value FROM %s%s where type='%s' and ln='%s' and id_%s=%s" % (table, table, name, rtype,ln, table, ID))
def get_current_name(ID, ln, rtype, table): """Returns a list of the names, either with the name in the current language, the default language, or just the name from the given table ln - a language supported by cdsware type - the type of value wanted, like 'ln', 'sn'""" #try: if 1==1: res = "" if ID: res = run_sql("SE...
res = run_sql("SELECT id_%s,value FROM %sname where type='%s' and ln='%s'" % (table, table, rtype,ln))
res = run_sql("SELECT id_%s,value FROM %s%s where type='%s' and ln='%s'" % (table, table, name, rtype,ln))
def get_current_name(ID, ln, rtype, table): """Returns a list of the names, either with the name in the current language, the default language, or just the name from the given table ln - a language supported by cdsware type - the type of value wanted, like 'ln', 'sn'""" #try: if 1==1: res = "" if ID: res = run_sql("SE...