|
|
@ -1,4 +1,4 @@ |
|
|
|
#!/usr/bin/python |
|
|
|
#!/usr/local/bin/python |
|
|
|
# -*- coding: iso-8859-15 -*- |
|
|
|
""" |
|
|
|
BC (Border-Check) is a tool to retrieve info of traceroute tests over website navigation routes. |
|
|
@ -26,12 +26,12 @@ DEBUG = 1 |
|
|
|
|
|
|
|
class bc(object): |
|
|
|
""" |
|
|
|
BC main Class |
|
|
|
""" |
|
|
|
BC main Class |
|
|
|
""" |
|
|
|
def __init__(self): |
|
|
|
""" |
|
|
|
Init defaults |
|
|
|
""" |
|
|
|
Init defaults |
|
|
|
""" |
|
|
|
self.browser = "" # "F" Firefox / "C" Chrome |
|
|
|
self.browser_path = "" |
|
|
|
self.url = "" |
|
|
@ -39,14 +39,14 @@ class bc(object): |
|
|
|
|
|
|
|
def set_options(self, options): |
|
|
|
""" |
|
|
|
Set program options |
|
|
|
""" |
|
|
|
Set program options |
|
|
|
""" |
|
|
|
self.options = options |
|
|
|
|
|
|
|
def create_options(self, args=None): |
|
|
|
""" |
|
|
|
Create options for OptionParser |
|
|
|
""" |
|
|
|
Create options for OptionParser |
|
|
|
""" |
|
|
|
self.optionParser = BCOptions() |
|
|
|
self.options = self.optionParser.get_options(args) |
|
|
|
if not self.options: |
|
|
@ -55,8 +55,8 @@ class bc(object): |
|
|
|
|
|
|
|
def try_running(self, func, error, args=None): |
|
|
|
""" |
|
|
|
Try running a function and print some error if it fails and exists with a fatal error. |
|
|
|
""" |
|
|
|
Try running a function and print some error if it fails and exists with a fatal error. |
|
|
|
""" |
|
|
|
options = self.options |
|
|
|
args = args or [] |
|
|
|
try: |
|
|
@ -72,8 +72,8 @@ class bc(object): |
|
|
|
|
|
|
|
def check_browser(self): |
|
|
|
""" |
|
|
|
Check for browser used by system |
|
|
|
""" |
|
|
|
Check for browser used by system |
|
|
|
""" |
|
|
|
if sys.platform == 'darwin': |
|
|
|
f_osx = os.path.join(os.path.expanduser('~'), 'Library/Application Support/Firefox/Profiles') |
|
|
|
c_osx = os.path.join(os.path.expanduser('~'), 'Library/Application Support/Google/Chrome/Default/History') |
|
|
@ -140,8 +140,8 @@ class bc(object): |
|
|
|
|
|
|
|
def getURL(self): |
|
|
|
""" |
|
|
|
Set urls to visit |
|
|
|
""" |
|
|
|
Set urls to visit |
|
|
|
""" |
|
|
|
print "Browser database:", self.browser_path, "\n" |
|
|
|
conn = sqlite3.connect(self.browser_path) |
|
|
|
c = conn.cursor() |
|
|
@ -164,8 +164,8 @@ class bc(object): |
|
|
|
|
|
|
|
def getGEO(self): |
|
|
|
""" |
|
|
|
Get Geolocation database (http://dev.maxmind.com/geoip/legacy/geolite/) |
|
|
|
""" |
|
|
|
Get Geolocation database (http://dev.maxmind.com/geoip/legacy/geolite/) |
|
|
|
""" |
|
|
|
# Download and extract database |
|
|
|
try: |
|
|
|
urllib.urlretrieve('http://xsser.sf.net/map/GeoLiteCity.dat.gz', |
|
|
@ -183,8 +183,8 @@ class bc(object): |
|
|
|
|
|
|
|
def run(self, opts=None): |
|
|
|
""" |
|
|
|
Run BorderCheck |
|
|
|
""" |
|
|
|
Run BorderCheck |
|
|
|
""" |
|
|
|
#eprint = sys.stderr.write |
|
|
|
# set options |
|
|
|
if opts: |
|
|
@ -250,4 +250,3 @@ if __name__ == "__main__": |
|
|
|
if options: |
|
|
|
app.set_options(options) |
|
|
|
app.run() |
|
|
|
|
|
|
|