diff options
author | showard <showard@592f7852-d20e-0410-864c-8624ca9c26a4> | 2009-01-07 21:07:28 +0000 |
---|---|---|
committer | showard <showard@592f7852-d20e-0410-864c-8624ca9c26a4> | 2009-01-07 21:07:28 +0000 |
commit | 01df7df14150eacb0f7345c35edb580fa5e3a3aa (patch) | |
tree | 53141b3b1ebe96ade31e0d21a04484639f842ce5 /tko/retrieve_logs.cgi | |
parent | 9e7268aafd44f61edf75a014bb1f60014240937d (diff) |
Change drop-down log viewers in TKO to use JSONP instead of XmlHttpRequests so they can handle direction to other servers. If you're curious what the hell JSONP is, check out http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=Article_UsingGWTForJSONMashups.
Signed-off-by: Steve Howard <showard@google.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@2607 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'tko/retrieve_logs.cgi')
-rwxr-xr-x | tko/retrieve_logs.cgi | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/tko/retrieve_logs.cgi b/tko/retrieve_logs.cgi index 5cb3a224..0f822a40 100755 --- a/tko/retrieve_logs.cgi +++ b/tko/retrieve_logs.cgi @@ -28,31 +28,47 @@ except ImportError: # Get form fields form = cgi.FieldStorage(keep_blank_values=True) # Retrieve logs -job_path = form['job'].value[1:] +job_path = form['job'].value job_path = os.path.join(autodir, job_path) keyval = retrieve_logs(job_path) -def find_repo(job_path): +def find_repository_host(job_path): """Find the machine holding the given logs and return a URL to the logs""" config = global_config.global_config drones = config.get_config_value('SCHEDULER', 'drones') results_host = config.get_config_value('SCHEDULER', 'results_host') - if drones and results_host and results_host != 'localhost': - drone_list = [hostname.strip() for hostname in drones.split(',')] - results_repos = [results_host] + drone_list + drone_list = [hostname.strip() for hostname in drones.split(',')] + results_repos = [results_host] + drone_list + if results_repos != ['localhost']: for drone in results_repos: - http_path = 'http://%s%s' % (drone, form['job'].value) + http_path = 'http://%s%s' % (drone, job_path) try: - urllib2.urlopen(http_path).read() - return http_path + urllib2.urlopen(http_path) + if drone == 'localhost': + return None + return drone except urllib2.URLError: pass # just return the results repo if we haven't found any - return 'http://%s%s' % (results_host, form['job'].value) + return results_host else: - # Local - return form['job'].value + return None -print page % find_repo(job_path) +def get_full_path(host, path): + if host: + prefix = 'http://' + host + else: + prefix = '' + + if form.has_key('jsonp_callback'): + callback = form['jsonp_callback'].value + return '%s/tko/jsonp_fetcher.cgi?path=%s&callback=%s' % ( + prefix, path, callback) + else: + return prefix + path + + +host = find_repository_host(job_path) +print page % get_full_path(host, job_path) |