summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2009-07-02 13:34:38 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2009-07-02 13:34:38 -0400
commitc12f48f651cc97fede473366123badb57fc067a3 (patch)
tree7bab016949ca82bd33917e5d3d4fc07249a09db7
parentTypo. (diff)
downloadgeoemail-c12f48f651cc97fede473366123badb57fc067a3.tar.xz
geoemail-c12f48f651cc97fede473366123badb57fc067a3.zip
Only plot verified points on map.
-rwxr-xr-xsrc/geoemail.py18
-rw-r--r--src/locationverifier.py4
2 files changed, 14 insertions, 8 deletions
diff --git a/src/geoemail.py b/src/geoemail.py
index 60539f48..b4ee5d2d 100755
--- a/src/geoemail.py
+++ b/src/geoemail.py
@@ -9,10 +9,10 @@ import os
def main():
global options, parser
parser = OptionParser(usage="usage: %prog [options] file|directory [file|directory] [file|directory] ...", description="Analyzes email headers and extracts geographic information.")
- parser.add_option("-p", "--print", action="store_true", help="print geographic information about each encountered email", dest="printinfo")
- parser.add_option("-d", "--debug", action="store_true", help="display when email parser has to dig a little deeper to find the correct IP")
- parser.add_option("-m", "--map", action="store", type="string", metavar="HTMLFILE", help="generate visual representation of emails in a Google Map and write html to HTMLFILE")
- parser.add_option("-v", "--verify", action="store", type="string", metavar="CSVFILE", help="verify accuracy of algorithm by comparing to CSV table with the first column of the first row the default country, then in the next rows, the first column the start date (mm/dd/yyyy), the second column the end date, and the remaining columns the countries visited")
+ parser.add_option("-p", "--print", action="store_true", help="Print geographic information about each encountered email.", dest="printinfo")
+ parser.add_option("-d", "--debug", action="store_true", help="Display when email parser has to dig a little deeper to find the correct IP.")
+ parser.add_option("-m", "--map", action="store", type="string", metavar="HTMLFILE", help="Generate visual representation of emails in a Google Map and write html to HTMLFILE. When combined with -v, --verify, only verified points are plotted.")
+ parser.add_option("-v", "--verify", action="store", type="string", metavar="CSVFILE", help="Verify accuracy of algorithm by comparing to CSV table with the first column of the first row the default country, then in the next rows, the first column the start date (mm/dd/yyyy), the second column the end date, and the remaining columns the countries visited. When combined with -m, --map, only verified points are plotted.")
(options, args) = parser.parse_args()
if options.debug == None and options.map == None and options.printinfo == None and options.verify == None:
options.printinfo = True
@@ -32,6 +32,7 @@ def main():
outfile = open(options.map, "w")
mailmap.writeMap(outfile)
outfile.close()
+ print "Map written to %s" % options.map
if options.verify != None:
print verification
if len(verification.misses) > 0:
@@ -60,10 +61,13 @@ def processFile(fileName):
if options.debug and examine.debug:
print fileName + ":",
print examine.debug
- if options.map != None:
- mailmap.addEmail(examine)
- if options.verify != None:
+ if options.map != None and options.verify != None:
+ if verification.checkEmail(examine):
+ mailmap.addEmail(examine)
+ elif options.verify != None:
verification.checkEmail(examine)
+ elif options.map != None:
+ mailmap.addEmail(examine)
if options.printinfo:
print fileName + ":"
print "\tSent: %s at %s" % (examine.date.date(), examine.date.time())
diff --git a/src/locationverifier.py b/src/locationverifier.py
index 7a52e184..b9076155 100644
--- a/src/locationverifier.py
+++ b/src/locationverifier.py
@@ -41,10 +41,12 @@ class LocationVerifier:
for place in location[2]:
if country.find(place) != -1:
self.locationHit += 1
- return
+ return True
if inDefault:
self.defaultLocationHit += 1
+ return True
else:
self.misses.append(email)
+ return False
def __str__(self):
return "%s emails from %s to %s\n%s in default location (%s)\n%s in verified locations\n%s in non-verified locations\n%s%% in default or verified locations\n%s%% in verified locations out of all non-default locations" % (self.totalEmailsInRange, self.startDate, self.endDate, self.defaultLocationHit, self.defaultLocation, self.locationHit, len(self.misses), ((float(self.defaultLocationHit) + float(self.locationHit)) / float(self.totalEmailsInRange) * 100.0), (float(self.locationHit) / (float(self.totalEmailsInRange) - float(self.defaultLocationHit)) * 100.0)) \ No newline at end of file