def run(self): server_list = self.get_server_list() self.log("StatServerDate start %s" % get_time()) if self.server_id is None: statServerDatas = StatServerDataCountry.query( condition="stat_date ='%s'" % self.date) else: statServerDatas = StatServerDataCountry.query( condition="stat_date ='%s' and server_id = '%s' " % (self.date, self.server_id)) if not statServerDatas: for server in server_list: try: if server.server_status == 100: continue countries = self.getServerCountryCode(server) if countries: for country in countries: self.stat(server, self.date, country['idfa']) except Exception, ex: self.log("server_name[%s] error" % server.server_name) self.log(ex) self.log("StatServerDate end %s" % get_time())
def run(self): server_list = self.get_server_list() self.log("StatServerDate start %s" % get_time()) if self.server_id is None: statServerDatas = StatServerDataCountry.query(condition="stat_date ='%s'" % self.date) else: statServerDatas = StatServerDataCountry.query(condition="stat_date ='%s' and server_id = '%s' " % (self.date, self.server_id)) if not statServerDatas: for server in server_list: try: if server.server_status==100: continue countries = self.getServerCountryCode(server) if countries : for country in countries: self.stat(server, self.date, country['idfa']) except Exception,ex: self.log("server_name[%s] error" % server.server_name) self.log(ex) self.log("StatServerDate end %s" % get_time())
try: cursor = connection.cursor() sql = "select COALESCE(max(online),0) as max_online from stat_online where date(stat_time) = '%s' and server_id = '%s'" % ( date, values['server_id']) data = cursor.fetchone(sql) if not data and data['max_online'] is None: values['max_online'] = 0 else: values['max_online'] = int(data['max_online']) except Exception, ex: self.log(ex) finally: if cursor is not None: cursor.close() statServerData = StatServerDataCountry() statServerData.country_code = country for k, v in values.iteritems(): setattr(statServerData, k, v) statServerData.stat_date = date if self.isInsert: statServerData.persist() #print '' else: self.statServerDatass.append(statServerData) date = get_date_str_by_day(date, 1, '%Y-%m-%d') # if self.is_input: # break if string_to_datetime(date, '%Y-%m-%d') >= string_to_datetime( get_date(), '%Y-%m-%d'):
cursor = None try: cursor = connection.cursor() sql = "select COALESCE(max(online),0) as max_online from stat_online where date(stat_time) = '%s' and server_id = '%s'" % (date,values['server_id']) data = cursor.fetchone(sql) if not data and data['max_online'] is None: values['max_online'] = 0 else: values['max_online'] = int(data['max_online']) except Exception,ex: self.log(ex) finally: if cursor is not None: cursor.close() statServerData = StatServerDataCountry() statServerData.country_code=country for k, v in values.iteritems(): setattr(statServerData, k, v) statServerData.stat_date = date if self.isInsert: statServerData.persist() #print '' else: self.statServerDatass.append(statServerData) date = get_date_str_by_day(date,1,'%Y-%m-%d') # if self.is_input: # break if string_to_datetime(date,'%Y-%m-%d') >= string_to_datetime(get_date(),'%Y-%m-%d') :