Bug 387619 - Stand-alone Talos. Check for csv path existence/ graph server

link existence.  a=anodelman r=rcampbell


git-svn-id: svn://10.0.0.236/trunk@238986 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
anodelman%mozilla.com
2007-11-08 19:32:42 +00:00
parent 5cf7b12f9a
commit d965814d93
3 changed files with 28 additions and 10 deletions

View File

@@ -5,7 +5,19 @@
# "Except where otherwise noted, recipes in the Python Cookbook are published under the Python license ."
# This recipe is covered under the Python license: http://www.python.org/license
import httplib, mimetypes
import httplib, mimetypes, urllib2
def link_exists(host, selector):
"""
Check to see if the given host exists and is reachable
"""
try:
site = urllib2.urlopen("http://" + host + selector)
meta = site.info()
except urllib2.URLError:
print "FAIL: http://" + host + selector + " raises URLError (check if link exists)"
return 0
return 1
def post_multipart(host, selector, fields, files):
"""

View File

@@ -85,11 +85,11 @@ def process_Request(post):
str += line.split(":")[3] + ":" + shortNames(line.split(":")[1]) + ":" + line.split(":")[2] + '\n'
return str
def send_to_csv(csv_file, results):
def send_to_csv(csv_dir, results):
import csv
for res in results:
browser_dump, counter_dump = results[res]
writer = csv.writer(open(csv_file + '_' + res + '.csv', "wb"))
writer = csv.writer(open(os.path.join(csv_dir, res + '.csv'), "wb"))
if res in ('ts', 'twinopen'):
i = 0
writer.writerow(['i', 'val'])
@@ -118,7 +118,7 @@ def send_to_csv(csv_file, results):
i += 1
for cd in counter_dump:
for count_type in cd:
writer = csv.writer(open(csv_file + '_' + res + '_' + count_type + '.csv', "wb"))
writer = csv.writer(open(os.path.join(csv_dir, res + '_' + count_type + '.csv'), "wb"))
writer.writerow(['i', 'value'])
i = 0
for val in cd[count_type]:
@@ -247,7 +247,7 @@ def test_file(filename):
tests = []
title = ''
testdate = ''
csv_file = ''
csv_dir = ''
results_server = ''
results_link = ''
results = {}
@@ -261,12 +261,18 @@ def test_file(filename):
title = yaml_config[item]
elif item == 'testdate':
testdate = yaml_config[item]
elif item == 'csv_file':
csv_file = os.path.normpath(yaml_config[item])
elif item == 'csv_dir':
csv_dir = os.path.normpath(yaml_config[item])
if not os.path.exists(csv_dir):
print "FAIL: path \"" + csv_dir + "\" does not exist"
sys.exit(0)
elif item == 'results_server':
results_server = yaml_config[item]
elif item == 'results_link' :
results_link = yaml_config[item]
if (results_link != results_server != ''):
if not post_file.link_exists(results_server, results_link):
exit(0)
browser_config = {'preferences' : yaml_config['preferences'],
'extensions' : yaml_config['extensions'],
'firefox' : yaml_config['firefox'],
@@ -304,8 +310,8 @@ def test_file(filename):
if (results_server != '') and (results_link != ''):
#send results to the graph server
send_to_graph(results_server, results_link, title, date, browser_config, results)
if csv_file != '':
send_to_csv(csv_file, results)
if csv_dir != '':
send_to_csv(csv_dir, results)
if __name__=='__main__':
optlist, args = getopt.getopt(sys.argv[1:], 'd', ['debug'])

View File

@@ -5,7 +5,7 @@ title: firefox_testing
#*** output options ****
#uncomment to turn on dump to csv option
#csv_file: 'output/out'
#csv_dir: 'output'
#comment out next two lines to disable send to graph server
results_server: 'url.of.graphserver'
results_link: '/bulk.cgi'