def getMilestones(): # connect trac.db conn = adodb.NewADOConnection('sqlite') dbf = "%s/%s/%s" % (Settings['rootpath'], Settings['projname'], Settings['dbname']) conn.Connect(database=dbf) #"trac.db" # retrieve all milestones sqls = sqltrac reAllMilestone = [m[0] for m in conn.GetAll(sqls['allMilestone'])] # strip milestone name milestone = [] for m in reAllMilestone: milestone.append(stripMilestoneName(m)) print "\n" * 3, "milestone", milestone #return ['kxedem2', 'kxewssm11', 'kxefeng1', 'kxefeng2a'] return milestone
def main(): servers = [] conn = adodb.NewADOConnection('mysql') conn.Connect('localhost', 'hostedby_soda', 'alpha01', 'hostedby_alpha') cursor = conn.Execute( 'select * from servers;' ) while not cursor.EOF: arr = cursor.GetRowAssoc(0) server = ( "%s:%s" ) % ( arr['serverip'], arr['serverport'] ) rcon = arr['serverrcon'] players = int( os.popen( ( "/home/hostedby/www/mine/wc/qstat -R -P -cn -tsw -q3s %s -raw \' \' | grep -v ^game | grep -v ^Q3S | wc -l" ) % ( server ) ).read().rstrip( '\n' ) ) if players < 5: print ( "./rcon.py %s %s rcon set g_respawn 2" ) % ( server, rcon ) elif players < 11: print ( "./rcon.py %s %s rcon set g_respawn 4" ) % ( server, rcon ) elif players < 15: print ( "./rcon.py %s %s rcon set g_respawn 8" ) % ( server, rcon ) else: print ( "./rcon.py %s %s rcon set g_respawn 12" ) % ( server, rcon ) cursor.MoveNext() cursor.Close() conn.Close()
def do_import(options, params): """Import a blog based upon a section from the .ini file.""" print("[{}]".format(params["iniSection"])) # Check to see if this section should be skipped. if check_params(params): return # Create a connection to the Serendipity database. s9y_connection = adodb.NewADOConnection(params["s9yDriver"]) s9y_connection.Connect(params["s9yHost"], params["s9yUser"], params["s9yPassword"], params["s9yDatabase"]) # Create a connection to the Tikiwiki database. tiki_connection = adodb.NewADOConnection(params["tikiDriver"]) tiki_connection.Connect(params["tikiHost"], params["tikiUser"], params["tikiPassword"], params["tikiDatabase"]) # Find the blog in Tikiwiki. blog_id = get_tiki_blog_id(tiki_connection, params["tiki_blog_name"]) if blog_id is None: print("ERROR: No Tikiwiki blog titled '" + params["tiki_blog_name"] + "' was found.") return 1 # Build the query to fetch posts from Serendipity. join_clauses = [] where_clauses = [] if "s9yFilterAuthor" in params: where_clauses.append("author='" + params["s9yFilterAuthor"] + "'") if "s9yFilterCategory" in params: categoryid = get_s9y_categoryid(s9y_connection, params["s9yFilterCategory"]) join_clauses.append("INNER JOIN s9y_entrycat" + " ON s9y_entries.id = s9y_entrycat.entryid") where_clauses.append("s9y_entrycat.categoryid=" + str(categoryid)) join_statement = " " + " ".join(join_clauses) if len(where_clauses) > 0: where_statement = " WHERE (" + " AND ".join(where_clauses) + ")" else: where_statement = "" statement =\ "SELECT title,timestamp,body,author" +\ " FROM s9y_entries" +\ join_statement +\ where_statement +\ " ORDER BY id" # Loop through the Serendipity posts. n_posts = 0 for row in s9y_connection.Execute(statement): # Extract the fields that we can import. (title, timestamp, body, author) = row if params["s9yMarkup"] == "none": body = translate_none(body) elif params["s9yMarkup"] == "s9y": body = translate_s9y(body) elif params["s9yMarkup"] == "textile": body = translate_textile(body) elif params["s9yMarkup"] == "bbcode": body = translate_bbcode(body) elif params["s9yMarkup"] == "textwiki": body = translate_text_wiki(body) else: print("ERROR: Unknown markup '{}'".format(params["s9yMarkup"])) return 1 # Add the post to the tikiwiki database. statement =\ "INSERT INTO `tiki_blog_posts`" +\ " (blogId, data, data_size, created, user, title, priv)" +\ " VALUES(" +\ str(blog_id) + "," +\ sql_quote(body) + "," + \ "0," +\ str(timestamp) + "," +\ sql_quote(author) + "," +\ sql_quote(title) + "," +\ sql_quote("n") + ")" if not options.dryRun: tiki_connection.Execute(statement) n_posts += 1 # Update the number of posts field in the tikiwiki database. statement =\ "UPDATE tiki_blogs SET posts = posts + 1 WHERE blogId = " +\ str(blog_id) if not options.dryRun: tiki_connection.Execute(statement) # Print some statistics. if options.dryRun: print("{} posts would be imported".format(n_posts)) else: print("{} posts imported".format(n_posts))
if typeF.find('(')>=0: if typeF.find(',')>=0: m = reFloat.search(typeF) else: m = reInt.search(typeF) if m: gps = m.groups() type = gps[0] size = gps[1] else: type = typeF size = -1 else: type = typeF size = -1 arr.append((rs.fields[0],type,size)) rs.MoveNext() return arr class cursor_mysql(adodb.ADOCursor): def __init__(self,rs,conn): adodb.ADOCursor.__init__(self,rs,conn) #self._insertid = rs.insert_id() self._insertid = rs.lastrowid if __name__ == '__main__': db = adodb.NewADOConnection('mysql') db.Connect('localhost','root','','northwind') for r in db.Execute('select * from adoxyz'): print r adodb.Test(db)
def __init__(self): self.conn = adodb.NewADOConnection('mysql') self.conn.Connect('192.168.1.95', 'root', 'root', 'banner_quickscan')
def __init__(self, milestone): """ini all: - milestone milestone """ self.milestone = milestone self.init = Settings self.mapDone = ('closed') self.mapDoing = ('assigned') self.mapNew = ('new', 'reopened') self.mapUnplan = ('accidental') # load setting from ini self.fDict = os.path.join( dirname, "%s/%s.dump" % (self.init['dumpath'], milestone)) self.expRoot = self.init['expath'] self.projname = self.init['projname'] self.rootpath = self.init['rootpath'] self.dbname = self.init['dbname'] self.sqls = sqltrac self.conn = adodb.NewADOConnection('sqlite') # pysqlite required dbf = "%s/%s/%s" % (self.rootpath, self.projname, self.dbname) self.conn.Connect(database=dbf) #"trac.db" try: print "try load historic dictDUMP" self.TicketQuery = pickle.load(open(self.fDict)) except: print "rebuild dict.obj." self.TicketQuery = {} '''data struc. burnti={ 'yymmdd':{'burn':{'due':int,'all':[id,...]} ,'total':{'due':int,'all':[id,...]} } ,... } ''' day = 60 * 60 * 24 # reAllTi = self.conn.GetAll(self.sqls['allTickets']) timeMin = self.conn.GetOne(self.sqls['timeMin'] % self.milestone) if not timeMin: return dayMin = int(timeMin) / day today = int(time.time()) / day for aDay in range(dayMin, today + 1): d = time.strftime("%y%m%d", time.localtime(aDay * day)) print d rows = self.conn.GetAll(self.sqls['allTicketsOneDay'] % self.milestone) reAllTi = [] for row in rows: id = row[0] t = (aDay + 1) * day currentStatus = self.conn.GetAll(self.sqls['currentStatus'] % (id, t))[0][0] if not currentStatus: result = self.conn.GetAll(self.sqls['createdStatus'] % (id, t)) if result: currentStatus = result[0][0] if currentStatus: row = list(row) row[-4] = currentStatus reAllTi.append(row) # print reAllTi reAllDue = self.conn.GetAll(self.sqls['allDue'] % self.milestone) # reAllDue = self.conn.GetAll(self.sqls['allDue']) # filter history record, i.e., not today or yesterday if aDay != today and aDay != today - 1 and self.TicketQuery.has_key( d): print "skipped %s" % d continue else: self.TicketQuery[d] = self.initScan(reAllTi, reAllDue) #DBscanner() # print self.TicketQuery print "%s >>>CreatDate flush starting.." % (self.projname) logging.info("%s >>>CreatDate flush starting.." % self.projname) f = open(self.fDict, "w") pickle.dump(self.TicketQuery, f) f.close()
def __init__(self): self.conn = adodb.NewADOConnection('mysql') self.conn.Connect('192.168.1.95', 'root', 'disappointed1', 'telnet_banners')
def __init__(self,milestone): """ini all: - milestone ~milestone """ self.crtDate = time.strftime("%y%m%d",time.localtime(time.time())) self.milestone=milestone self.init = Settings self.done=('closed') self.TicketQuery = {} self.RelaTicket = {'relati':{} ,'purenew':[] ,'puredoing':[] ,'puredone':[] } # load setting from ini self.fDict = os.path.join(dirname, "data/%s.dump"%milestone) self.expRoot = self.init['expath'] self.projname = self.init['projname'] self.rootpath = self.init['rootpath'] self.dbname = self.init['dbname'] self.reporturl = self.init['reporturl'] #self.UnplannedRep = self.init['UnplannedRep'] self.ticketurl = self.init['ticketurl'] self.tplIdx = os.path.join(dirname, "%s/idx.relat.tpl"%self.init['tplpath']) self.expIdx = os.path.join(dirname, "%s/idx-%s.html"%(self.init['expath'],milestone)) self.sqls = sqltrac #print self.sql self.conn = adodb.NewADOConnection('sqlite') # pysqlite required dbf = "%s/%s/%s"%(self.rootpath ,self.projname ,self.dbname) print dbf self.conn.Connect(database = dbf) #"trac.db" try: print "try load historic dictDUMP" self.MaileQuery = pickle.load(open(self.fDict))[self.crtDate] except: print "BurnDown data can't load! %s" % self.crtDate print pickle.load(open(self.fDict)) logging.info("%s >>>BurnDown data can't load!.."%self.projname) return #self.MaileQuery={} #print self.MaileQuery '''data struc. burnti={ 'yymmdd':{'burn':{'due':int,'all':[id,...]} ,'total':{'due':int,'all':[id,...]} } ,... } SELECT p.value AS __color__, t.priority as __group__,id AS ticket, summary, time AS created FROM ticket t LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority' WHERE milestone = 'DefendEngine.m1.\u9632\u5fa1\u5b50\u7cfb\u7edf\u7b2c\u4e00\u9636\u6bb5\u70b9' and status = 'assigned' ORDER BY p.value ''' self.crtAllTi = self.initScan()#DBscanner() #print self.crtAllTi print "%s >>>CreatDate flush starting.."%(self.projname) logging.info("%s >>>CreatDate flush starting.."%self.projname)