rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
os.rmdir(menu) | shutil.rmtree(menu) | def clean_menu(): """Function removing unused menu entries, usually called at the end""" all_menus = [] for y in range(db.__len__()): if not all_menus.__contains__(db[y][2]): all_menus.append(db[y][2]) # This will "save" submenus entries for x in range(menus_used.__len__()): # Preserve menu if only submenu inside for s... |
shutil.copyfile(MENUSRC, MENUDIR) | shutil.copytree(MENUSRC, MENUDIR) | def copy_menu_struct(): try: shutil.copyfile(MENUSRC, MENUDIR) except: sys.stderr.write("Unable to copy menu structure to" + MENUDIR) sys.stderr.write("Verify that you have right permissions") return -1 |
shutil.copyfile(file, ICONDIR) | shutil.copyfile(file, ICONDIR + eapfile) | def make_menu_entry(eapfile="" , category="" ): file = os.path.join(EAPDIR, eapfile) if os.path.exists(file): # Check if dry-run if options.simulate: print arrow + "Copying " + eapfile + " to " + ICONDIR if not menus_used.__contains__(category): menus_used.append(category) if not os.path.exists(os.path.join(MENUDIR, "a... |
menuorder = open(os.path.join(MENUDIR, "all", category, ".order"), "w") | menuorder = open(os.path.join(MENUDIR, category, ".order"), "w") | def make_menu_entry(eapfile="" , category="" ): file = os.path.join(EAPDIR, eapfile) if os.path.exists(file): # Check if dry-run if options.simulate: print arrow + "Copying " + eapfile + " to " + ICONDIR if not menus_used.__contains__(category): menus_used.append(category) if not os.path.exists(os.path.join(MENUDIR, "a... |
if self._install_profile.get_install_stage() == 3 and self._install_profile.get_dynamic_stage3(): | def unpack_stage_tarball(self): if not os.path.isdir(self._chroot_dir): if self._debug: self._logger.log("DEBUG: making the chroot dir:"+self._chroot_dir) os.makedirs(self._chroot_dir) if self._install_profile.get_install_stage() == 3 and self._install_profile.get_dynamic_stage3(): # stage3 generation code here dircd= ... | |
GLIUtility.spawn("mv " + self._chroot_dir + " " + "/etc/init.d/halt.sh.orig" + self._chroot_dir + "/etc/init.d/halt.sh") GLIUtility.spawn("mv " + self._chroot_dir + " " + "/etc/init.d/fstab.orig" + self._chroot_dir + "/etc/init.d/fstab") | GLIUtility.spawn("mv " + "/etc/init.d/halt.sh.orig" + self._chroot_dir + "/etc/init.d/halt.sh") GLIUtility.spawn("mv " + "/etc/init.d/fstab.orig" + self._chroot_dir + "/etc/init.d/fstab") | def unpack_stage_tarball(self): if not os.path.isdir(self._chroot_dir): if self._debug: self._logger.log("DEBUG: making the chroot dir:"+self._chroot_dir) os.makedirs(self._chroot_dir) if self._install_profile.get_install_stage() == 3 and self._install_profile.get_dynamic_stage3(): # stage3 generation code here dircd= ... |
cur.execute(sqlcmd % (taskid, linenum, cmdid, today)) | cur.execute(sqlcmd % (taskid, today)) | def insertTask(self, taskid): """inserts a task into the right tables, returns resultant rownumber for use in other tables""" sqlcmd = """insert into tasks (taskid, date) values ('%s','%s');""" #print >>sys.stderr, sqlcmd import time #today = "%04d%02d%02d" % time.localtime()[:3] # date in yyyy-mm-dd hh:mm format today... |
def cmdWithInput(self, concretename): | def cmdsWithInput(self, concretename): | def cmdWithInput(self, concretename): """Return a list of cmdids that have inputid as one of their input""" cur = self.cursor() # first find the affected commands cur.execute("""select (taskrow,linenum) from cmdFileRelation where (output=0, concretename='%s'""" % (concretename)) rows = cur.fetchall() ## FIXME: still ne... |
cur.execute("""select (taskrow,linenum) from cmdFileRelation where (output=0, concretename='%s'""" % (concretename)) | cur.execute("""select taskrow,linenum from cmdFileRelation where output=0 AND concretename='%s';""" % (concretename)) | def cmdWithInput(self, concretename): """Return a list of cmdids that have inputid as one of their input""" cur = self.cursor() # first find the affected commands cur.execute("""select (taskrow,linenum) from cmdFileRelation where (output=0, concretename='%s'""" % (concretename)) rows = cur.fetchall() ## FIXME: still ne... |
return None | return rows | def cmdWithInput(self, concretename): """Return a list of cmdids that have inputid as one of their input""" cur = self.cursor() # first find the affected commands cur.execute("""select (taskrow,linenum) from cmdFileRelation where (output=0, concretename='%s'""" % (concretename)) rows = cur.fetchall() ## FIXME: still ne... |
where (taskrow=%d, linenum=%d)""" | where taskrow=%d AND linenum=%d;""" cur = self.cursor() for (taskrow, linenum) in cmdList: cur.execute(getfiles % (taskrow, linenum)) ready = True f = cur.fetchall() for t in f: print t print """ """ | def makeReady(self, cmdList): # for each cmd in the list, check the filestates of its input files getfiles = """select * from cmdFileRelation INNER JOIN fileState where (taskrow=%d, linenum=%d)""" |
cur.execute("select * from tasks;") | cur.execute("select taskid,rowid,date from tasks;") | def showState(self): cur = self.cursor() # look for tasks cur.execute("select * from tasks;") ttable = cur.fetchall() taskdict = {} if ttable == []: print "No Tasks in DB" else: for row in ttable: taskid = row[0] if taskid not in taskdict: taskdict[taskid] = (1, row[3]) else: entry = taskdict[taskid] taskdict[taskid] =... |
taskdict[taskid] = (1, row[3]) | taskdict[taskid] = row[1:] | def showState(self): cur = self.cursor() # look for tasks cur.execute("select * from tasks;") ttable = cur.fetchall() taskdict = {} if ttable == []: print "No Tasks in DB" else: for row in ttable: taskid = row[0] if taskid not in taskdict: taskdict[taskid] = (1, row[3]) else: entry = taskdict[taskid] taskdict[taskid] =... |
entry = taskdict[taskid] taskdict[taskid] = (entry[0] + 1, entry[1]) | print "warning, duplicate task in tasks table, id=", print taskid, " Ignoring..." | def showState(self): cur = self.cursor() # look for tasks cur.execute("select * from tasks;") ttable = cur.fetchall() taskdict = {} if ttable == []: print "No Tasks in DB" else: for row in ttable: taskid = row[0] if taskid not in taskdict: taskdict[taskid] = (1, row[3]) else: entry = taskdict[taskid] taskdict[taskid] =... |
print "TaskId:", tid, "has", entry[0], "lines, dated", | print "TaskId:", tid, "is dated", | def showState(self): cur = self.cursor() # look for tasks cur.execute("select * from tasks;") ttable = cur.fetchall() taskdict = {} if ttable == []: print "No Tasks in DB" else: for row in ttable: taskid = row[0] if taskid not in taskdict: taskdict[taskid] = (1, row[3]) else: entry = taskdict[taskid] taskdict[taskid] =... |
self.showTask(tid) | self.showTaskCommandsByRow(entry[0]) | def showState(self): cur = self.cursor() # look for tasks cur.execute("select * from tasks;") ttable = cur.fetchall() taskdict = {} if ttable == []: print "No Tasks in DB" else: for row in ttable: taskid = row[0] if taskid not in taskdict: taskdict[taskid] = (1, row[3]) else: entry = taskdict[taskid] taskdict[taskid] =... |
def showTask(self, tid): cur = self.cursor() cmd = 'select cmdid from tasktable where taskid="%s"' % (tid) | def showTaskCommandsByRow(self, taskrow): cur = self.cursor() cmd = 'select * from cmds where taskrow="%s"' % (taskrow) | def showTask(self, tid): cur = self.cursor() cmd = 'select cmdid from tasktable where taskid="%s"' % (tid) cur.execute(cmd) for cidtuple in cur.fetchall(): self.showCmd(cidtuple[0]) pass |
self.showCmd(cidtuple[0]) pass | self.showCmdTuple(cidtuple) pass def showCmdTuple(self, tuple): """Pretty-prints a row from the cmds table""" cmdtemplate = "row %d, line %d, cmd %s, cmdline= %s" print cmdtemplate % tuple pass | def showTask(self, tid): cur = self.cursor() cmd = 'select cmdid from tasktable where taskid="%s"' % (tid) cur.execute(cmd) for cidtuple in cur.fetchall(): self.showCmd(cidtuple[0]) pass |
LEFT JOIN fileState USING (concretename) | JOIN fileState USING (concretename) | def makeReady(self, cmdList): """input: cmdList is a list of tuples (taskrow,linenum) for each tuple, check to see if it has any unready input files if there are no unready input files, add job to the ready list |
if t[1] != 2: | if t[1] != 3: | def makeReady(self, cmdList): """input: cmdList is a list of tuples (taskrow,linenum) for each tuple, check to see if it has any unready input files if there are no unready input files, add job to the ready list |
def initMakeReady(self, taskrow): """Find all ready jobs and put them on the readylist Warning: logic duplication between this and makeReady. Refactoring these two is a priority. """ sql = """select linenum,output,concretename,state from cmds LEFT JOIN cmdFileRelation USING (taskrow,linenum) LEFT JOIN fileState USING (... | def makeReady(self, cmdList): """input: cmdList is a list of tuples (taskrow,linenum) for each tuple, check to see if it has any unready input files if there are no unready input files, add job to the ready list | |
j.insertInout(row, 10, "%tempf_other.nc%", "/tmp/temp1111tempf_other.nc", | j.insertInout(row, 10, "in.nc", "in.nc", False, 1, False) j.insertInout(row, 10, "%tempf_other.nc%", "/tmp/temp0000tempf_other.nc", | def selfTest(): print "doing basic internal build/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" row = j.insertTask("AABBCCDD") j.insertCmd(row, 10, "ncwa", "ncwa in.nc %tempf_other.nc% %outf_out.nc%") j.insertInout(row, 10, "%tempf_other.nc%", "/tmp/temp... |
clist = j.cmdsWithInput("/tmp/temp1111tempf_other.nc") j.makeReady(clist) | j.initMakeReady(row) | def selfTest(): print "doing basic internal build/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" row = j.insertTask("AABBCCDD") j.insertCmd(row, 10, "ncwa", "ncwa in.nc %tempf_other.nc% %outf_out.nc%") j.insertInout(row, 10, "%tempf_other.nc%", "/tmp/temp... |
parserShortOpt = "4AaBb:CcD:d:FfHhl:Mmn:Oo:Pp:QqRrs:S:s:t:uv:w:xY:y:" | parserShortOpt = "4Aa:Bb:CcD:d:FfHhl:Mmn:Oo:Pp:QqRrs:S:s:t:uv:w:xY:y:" | def readConfigFile(): # can add other mappings from config file to local settings" cfgmap = [("serverBase", "ssd-server", "url")] try: import ConfigParser config = ConfigParser.ConfigParser() filename = "ssdwrap.conf" # look in the same place as the script is located... # should I check current working directory inste... |
"abc", "alphabetize", "bnr", "binary", | "attribute=", "avg=", "average=" "bnr", "binary", | def readConfigFile(): # can add other mappings from config file to local settings" cfgmap = [("serverBase", "ssd-server", "url")] try: import ConfigParser config = ConfigParser.ConfigParser() filename = "ssdwrap.conf" # look in the same place as the script is located... # should I check current working directory inste... |
ncpdqShortOpt = parserShortOpt.replace("a","a:") ncpdqShortOpt = ncpdqShortOpt.replace("M","M:") ncpdqShortOpt = ncpdqShortOpt.replace("P","P:") ncpdqShortOpt = ncpdqShortOpt.replace("u","Uu") | ncpackShortOpt = parserShortOpt.replace("M","M:") ncpackShortOpt = ncpackShortOpt.replace("P","P:") ncpackShortOpt = ncpackShortOpt.replace("u","Uu") | def readConfigFile(): # can add other mappings from config file to local settings" cfgmap = [("serverBase", "ssd-server", "url")] try: import ConfigParser config = ConfigParser.ConfigParser() filename = "ssdwrap.conf" # look in the same place as the script is located... # should I check current working directory inste... |
ncpdqLongOpt = parserLongOpt[:] ncpdqLongOpt.extend(['arrange','permute','reorder', 'rdr', | ncpackLongOpt = parserLongOpt[:] ncpackLongOpt.extend(['arrange','permute','reorder', 'rdr', | def readConfigFile(): # can add other mappings from config file to local settings" cfgmap = [("serverBase", "ssd-server", "url")] try: import ConfigParser config = ConfigParser.ConfigParser() filename = "ssdwrap.conf" # look in the same place as the script is located... # should I check current working directory inste... |
elif cmd == "ncpdq": | elif cmd in ["ncpdq", "ncpack", "ncunpack"]: | def specialGetOpt(cmd, argvlist): #consider special-case for ncwa ncflint -w: option # wgt_var, weight also for ncflint/ncwa if cmd == "ncap": # ncap has a different format return getopt.getopt(argvlist, SsdapCommon.ncapShortOpt, SsdapCommon.ncapLongOpt) elif cmd == "ncpdq": # ncpdq has a different format too return ge... |
SsdapCommon.ncpdqShortOpt, SsdapCommon.ncpdqLongOpt) | SsdapCommon.ncpackShortOpt, SsdapCommon.ncpackLongOpt) elif cmd == "ncks": return getopt.getopt(argvlist, SsdapCommon.ncksShortOpt, SsdapCommon.ncksLongOpt) | def specialGetOpt(cmd, argvlist): #consider special-case for ncwa ncflint -w: option # wgt_var, weight also for ncflint/ncwa if cmd == "ncap": # ncap has a different format return getopt.getopt(argvlist, SsdapCommon.ncapShortOpt, SsdapCommon.ncapLongOpt) elif cmd == "ncpdq": # ncpdq has a different format too return ge... |
parserShortOpt = "4AaBb:CcD:d:FfHhl:Mmn:Oo:Pp:QqRrs:S:s:t:uv:xY:y:" | parserShortOpt = "4AaBb:CcD:d:FfHhl:Mmn:Oo:Pp:QqRrs:S:s:t:uv:w:xY:y:" | def readConfigFile(): # can add other mappings from config file to local settings" cfgmap = [("serverBase", "ssd-server", "url")] try: import ConfigParser config = ConfigParser.ConfigParser() filename = "ssdwrap.conf" # look in the same place as the script is located... # should I check current working directory inste... |
"variable=", "op_typ=", "operation=" ] | "variable=", "wgt_var=", "weight=", "op_typ=", "operation=" ] | def readConfigFile(): # can add other mappings from config file to local settings" cfgmap = [("serverBase", "ssd-server", "url")] try: import ConfigParser config = ConfigParser.ConfigParser() filename = "ssdwrap.conf" # look in the same place as the script is located... # should I check current working directory inste... |
s | def dispatchScript(self): """sends the script to be executed""" (path, name) = os.path.split(self.targetFile) url = self.serverBase + "/" + name url += ".dods?" + self.MAGIC_CONSTRAINT print "url is " + url s try: result = urllib.urlopen(url, self.scriptData) # request from server if self.targetFile != self.MAGIC_DUMMY... | |
cur = self.cursor() template = "update filestate set state=%d where concretename=\'%s\'" cur.execute(template % (state,concretename)) | template = "BEGIN EXCLUSIVE; UPDATE filestate set state=%d where concretename=\'%s\' ; COMMIT;" con = self.connection() oldIsolate = con.isolation_level con.isolation_level = None cur = con.cursor() deferred = None try: cur.executescript(template % (state,concretename)) except Exception, e: deferred = e con.isolation_l... | def setFileStateByName(self, concretename, state): """retries until successful.""" cur = self.cursor() template = "update filestate set state=%d where concretename=\'%s\'" cur.execute(template % (state,concretename)) |
def showReadyList(self): | def showReadyList(self, taskrow=None): | def showReadyList(self): sql = "select * from readyList JOIN cmds USING (taskrow,linenum) LIMIT 200;" cur = self.cursor() cur.execute(sql) for r in cur.fetchall(): print "ready cmd: task=%d line=%d, out=%s, cmd=%s, cmdline=%s" % ( r[0], r[1], r[2], r[3], r[4]) |
cur = self.cursor() cur.execute(sql) | sqltemp = "select * from readyList JOIN cmds USING (taskrow,linenum) where taskrow=%d LIMIT 200;" cur = self.cursor() if taskrow is not None: cur.execute(sqltemp % taskrow) else: cur.execute(sql) | def showReadyList(self): sql = "select * from readyList JOIN cmds USING (taskrow,linenum) LIMIT 200;" cur = self.cursor() cur.execute(sql) for r in cur.fetchall(): print "ready cmd: task=%d line=%d, out=%s, cmd=%s, cmdline=%s" % ( r[0], r[1], r[2], r[3], r[4]) |
parserShortOpt = "4AaBb:CcD:d:FfHhl:Mmn:Oo:Pp:QqRrs:S:s:t:uv:xy:" | parserShortOpt = "4AaBb:CcD:d:FfHhl:Mmn:Oo:Pp:QqRrs:S:s:t:uv:xY:y:" | def readConfigFile(): # can add other mappings from config file to local settings" cfgmap = [("serverBase", "ssd-server", "url")] try: import ConfigParser config = ConfigParser.ConfigParser() filename = "ssdwrap.conf" # look in the same place as the script is located... # should I check current working directory inste... |
assert len(rows) is 1 | assert len(rows) == 1 | def markStart(self, readyTuple): """helper for the case where a new ready job exists.""" (taskrow, linenum, concretename) = readyTuple fetch = "SELECT cmdLine FROM cmds WHERE taskrow=? AND linenum=?;" update = "UPDATE fileState SET state=2 WHERE concretename=?;" self.cursor.execute(fetch, (taskrow, linenum)) rows = sel... |
curcount = None if len(rows) is 0: if count is 1: | if len(rows) == 0: if count == 1: | def updateDeleteTracker(self, inputlist): """inputlist is a list of tuples of (concretename, usagecount) where usagecount is the number of times this file is consumed during the dataflow """ fetch = "SELECT count FROM useList WHERE concretename=?;" deleteList = [] updateList = [] setList = [] for (concretename, count) ... |
assert len(rows) is 1 if rows[0][0] is (count-1): | assert len(rows) == 1 curcount = int(rows[0][0]) + 1 if curcount == count: print >>open("/tmp/foo1","a"), "ok to del",concretename | def updateDeleteTracker(self, inputlist): """inputlist is a list of tuples of (concretename, usagecount) where usagecount is the number of times this file is consumed during the dataflow """ fetch = "SELECT count FROM useList WHERE concretename=?;" deleteList = [] updateList = [] setList = [] for (concretename, count) ... |
else: updateList.append((rows[0][0]+1, concretename)) | else: updateList.append((curcount, concretename)) | def updateDeleteTracker(self, inputlist): """inputlist is a list of tuples of (concretename, usagecount) where usagecount is the number of times this file is consumed during the dataflow """ fetch = "SELECT count FROM useList WHERE concretename=?;" deleteList = [] updateList = [] setList = [] for (concretename, count) ... |
if type(tup) is tuple and len(tup) is 3: | if type(tup) == tuple and len(tup) == 3: | def selfTest(args=[]): buildOnly = False if len(args) > 0: if "build" in args: buildOnly = True print "doing basic internal build/fill/run/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" inputdict = selfPopulateAndPrep(j) # clist = j.cmdsWithInput("/tmp... |
useList = ["CREATE TABLE useList ( concretename VARCHAR(192),", | useList = ["CREATE TABLE useList (", " concretename VARCHAR(192),", | def buildTables(self): """Builds the set of tables needed for async operation""" ## ## consider having a table to store the actual script ## this would help for debugging and output caching ## taskcommand = ["CREATE TABLE tasks (", " taskid VARCHAR(8),", " date DATE", ");"] cmdcommand = ["CREATE TABLE cmds (", " tas... |
"xcl", "exclude" | "xcl", "exclude", | def readConfigFile(): # can add other mappings from config file to local settings" cfgmap = [("serverBase", "ssd-server", "url")] try: import ConfigParser config = ConfigParser.ConfigParser() filename = "ssdwrap.conf" # look in the same place as the script is located... # should I check current working directory inste... |
shortopts = SsdapCommon.parserShortOpt longopts = SsdapCommon.parserLongOpt (arglist, leftover) = getopt.getopt(argvlist[1:],shortopts, longopts) | (arglist, leftover) = SsdapCommon.specialGetOpt(self.cmd, argvlist[1:]) | def build(self, argvlist): """look for output filename, replace with magic key for remote""" # pull of cmd first. if argvlist[0] not in local.acceptableNcCommands: raise "Bad NCO command" self.cmd = argvlist[0] |
if (len(v) > 0) and \ v[0] not in (string.letters + string.digits + "%"): line += " " + k + "='" + v + "'" else: line += " " + k + " " + v | needsProt = False safe = string.letters + string.digits + "%" for x in v: needsProt |= (x not in safe) if needsProt: line += " " + k + " '" + v + "'" elif len(v) > 0: line += " " + k + " " + v else: line += " " + k | def rebuildCommandline(self, argdict, infilename): line = self.cmd for (k,v) in argdict.items(): #special value handling for --op_typ='-' if (len(v) > 0) and \ v[0] not in (string.letters + string.digits + "%"): line += " " + k + "='" + v + "'" else: line += " " + k + " " + v line += ''.join([" " + name for name in inf... |
self.dbcursor.close() | if self.dbcursor is not None: self.dbcursor.close() | def close(self): """force closing the db and releasing of db handles""" if self.connected: self.dbconnection.commit() self.dbcursor.close() self.dbconnection.close() self.connected = False self.dbcursor = None self.dbconnection = None |
cmd = """SELECT readyList.rowid,concretename,cmdLine | cmd = """SELECT taskrow,linenum,concretename,cmdLine | def fetchAndLockNextCmd(self,taskrow): # fetch a cmd from ready list cmd = """SELECT readyList.rowid,concretename,cmdLine FROM readyList JOIN cmds USING (taskrow,linenum) WHERE taskrow=%d LIMIT 1;""" cur = self.cursor() cur.execute(cmd % taskrow) rows = cur.fetchall() if len(rows) < 1: return None mycommand = rows[0] #... |
USING (taskrow,linenum) WHERE taskrow=%d LIMIT 1;""" cur = self.cursor() cur.execute(cmd % taskrow) rows = cur.fetchall() if len(rows) < 1: return None mycommand = rows[0] cmd = """delete from readyList where rowid=%d;""" cur.execute(cmd % mycommand[0]) cmd = "update fileState set state=2 where concretename='%s';" c... | USING (taskrow,linenum) WHERE taskrow=%d;""" rows = None for i in range(3): try: self.close() con = self.connection() oldLevel = con.isolation_level con.isolation_level = "EXCLUSIVE" cur = con.cursor() cur.execute(cmd % taskrow) rows = cur.fetchall() result = None break except: import time time.sleep(0.2) continue ... | def fetchAndLockNextCmd(self,taskrow): # fetch a cmd from ready list cmd = """SELECT readyList.rowid,concretename,cmdLine FROM readyList JOIN cmds USING (taskrow,linenum) WHERE taskrow=%d LIMIT 1;""" cur = self.cursor() cur.execute(cmd % taskrow) rows = cur.fetchall() if len(rows) < 1: return None mycommand = rows[0] #... |
if argvlist[0] not in acceptableNcCommands: | if argvlist[0] not in local.acceptableNcCommands: | def build(self, argvlist): """look for output filename, replace with magic key for remote""" # pull of cmd first. if argvlist[0] not in acceptableNcCommands: raise "Bad NCO command" self.cmd = argvlist[0] |
if "--output" not in argdict: | if "-o" not in argdict: | def rebuildCommandline(self, argdict, infilename): line = self.cmd for (k,v) in argdict.items(): #special value handling for --op_typ='-' if (len(v) > 0) and \ v[0] not in (string.letters + string.digits + "%"): line += " " + k + "='" + v + "'" else: line += " " + k + " " + v line += ''.join([" " + name for name in inf... |
serverBase = serverBase | serverBase = local.serverBase | def outputFile(self): if self.specialOutput(self.outfilename): return None return self.outfilename |
print "script is " + script | def run(self): """sends off its current batch of commands off to the server to run""" script = self.buildScript() print "script is " + script self.executeBuilt(script) | |
url = serverBase + "/" + filename | url = local.serverBase + "/" + filename | def executeBuilt(self, script): """sends the script to be executed""" |
for c in acceptableNcCommands: print c, | for c in local.acceptableNcCommands: print c, | def printUsage(): print "Usage: " + sys.argv[0] + " <cmd> [cmd args...]" print "... where <cmd> is one of: ", for c in acceptableNcCommands: print c, print print "... and cmd args are the args you want for the command" print "Note that you have to have both an input and output file specified," print "unless you're usin... |
return self.execute(*pargs, **kwargs) | val = self.execute(*pargs, **kwargs) break | def executeBlocking(self, *pargs, **kwargs): """This keeps trying an operation until it succeeds. Transient DB exceptions are explicitly caught.""" while True: try: return self.execute(*pargs, **kwargs) except sqlite.OperationalError, e: # if db is locked, wait and retry. if 'database is locked' in str(e): print >>open... |
deleteList.append(concretename) | deleteList.append((concretename,)) print "marked",concretename,"for deletion" | def updateDeleteTracker(self, inputlist): fetch = "SELECT count FROM useList WHERE concretename=?;" deleteList = [] updateList = [] setList = [] for (concretename, count) in inputlist: self.cursor.execute(fetch, (concretename,)) rows = self.cursor.fetchall() curcount = None if len(rows) is 0: if count is 1: # only supp... |
os.unlink(f) | print "unlinking f", f[0] os.unlink(f[0]) | def postExecute(self): """after transaction completes, process deferred behavior. --delete queued files.""" if "deleteList" not in dir(self): return for f in self.deleteList: try: os.unlink(f) except OSError,e: # log error... FIXME before going production print >>open("/tmp/foo1","a"), os.getpid(),"error deleting", f p... |
print >>open("/tmp/foo1","a"), os.getpid(),"error deleting", f | print >>open("/tmp/foo1","a"), os.getpid(),"error deleting", f[0] | def postExecute(self): """after transaction completes, process deferred behavior. --delete queued files.""" if "deleteList" not in dir(self): return for f in self.deleteList: try: os.unlink(f) except OSError,e: # log error... FIXME before going production print >>open("/tmp/foo1","a"), os.getpid(),"error deleting", f p... |
"DROP TABLE useList;", "DROP TABLE useCount;" | "DROP TABLE useList;" | def deleteTables(self): deletecmd = [ "DROP TABLE tasks;", "DROP TABLE cmds;", "DROP TABLE cmdFileRelation;", "DROP TABLE fileState;", "DROP TABLE readyList;", "DROP TABLE useList;", "DROP TABLE useCount;" ]; # sqlite automatically drops indexes cur = self.cursor() try: cur.executescript("\n".join(deletecmd)) print >>s... |
pass | return inputdict | def selfPopulateAndPrep(jobpers): pop = jobpers.newPopulationTransaction() row = pop.insertTask("AABBCCDD") # a command with no input and one independent output (ready to go) pop.insertCmd(2, "ncap", "ncap -o %outf_indep.nc%") pop.insertInOut(2, "%outf_indep.nc%", "/tmp/temp1111outf_indep.nc", True, 1, False) # a comma... |
selfPopulateAndPrep(j) | inputdict = selfPopulateAndPrep(j) | def selfTest(args=[]): buildOnly = False if len(args) > 0: if "build" in args: buildOnly = True print "doing basic internal build/fill/run/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" selfPopulateAndPrep(j) # clist = j.cmdsWithInput("/tmp/temp1111tem... |
(cline, outname) = (None,None) | (cline, outname, linenum) = (None, None, None) | def selfTest(args=[]): buildOnly = False if len(args) > 0: if "build" in args: buildOnly = True print "doing basic internal build/fill/run/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" selfPopulateAndPrep(j) # clist = j.cmdsWithInput("/tmp/temp1111tem... |
(cline,outname) = fetch.execute() | (cline, outname, linenum) = fetch.execute() | def selfTest(args=[]): buildOnly = False if len(args) > 0: if "build" in args: buildOnly = True print "doing basic internal build/fill/run/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" selfPopulateAndPrep(j) # clist = j.cmdsWithInput("/tmp/temp1111tem... |
j.showState() | def selfTest(args=[]): buildOnly = False if len(args) > 0: if "build" in args: buildOnly = True print "doing basic internal build/fill/run/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" selfPopulateAndPrep(j) # clist = j.cmdsWithInput("/tmp/temp1111tem... | |
tup = cmtcmd.execute(outname) | tup = cmtcmd.executeBlocking(outname, inputdict[linenum]) | def selfTest(args=[]): buildOnly = False if len(args) > 0: if "build" in args: buildOnly = True print "doing basic internal build/fill/run/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" selfPopulateAndPrep(j) # clist = j.cmdsWithInput("/tmp/temp1111tem... |
if type(tup) is tuple and len(tup) == 2: (cline, outname) = tup | if type(tup) is tuple and len(tup) is 3: (cline, outname, linenum) = tup | def selfTest(args=[]): buildOnly = False if len(args) > 0: if "build" in args: buildOnly = True print "doing basic internal build/fill/run/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" selfPopulateAndPrep(j) # clist = j.cmdsWithInput("/tmp/temp1111tem... |
print "cmdList: %d,%d has %s in %s" % ( taskrow, linenum, concretename, state) | def initMakeReady(self, taskrow): """Find all ready jobs and put them on the readylist Warning: logic duplication between this and makeReady. Refactoring these two is a priority. """ sql = """select linenum,output,concretename,state from cmds LEFT JOIN cmdFileRelation USING (taskrow,linenum) LEFT JOIN fileState USING (... | |
print "Not Ready %d,%d has %s in %s" % ( taskrow, linenum, concretename, state) | def initMakeReady(self, taskrow): """Find all ready jobs and put them on the readylist Warning: logic duplication between this and makeReady. Refactoring these two is a priority. """ sql = """select linenum,output,concretename,state from cmds LEFT JOIN cmdFileRelation USING (taskrow,linenum) LEFT JOIN fileState USING (... | |
cmd = """select rowid,concretename,cmdLine from readyList JOIN cmds USING (taskrow,linenum) where taskrow=%d limit 1;""" | cmd = """SELECT readyList.rowid,concretename,cmdLine FROM readyList JOIN cmds USING (taskrow,linenum) WHERE taskrow=%d LIMIT 1;""" | def fetchAndLockNextCmd(self,taskrow): # fetch a cmd from ready list cmd = """select rowid,concretename,cmdLine from readyList JOIN cmds USING (taskrow,linenum) where taskrow=%d limit 1;""" cur = self.cursor() cur.execute(cmd % taskrow) rows = cur.fetchall() mycommand = row[0] # drop the cmd from the list cmd = """dele... |
mycommand = row[0] | if len(rows) < 1: return None mycommand = rows[0] | def fetchAndLockNextCmd(self,taskrow): # fetch a cmd from ready list cmd = """select rowid,concretename,cmdLine from readyList JOIN cmds USING (taskrow,linenum) where taskrow=%d limit 1;""" cur = self.cursor() cur.execute(cmd % taskrow) rows = cur.fetchall() mycommand = row[0] # drop the cmd from the list cmd = """dele... |
return mycommand[2] | return (mycommand[2],mycommand[1]) | def fetchAndLockNextCmd(self,taskrow): # fetch a cmd from ready list cmd = """select rowid,concretename,cmdLine from readyList JOIN cmds USING (taskrow,linenum) where taskrow=%d limit 1;""" cur = self.cursor() cur.execute(cmd % taskrow) rows = cur.fetchall() mycommand = row[0] # drop the cmd from the list cmd = """dele... |
cur.execute("select taskid,rowid,date from tasks;") | cur.execute("select taskid,rowid,date from tasks LIMIT 200;") | def showState(self): cur = self.cursor() # look for tasks cur.execute("select taskid,rowid,date from tasks;") ttable = cur.fetchall() taskdict = {} if ttable == []: print "No Tasks in DB" else: for row in ttable: taskid = row[0] if taskid not in taskdict: taskdict[taskid] = row[1:] else: print "warning, duplicate task ... |
cur.execute("select rowid,concretename,state from filestate") | cur.execute("select rowid,concretename,state from filestate LIMIT 200") | def showFileTable(self): cur = self.cursor() cur.execute("select rowid,concretename,state from filestate") fstate = cur.fetchall() if fstate == []: print "No Files in DB" else: for row in fstate: print row[0], "Concrete", row[1], "with state", row[2], print "(", JobPersistence.fileStateMap[row[2]], ")" #print >>sys.std... |
cmd = 'select * from cmds where taskrow="%s"' % (taskrow) | cmd = 'select * from cmds where taskrow="%s" LIMIT 200' % (taskrow) | def showTaskCommandsByRow(self, taskrow): cur = self.cursor() cmd = 'select * from cmds where taskrow="%s"' % (taskrow) cur.execute(cmd) for cidtuple in cur.fetchall(): self.showCmdTuple(cidtuple) pass |
def showReadyList(self): sql = "select * from readyList JOIN cmds USING (taskrow,linenum) LIMIT 200;" cur = self.cursor() cur.execute(sql) for r in cur.fetchall(): print "ready cmd: task=%d line=%d, out=%s, cmd=%s, cmdline=%s" % ( r[0], r[1], r[2], r[3], r[4]) | def showCmd(self, cid): cur = self.cursor() cmd = 'select * from cmdtable where cmdid="%s"' % (cid) cur.execute(cmd) for fields in cur: print ' ID %s is cmd "%s" with cmdline "%s"' % fields cmd = 'select * from inouttable where cmdid="%s" and output=0' % (cid) cur.execute(cmd) for fields in cur: print " Inputfile: lo... | |
def selfTest(): print "doing basic internal build/delete/build/delete test." | def selfTest(args=[]): buildOnly = False if len(args) > 0: if "build" in args: buildOnly = True print "doing basic internal build/fill/run/delete/build/delete test." | def selfTest(): print "doing basic internal build/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" row = j.insertTask("AABBCCDD") # a command with no input and one independent output (ready to go) j.insertCmd(row, 2, "ncap", "ncap -o %outf_indep.nc%") j.ins... |
j.showState() | def selfTest(): print "doing basic internal build/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" row = j.insertTask("AABBCCDD") # a command with no input and one independent output (ready to go) j.insertCmd(row, 2, "ncap", "ncap -o %outf_indep.nc%") j.ins... | |
return | j.showState() while True: try: (cline,outname) = j.fetchAndLockNextCmd(row) except TypeError: print ":::no more lines to run!" break print ":::pretending to run %s" % (cline) j.showState() print ":::fake produce %s" % (outname) affected = j.cmdsWithInput(outname) j.setFileStateByName(outname, 3) j.makeReady(affected) ... | def selfTest(): print "doing basic internal build/delete/build/delete test." j = JobPersistence("sometest_db") j.buildTables() j.close() print " build and close" row = j.insertTask("AABBCCDD") # a command with no input and one independent output (ready to go) j.insertCmd(row, 2, "ncap", "ncap -o %outf_indep.nc%") j.ins... |
def fileShow(): j = JobPersistence() | def fileShow(dbfilename = None): j = JobPersistence(fixDbFilename(dbfilename)) | def fileShow(): j = JobPersistence() j.showFileTable() j.close() |
j = JobPersistence(fixDbFilename(dbfilename)) print "ok, deleting tables from ssdap" | realdb = fixDbFilename(dbfilename) j = JobPersistence(realdb) print "ok, deleting tables from ssdap @ %s" % (str(realdb)) | def deleteTables(dbfilename = None): j = JobPersistence(fixDbFilename(dbfilename)) print "ok, deleting tables from ssdap" j.deleteTables() j.close() pass |
j = JobPersistence(fixDbFilename(dbfilename)) print "ok, building new tables for ssdap" | realdb = fixDbFilename(dbfilename) j = JobPersistence(realdb) print "ok, building new tables for ssdap @ %s" % (str(realdb)) | def buildTables(dbfilename = None): j = JobPersistence(fixDbFilename(dbfilename)) print "ok, building new tables for ssdap" j.buildTables() j.close() pass |
from string import maketrans, translate, join msg = join(args["text"].split(" ")[2:]) table = maketrans( 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') newstring = translate(msg, table) | msg = " ".join(args["text"].split(" ")[2:]) newstring = msg.encode("rot_13") | def handler(self, **args): "Qbrf n fvzcyr ebg13, abguvat snapl" from irclib import Event, nm_to_n if args["type"] == "privmsg": target=nm_to_n(args["source"]) else: target=args["channel"] from string import maketrans, translate, join msg = join(args["text"].split(" ")[2:]) table = maketrans( 'nopqrstuvwxyzabcdefghijkl... |
def __init__(self, channels=[], nickname="", server="", port=6667, password="", module_list=[]): | def __init__(self, channels=[], nickname="", server="", port=6667, password="", module_list=[], encoding=""): | def __init__(self, channels=[], nickname="", server="", port=6667, password="", module_list=[]): """MooBot initializer - gets values from config files and uses those unless passed values directly""" print "possible config files: " + ", ".join(self.config_files) |
print "possible config files: " + ", ".join(self.config_files) | Debug("possible config files: " + ", ".join(self.config_files)) | def __init__(self, channels=[], nickname="", server="", port=6667, password="", module_list=[]): """MooBot initializer - gets values from config files and uses those unless passed values directly""" print "possible config files: " + ", ".join(self.config_files) |
SingleServerIRCBot.__init__(self, [(server, port, password)], nickname, nickname) | SingleServerIRCBot.__init__(self, [(server, port, password, encoding)], nickname, nickname) | def __init__(self, channels=[], nickname="", server="", port=6667, password="", module_list=[]): """MooBot initializer - gets values from config files and uses those unless passed values directly""" print "possible config files: " + ", ".join(self.config_files) |
print "Joining", channel | Debug("Joining", channel) | def on_welcome(self, c, e): """Whenever this bot joins a server, this is executed""" for channel in self.channels.keys(): print "Joining", channel c.join(channel) |
print YELLOW + "<" + nm_to_n(args["source"]) + NORMAL + "/" + \ | Debug(YELLOW + "<" + nm_to_n(args["source"]) + NORMAL + "/" + \ | def on_privmsg(self, c, e): """Whenever someone sends a /msg to our bot, this is executed""" msg = e.arguments()[0] # the string of what was said # build the args dict for the handlers args={} args["text"] = self.connection.get_nickname() + ": " + msg args["type"] = e.eventtype() args["source"] = e.source() args["chann... |
RED + "(" + args["type"] + ")" + NORMAL, args["text"] | RED + "(" + args["type"] + ")" + NORMAL, args["text"]) | def on_privmsg(self, c, e): """Whenever someone sends a /msg to our bot, this is executed""" msg = e.arguments()[0] # the string of what was said # build the args dict for the handlers args={} args["text"] = self.connection.get_nickname() + ": " + msg args["type"] = e.eventtype() args["source"] = e.source() args["chann... |
print YELLOW + "<" + nm_to_n(args["source"]) + NORMAL + "/" +\ | Debug(YELLOW + "<" + nm_to_n(args["source"]) + NORMAL + "/" +\ | def on_pubmsg(self, c, e): """Whenever someone speaks in a channel where our bot resides, this is executed""" import string msg = e.arguments()[0] args = {} args["text"] = msg args["type"] = e.eventtype() args["source"] = e.source() args["channel"] = e.target() # Then check with all the global handlers, see if any matc... |
RED + "(" + args["type"] + ")" + NORMAL, args["text"] | RED + "(" + args["type"] + ")" + NORMAL, args["text"]) | def on_pubmsg(self, c, e): """Whenever someone speaks in a channel where our bot resides, this is executed""" import string msg = e.arguments()[0] args = {} args["text"] = msg args["type"] = e.eventtype() args["source"] = e.source() args["channel"] = e.target() # Then check with all the global handlers, see if any matc... |
print "Could not get event handler." print "msg:", args["text"] print "type:", args["type"] print "source:", args["source"] print "channel:", args["channel"] | Debug("Could not get event handler.") Debug("msg:", args["text"]) Debug("type:", args["type"]) Debug("source:", args["source"]) Debug("channel:", args["channel"]) | def get_handler(self, type, msg, args): """Used when an event is raised that needs an event handler""" # Check through the handlers for a key that matches # the message contents. from irclib import nm_to_n from irclib import Event import weakref nickname = self.connection.get_nickname() if type == Handler.GLOBAL and ar... |
print RED + ">" + \ | Debug(RED + ">" + \ | def do_event(self, event): """Does an appropriate action based on event""" if event.eventtype() == "privmsg": for line in string.split(event.arguments()[0], "\n"): # print the output to the STDOUT, with a bit of colour print RED + ">" + \ PURPLE + self.connection.get_nickname() + \ RED + "/" + \ GREEN + event.target() ... |
NORMAL, line | NORMAL, line) | def do_event(self, event): """Does an appropriate action based on event""" if event.eventtype() == "privmsg": for line in string.split(event.arguments()[0], "\n"): # print the output to the STDOUT, with a bit of colour print RED + ">" + \ PURPLE + self.connection.get_nickname() + \ RED + "/" + \ GREEN + event.target() ... |
print RED + " * " + \ | Debug(RED + " * " + \ | def do_event(self, event): """Does an appropriate action based on event""" if event.eventtype() == "privmsg": for line in string.split(event.arguments()[0], "\n"): # print the output to the STDOUT, with a bit of colour print RED + ">" + \ PURPLE + self.connection.get_nickname() + \ RED + "/" + \ GREEN + event.target() ... |
NORMAL, event.arguments() | NORMAL, event.arguments()) | def do_event(self, event): """Does an appropriate action based on event""" if event.eventtype() == "privmsg": for line in string.split(event.arguments()[0], "\n"): # print the output to the STDOUT, with a bit of colour print RED + ">" + \ PURPLE + self.connection.get_nickname() + \ RED + "/" + \ GREEN + event.target() ... |
print "Joining", event.target() | Debug("Joining", event.target()) | def do_event(self, event): """Does an appropriate action based on event""" if event.eventtype() == "privmsg": for line in string.split(event.arguments()[0], "\n"): # print the output to the STDOUT, with a bit of colour print RED + ">" + \ PURPLE + self.connection.get_nickname() + \ RED + "/" + \ GREEN + event.target() ... |
print "Parting", event.target() | Debug("Parting", event.target()) | def do_event(self, event): """Does an appropriate action based on event""" if event.eventtype() == "privmsg": for line in string.split(event.arguments()[0], "\n"): # print the output to the STDOUT, with a bit of colour print RED + ">" + \ PURPLE + self.connection.get_nickname() + \ RED + "/" + \ GREEN + event.target() ... |
print "Changing nick to ", event.target() | Debug("Changing nick to ", event.target()) | def do_event(self, event): """Does an appropriate action based on event""" if event.eventtype() == "privmsg": for line in string.split(event.arguments()[0], "\n"): # print the output to the STDOUT, with a bit of colour print RED + ">" + \ PURPLE + self.connection.get_nickname() + \ RED + "/" + \ GREEN + event.target() ... |
print "Kicking", event.target(), "from", event.arguments()[1] | Debug("Kicking", event.target(), "from", event.arguments()[1]) | def do_event(self, event): """Does an appropriate action based on event""" if event.eventtype() == "privmsg": for line in string.split(event.arguments()[0], "\n"): # print the output to the STDOUT, with a bit of colour print RED + ">" + \ PURPLE + self.connection.get_nickname() + \ RED + "/" + \ GREEN + event.target() ... |
print "Sending raw command: " + event.arguments()[0] | Debug("Sending raw command: " + event.arguments()[0]) | def do_event(self, event): """Does an appropriate action based on event""" if event.eventtype() == "privmsg": for line in string.split(event.arguments()[0], "\n"): # print the output to the STDOUT, with a bit of colour print RED + ">" + \ PURPLE + self.connection.get_nickname() + \ RED + "/" + \ GREEN + event.target() ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.