added some more debug mode output, cleaned up/simplified code in check_browser()

This commit is contained in:
rscmbbng 2013-09-09 17:58:35 +02:00
parent 59a6d8ab2a
commit 656f4f21ce

34
main.py
View File

@ -147,26 +147,20 @@ class bc(object):
self.browser_history_path = chromium_lin self.browser_history_path = chromium_lin
print "Browser Options:\n" + '='*45 + "\n" print "Browser Options:\n" + '='*45 + "\n"
if self.browser == "F": print "Currently used:", self.browser_path.split('/')[-1], "\n"
print "Browser used: Firefox \n"
elif self.browser == "C":
print "Browser used: Chrome \n"
elif self.browser == "CHROMIUM":
print "Browser used: Chromium \n"
elif self.browser == "S":
print "Browser used: Safari \n"
if self.options.debug == True: if self.options.debug == True:
if self.browser == "F" and sys.platform == 'darwin': if sys.platform == 'darwin':
self.browser_version = subprocess.check_output([self.browser_path, '--version']).strip('\n') if self.browser == "F" or self.browser == "C" or self.browser == "CHROMIUM":
elif self.browser == "F" and sys.platform.startswith('linux'): self.browser_version = subprocess.check_output([self.browser_path, '--version']).strip('\n')
elif sys.platform.startswith('linux') and self.browser == "F":
self.browser_version = subprocess.check_output(['firefox', '--version']).strip('\n') self.browser_version = subprocess.check_output(['firefox', '--version']).strip('\n')
elif self.browser == "C" and sys.platform == 'darwin':
self.browser_version = subprocess.check_output([self.browser_path, '--version']).strip('\n')
elif self.browser == "CHROMIUM" and sys.platform == 'darwin':
self.browser_version = subprocess.check_output([self.browser_path, '--version']).strip('\n')
print "Version:", self.browser_version, "\n" if self.browser == "S":
print "Can't get Safari version information, you'll have to look it up manually \n"
else:
print "Version:", self.browser_version, "\n"
print "History:", self.browser_history_path, "\n" print "History:", self.browser_history_path, "\n"
#move the subprocesses to debug mode #move the subprocesses to debug mode
@ -229,6 +223,8 @@ class bc(object):
url = url.replace('www.','') #--> doing a tracert to example.com and www.example.com yields different results. url = url.replace('www.','') #--> doing a tracert to example.com and www.example.com yields different results.
url_ip = socket.gethostbyname(url) url_ip = socket.gethostbyname(url)
print "Host:", url, "\n" print "Host:", url, "\n"
if self.options.debug == True:
print "Host ip:", url_ip, "\n"
if url != self.old_url: if url != self.old_url:
count = 1 count = 1
if sys.platform.startswith('linux'): if sys.platform.startswith('linux'):
@ -257,10 +253,12 @@ class bc(object):
except: except:
print "Error: network is not responding correctly. Aborting...\n" print "Error: network is not responding correctly. Aborting...\n"
sys.exit(2) sys.exit(2)
logfile = open('logfile', 'a') if self.options.debug == True:
logfile = open('logfile', 'a')
print '='*45 + "\n" + "Packages Route:\n" + '='*45 print '='*45 + "\n" + "Packages Route:\n" + '='*45
for line in a.stdout: for line in a.stdout:
logfile.write(line) if self.options.debug == True:
logfile.write(line)
parts = line.split() parts = line.split()
for ip in parts: for ip in parts:
if re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",ip): if re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",ip):