Exemplo n.º 1
0
 def stat(self,server,open_time):
     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
     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 = StatLiucunDataDate()
     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.data_date=datetime_to_string(open_time)
     statLiucunData.persist()
Exemplo n.º 2
0
 def run(self):
     if self.server_id:
         #ServerPartnerList.query(condition="server_id='%s'" % server_id, order="partner_id desc")
         statLiucunData = StatLiucunDataDate.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:
Exemplo n.º 3
0
def get_stat_liucun_server(server_id):
    return StatLiucunDataDate.query(condition="server_id='%s'" % server_id)
Exemplo n.º 4
0
             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()
     now_time = datetime.datetime.now()
     for server in server_list:
         try:
             if server.server_status==100:
                 continue
             begin_date = server.open_time
             while(datetime_to_string(now_time,"%Y-%m-%d") != datetime_to_string(begin_date,"%Y-%m-%d") and now_time < string_to_datetime(get_datetime_str_by_day(begin_date,30))):
                 statLiucunData = StatLiucunDataDate.query(condition="server_id='%s' and data_date='%s'" % (server.server_id,datetime_to_string(begin_date,"%Y-%m-%d")))
                 if statLiucunData:
                     statLiucunData[0].is_hostory = 1
                     statLiucunData[0].persist()
                 self.stat(server,begin_date)
                 begin_date = string_to_datetime(get_datetime_str_by_day(begin_date,1));
                 statLiucunData = StatLiucunDataDate()
                 statLiucunData.delete_mul(is_hostory=1)
         except Exception,ex:
             self.log(ex)
     
 
 def stat(self,server,open_time):
     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}
Exemplo n.º 5
0
def get_stat_liucun_server(server_id):
    return StatLiucunDataDate.query(condition="server_id='%s'" % server_id)