Ejemplo n.º 1
0
class Ipv_Top:
    def __init__(self,files,top_x=20,db_settings=local_db_settings):
        self.data=IpCounter(files).get_data()
        self.top_x=sorted(self.data.items(),key=lambda x:x[1],reverse=True)[:top_x]
        self.connection = MySQL_Connection(db_settings)


    def store(self):

        keys='(day,topn,ip,freq)'
        for i,(ip,counts) in enumerate(self.top_x):
            self.connection.insert('top_ip',keys,(today,i+1,ip,counts))
Ejemplo n.º 2
0
class PV_analysis:
    def __init__(self, files, db_settings=local_db_settings):
        self.connection = MySQL_Connection(db_settings)
        self.data = Market_PV_Counter(files).get_data()

    def store(self):
        self.connection.update("T_Site", ["recent_visit_cnt"], ["0"], 'WHERE url != ""')
        for url, value in self.data.items():
            with self.connection.connection as cursor:
                cursor.execute(
                    'UPDATE T_Site SET recent_visit_cnt = recent_visit_cnt+%d WHERE url LIKE "%%%s%%"' % (value, url)
                )
Ejemplo n.º 3
0
class IpLocationService:
    def __init__(self,files,db_settings=server_183_db_settings):
        self.data=IpLocationCounter(files).get_data()
        # self.data=cPickle.load(open('CityIpData'))
        self.connection=MySQL_Connection(db_settings)
        cPickle.dump(self.data,open('CityIpData','wb'))

    def store(self):

        province_data={}

        for (city,province),count in self.data.items():
            self.connection.insert('city_ip',('day','city','count'),(today,city,count))
            province_data.setdefault(province,0)
            province_data[province]+=count
        for province,count in province_data.items():
            self.connection.insert('province_ip',('day','province','count'),(today,province,count))

        # print self.data
        # print province_data
Ejemplo n.º 4
0
 def __init__(self,files,db_settings=server_183_db_settings):
     self.data=IpLocationCounter(files).get_data()
     # self.data=cPickle.load(open('CityIpData'))
     self.connection=MySQL_Connection(db_settings)
     cPickle.dump(self.data,open('CityIpData','wb'))
Ejemplo n.º 5
0
 def __init__(self,files,top_x=20,db_settings=local_db_settings):
     self.data=IpCounter(files).get_data()
     self.top_x=sorted(self.data.items(),key=lambda x:x[1],reverse=True)[:top_x]
     self.connection = MySQL_Connection(db_settings)
Ejemplo n.º 6
0
 def __init__(self, files, db_settings=local_db_settings):
     self.connection = MySQL_Connection(db_settings)
     self.data = Market_PV_Counter(files).get_data()