Subversion Repositories kim

Compare Revisions

Ignore whitespace Rev 6 → Rev 7

/trunk/kim/kim.py
47,13 → 47,13
self.options = get_app_options()
self.utils = Utils(self.options)
self.log = Logger('KIM', level=self.options.LOGLEVEL).get_logger()
self.log.info('Starting %s %s', name, version)
self.log.debug('Starting %s %s', name, version)
 
def run(self):
snff = self.utils.get_firefox_history()
snch = self.utils.get_chrome_history()
usndict = self.utils.get_uniq_sapnotes([snff, snch])
self.log.debug(usndict)
self.log.debug("Total Unique SAP Notes: %d", len(usndict))
 
return usndict
 
60,9 → 60,8
 
def main():
kim = KIM()
kim.run()
usndict = kim.run()
return usndict
 
 
if __name__ == '__main__':
main()
 
/trunk/kim/utils.py
116,8 → 116,8
 
def get_chrome_history(self):
profile_dir = self.get_chrome_profile_dir()
if profile_dir == None:
self.log.warning ("No Chrome profile path found")
if profile_dir is None:
self.log.debug ("No Chrome profile path found")
return None
elif os.path.isdir(profile_dir) == False:
self.log.warning ('Path Does Not Exist: %s' % profile_dir)
133,7 → 133,7
 
def filter_firefox_history(self, placesDB):
sndict = {}
self.log.debug('Printing Firefox history')
self.log.debug('Searching SAP Notes in Firefox history')
try:
conn = sqlite3.connect(placesDB)
c = conn.cursor()
168,7 → 168,7
 
def filter_chrome_history(self, placesDB):
sndict = {}
self.log.debug('Printing Chrome history')
self.log.debug('Searching SAP Notes in Chrome history')
shutil.copy(placesDB, "history")
conn = sqlite3.connect("history")
c = conn.cursor()
194,37 → 194,19
return None
 
 
def printUniqueSAPNotes(self):
unique = set()
for line in snotes:
# Get SAP Note number
sep = line.rfind('/')
snid = line[sep+1:]
unique.add(snid)
# Get visited date and add it to set
sep = line.find(':')
visited = line[:sep]
try:
svdate = dnotes['visited']
if not visited in svdate:
svdate.add(visited)
except:
svdate = set()
svdate.add(visited)
dnotes[snid] = {}
dnotes[snid]['visited'] = svdate
 
 
def get_uniq_sapnotes(self, sndicts):
usndict = {}
for sndict in sndicts:
for snid in sndict:
try:
date = usndict[snid]
if sndict[snid] > date:
if sndict is not None:
for snid in sndict:
try:
date = usndict[snid]
if sndict[snid] > date:
usndict[snid] = sndict[snid]
except:
usndict[snid] = sndict[snid]
except:
usndict[snid] = sndict[snid]
else:
self.log.debug("Possibly there is no data for current dictionary")
self.log.debug("Unique SAP Notes for all browsers: %d" % len(usndict))
return usndict