def stat(self,server): self.log("LiuCunServerData start %s,server:[%s]" % (get_time(),server.server_name)) values = {} days = {'one_user':0,'two_user':1,'three_user':3,'four_user':4,'five_user':5,'six_user':6,'seven_user':7,'fivteen_user':15,'thirty_user':30} values['server_id'] = server.server_id values['server_name'] = server.server_name open_time = server.open_time con= get_conn(server_util.str_to_dbconfig(server.db_connect)) for k,v in days.iteritems(): temp_date = get_datetime_str_by_day(open_time,v,"%Y-%m-%d") values[k] = self.stat_login_user(temp_date,con,get_datetime_str_by_day(open_time,0,"%Y-%m-%d")) statLiucunData = StatLiucunData() one_user = values['one_user'] for k, v in values.iteritems(): if k == 'one_user' or k == 'server_id' or k == 'server_name': setattr(statLiucunData, k, v) else: value = 0 if one_user != 0 and v != 0: value = round(v/float(one_user),5)*100 setattr(statLiucunData, k, value) else: setattr(statLiucunData, k, value) statLiucunData.persist()
def stat(self, server): self.log("LiuCunServerData start %s,server:[%s]" % (get_time(), server.server_name)) values = {} days = { 'one_user': 0, 'two_user': 1, 'three_user': 3, 'four_user': 4, 'five_user': 5, 'six_user': 6, 'seven_user': 7, 'fivteen_user': 15, 'thirty_user': 30 } values['server_id'] = server.server_id values['server_name'] = server.server_name open_time = server.open_time con = get_conn(server_util.str_to_dbconfig(server.db_connect)) for k, v in days.iteritems(): temp_date = get_datetime_str_by_day(open_time, v, "%Y-%m-%d") values[k] = self.stat_login_user( temp_date, con, get_datetime_str_by_day(open_time, 0, "%Y-%m-%d")) statLiucunData = StatLiucunData() one_user = values['one_user'] for k, v in values.iteritems(): if k == 'one_user' or k == 'server_id' or k == 'server_name': setattr(statLiucunData, k, v) else: value = 0 if one_user != 0 and v != 0: value = round(v / float(one_user), 5) * 100 setattr(statLiucunData, k, value) else: setattr(statLiucunData, k, value) statLiucunData.persist()
def run(self): if self.server_id: statLiucunData = StatLiucunData.load(server_id = server_id) if statLiucunData: statLiucunData.is_hostory = 1 statLiucunData.persist() else: curr_cursor = None try: curr_cursor = connection.cursor() sql = "update stat_liucun_data set is_hostory = 1" curr_cursor.execute(sql) except Exception,e: self.log(e) finally:
def run(self): if self.server_id: statLiucunData = StatLiucunData.load(server_id=server_id) if statLiucunData: statLiucunData.is_hostory = 1 statLiucunData.persist() else: curr_cursor = None try: curr_cursor = connection.cursor() sql = "update stat_liucun_data set is_hostory = 1" curr_cursor.execute(sql) except Exception, e: self.log(e) finally:
curr_cursor = connection.cursor() sql = "update stat_liucun_data set is_hostory = 1" curr_cursor.execute(sql) except Exception,e: self.log(e) finally: if curr_cursor is not None: curr_cursor.close() server_list = self.get_server_list() for server in server_list: try: self.stat(server) except Exception,ex: self.log(ex) statLiucunData = StatLiucunData() statLiucunData.delete_mul(is_hostory=1) def stat(self,server): self.log("LiuCunServerData start %s,server:[%s]" % (get_time(),server.server_name)) values = {} days = {'one_user':0,'two_user':1,'three_user':3,'four_user':4,'five_user':5,'six_user':6,'seven_user':7,'fivteen_user':15,'thirty_user':30} values['server_id'] = server.server_id values['server_name'] = server.server_name open_time = server.open_time con= get_conn(server_util.str_to_dbconfig(server.db_connect)) for k,v in days.iteritems(): temp_date = get_datetime_str_by_day(open_time,v,"%Y-%m-%d") values[k] = self.stat_login_user(temp_date,con,get_datetime_str_by_day(open_time,0,"%Y-%m-%d"))
def get_stat_liucun(): return StatLiucunData.query()
curr_cursor = connection.cursor() sql = "update stat_liucun_data set is_hostory = 1" curr_cursor.execute(sql) except Exception, e: self.log(e) finally: if curr_cursor is not None: curr_cursor.close() server_list = self.get_server_list() for server in server_list: try: self.stat(server) except Exception, ex: self.log(ex) statLiucunData = StatLiucunData() statLiucunData.delete_mul(is_hostory=1) def stat(self, server): self.log("LiuCunServerData start %s,server:[%s]" % (get_time(), server.server_name)) values = {} days = { 'one_user': 0, 'two_user': 1, 'three_user': 3, 'four_user': 4, 'five_user': 5, 'six_user': 6, 'seven_user': 7, 'fivteen_user': 15,