Log result of results submission. Added option to instruct server to ignore results, for testing purposes. Added license headers.
authorMark Cote <mcote@mozilla.com>
Thu, 15 Mar 2012 00:14:53 -0400
changeset 84 0ed9f4a0c35c8a3722554d4340c424ea64573bc3
parent 83 3bc9aa8c9cf431e9fcce459a05ef71b1c05b7594
child 85 5e62dadac39a90878daf142da821acc2d17b347b
push id82
push usermcote@mozilla.com
push dateThu, 15 Mar 2012 04:15:01 +0000
Log result of results submission. Added option to instruct server to ignore results, for testing purposes. Added license headers.
client/fxinstall.py
client/nw.py
client/results.py
client/speedtests.py
server/handlers.py
server/server.py
--- a/client/fxinstall.py
+++ b/client/fxinstall.py
@@ -1,8 +1,12 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
 import ftplib
 import os
 import re
 import shutil
 import sys
 import zipfile
 
 # taken from one of the comments at
--- a/client/nw.py
+++ b/client/nw.py
@@ -1,8 +1,12 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
 import _winreg
 import os
 
 IF_ID_FILENAME = 'nwifid'
 
 class NwDisabler(object):
     IFS_SUBKEY = 'SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces'
 
@@ -77,9 +81,9 @@ if __name__ == '__main__':
         if sys.argv[1] == 'enable':
             nw_disabler.enable_nw()
         elif sys.argv[1] == 'disable':
             nw_disabler.disable_nw()
         else:
             print 'Invalid command "%s".' % sys.argv[1]
             print usage
             sys.exit(errno.EINVAL)
-        
\ No newline at end of file
+        
--- a/client/results.py
+++ b/client/results.py
@@ -1,8 +1,12 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
 from collections import defaultdict
 
 class SpeedTestReport(object):
 
     def __init__(self, results):
         self.results = results
         self.best_scores = defaultdict(lambda: {'score': None,
                                                 'score_str': '',
--- a/client/speedtests.py
+++ b/client/speedtests.py
@@ -1,8 +1,12 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
 import BaseHTTPServer
 import cgi
 import collections
 import ConfigParser
 import datetime
 import errno
 import json
 import os
@@ -570,20 +574,26 @@ class TestRunnerRequestHandler(BaseHTTPS
             else:
                 raw_data = json.dumps(web_data)
                 content_type = 'application/json; charset=utf-8'
             req = urllib2.Request(config.server_results_url, raw_data)
             req.add_header('Content-Type', content_type)
             req.add_header('Content-Length', len(raw_data))
 
             try:
-                urllib2.urlopen(req)
+                response = json.loads(urllib2.urlopen(req).read())
             except urllib2.HTTPError, e:
                 print '**ERROR sending results to server: %s' % e
                 print
+            else:
+                if response['result'] == 'ok':
+                    print 'Results submitted to server.'
+                else:
+                    print '**ERROR sending results to server: %s' % \
+                        response['error']
         self.send_response(200)
         self.end_headers()
         self.wfile.write('<html></html>')
         self.server.browser_runner.next_test()
 
     def log_message(self, format, *args):
         """ Suppress log output. """
         return
@@ -596,16 +606,18 @@ def main():
     parser = OptionParser()
     parser.add_option('-t', '--test', dest='tests', action='append', default=[])
     parser.add_option('--testmode', dest='testmode', action='store_true')
     parser.add_option('-n', '--noresults', dest='noresults',
                       action='store_true')
     parser.add_option('-s', '--sign', dest='sign', type='string',
                       action='store',
                       help='sign results with key in given file')
+    parser.add_option('--ignore', dest='ignore', action='store_true',
+                      help='instruct server to ignore results')
     (options, args) = parser.parse_args()
     config.read(options.testmode, options.noresults)
     
     def get_browser_arg():
         try:
             browser = args[1]
         except IndexError:
             print 'Specify a browser.'
--- a/server/handlers.py
+++ b/server/handlers.py
@@ -1,8 +1,12 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
 import ConfigParser
 import datetime
 import json
 import os
 import re
 import speedtests
 import templeton.handlers
 import urllib2
--- a/server/server.py
+++ b/server/server.py
@@ -1,9 +1,12 @@
-#!/usr/bin/env python2.6
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
 import templeton.handlers
 import templeton.middleware
 import handlers
 import web
 
 urls = templeton.handlers.load_urls(handlers.urls)
 
 app = web.application(urls, handlers.__dict__)