Difference for python/CFLog.py from version 1.2 to 1.3


version 1.2 version 1.3
Line 18
 
Line 18
 #  #
 # The author can be reached via e-mail at jbontje@suespammers.org  # The author can be reached via e-mail at jbontje@suespammers.org
 #  #
   
 #Updated to use new path functions in CFPython -Todd Mitchell  #Updated to use new path functions in CFPython -Todd Mitchell
   #
   # Updated to add new fields and functions (kick, muzzle)
   # and rewritten to use plain text file storage (CFDataFile) instead of shelve.
   
 import shelve  
 import os.path  
   
 import CFPython  import CFPython
   
 from time import localtime, strftime, time  from time import localtime, strftime, time
   from CFDataFile import CFDataFile, CFData
   
 class CFLog:  class CFLog:
   
     logdb_file = os.path.join(CFPython.GetLocalDirectory(),'crossfirelog')  
     logdb = {}  
   
     def __init__(self):      def __init__(self):
         self.logdb = shelve.open(self.logdb_file)          logheader = ['Born', 'IP', 'Last_Login_Date', 'Login_Count', 'Kick_Count'
             , 'Last_Kick_Date', 'Muzzle_Count', 'Last_Muzzle_Date']
           self.log = CFData('Player_log', logheader)
   
     def create(self, name):      def create(self, name):
         date = strftime("%a, %d %b %Y %H:%M:%S CEST", localtime(time()))          date = strftime("%a, %d %b %Y %H:%M:%S CEST", localtime(time()))
         count=1          record={'#': name
         self.logdb[name]=['unknown', date, count]          ,'Born':date
           ,'IP':'unknown'
           ,'Last_Login_Date':date
           ,'Login_Count':0
           ,'Kick_Count':0
           ,'Last_Kick_Date':'never'
           ,'Muzzle_Count':0
           ,'Last_Muzzle_Date':'never'}
           self.log.put_record(record)
   
     def update(self, name, ip):      def remove(self, name):
           self.log.remove_record(name)
   
       def login_update(self, name, ip):
         date = strftime("%a, %d %b %Y %H:%M:%S CEST", localtime(time()))          date = strftime("%a, %d %b %Y %H:%M:%S CEST", localtime(time()))
         count=0          record = self.log.get_record(name)
         if self.logdb.has_key(name):          record['IP']=ip
             oldip, olddate, count=self.logdb[name]          record['Last_Login_Date']=date
         count+=1          record['Login_Count']=int(record['Login_Count'])+1
         self.logdb[name]=[ip, date, count]          self.log.put_record(record)
   
     def remove(self, name):      def kick_update(self, name):
         if self.logdb.has_key(name):          date = strftime("%a, %d %b %Y %H:%M:%S CEST", localtime(time()))
             del self.logdb[name]          record = self.log.get_record(name)
           record['Kick_Count']=int(record['Kick_Count'])+1
           record['Last_Kick_Date']=date
           self.log.put_record(record)
          
     def exist(self, name):      def muzzle_update(self, name):
         if self.logdb.has_key(name):          date = strftime("%a, %d %b %Y %H:%M:%S CEST", localtime(time()))
             return 1          record = self.log.get_record(name)
         else:          record['Muzzle_Count']=int(record['Muzzle_Count'])+1
             return 0          record['Last_Muzzle_Date']=date
           self.log.put_record(record)
   
     def info(self, name):      def info(self, name):
         if self.exist(name):          record = self.log.get_record(name)
             ip, date, count=self.logdb[name]          if record:
             return ip, date, count              return record
           else:
               return 0


Legend:
line(s) removed in v.1.2 
line(s) changed
 line(s) added in v.1.3

File made using version 1.96 of cvs2html by leaf at 2006-02-15 17:26