Skip to content

Commit

Permalink
minor clean up of Web interface & code.
Browse files Browse the repository at this point in the history
commented what URL each Quixote directory serves; renamed results_detail
to results_index; toggled 'files' link with presence/absence of files;
provided a way to retrieve the size of files.
  • Loading branch information
Titus Brown committed Nov 22, 2009
1 parent e0d5600 commit 0774a18
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pony_build/file_storage.py
Expand Up @@ -108,6 +108,10 @@ def exists(self):
"Check to see if the file still exists."
return os.path.isfile(self._make_abspath())

def size(self):
"Return the size, in bytes, of the file."
return os.path.getsize(self._make_abspath())

def open(self, mode='rb'):
"Provide a handle to the file contents. Make sure to use binary..."
return open(self._make_abspath(), mode)
37 changes: 36 additions & 1 deletion pony_build/qx_web/__init__.py
Expand Up @@ -28,6 +28,9 @@
from ..coordinator import build_tagset

class QuixoteWebApp(Directory):
"""
URL: /
"""
_q_exports = [ '', 'css', 'exit', 'recv_file', 'rss2', 'p', 'test']

def __init__(self, coord, pshb_list=[]):
Expand Down Expand Up @@ -120,6 +123,9 @@ def create_publisher(coordinator, pubsubhubbub_server=None):
###

class PackageDirectory(Directory):
"""
URL: /p/
"""
_q_exports = [ '' ]

def __init__(self, coord):
Expand All @@ -136,6 +142,9 @@ def _q_lookup(self, component):
###

class RSS2FeedDirectory(Directory):
"""
URL: /rss2/
"""
_q_exports = [ '', '_generic' ]

def __init__(self, coord):
Expand Down Expand Up @@ -165,6 +174,9 @@ def _q_lookup(self, component):
return snooper.generate_rss(self.coord, package_url, per_result_url)

class RSS2_GenericFeeds(Directory):
"""
URL: /rss2/_generic/
"""
_q_exports = [ '', 'redirect' ]

def __init__(self, coord):
Expand All @@ -191,6 +203,9 @@ def _q_lookup(self, package):
return RSS2_GenericPackageFeeds(self.coord, package)

class RSS2_GenericPackageFeeds(Directory):
"""
URL: /rss2/_generic/<package>/
"""
_q_exports = [ '' ]

def __init__(self, coord, package):
Expand Down Expand Up @@ -231,6 +246,9 @@ def _q_lookup(self, component):
###

class PackageInfo(Directory):
"""
/p/<package>/
"""
_q_exports = [ '', 'show_latest', 'show_all', 'inspect', 'detail',
'request_build', 'files' ]

Expand Down Expand Up @@ -281,6 +299,12 @@ def sort_by_timestamp(a, b):
tb = b[1][0]['time']
return -cmp(ta, tb)

def files_exist(tagset):
key = d[tagset][0]['result_key']
x = self.coord.get_files_for_result(key)
x = [ f for f in x if f.visible and f.exists() ]
return len(x)

it = d.items()
it.sort(sort_by_timestamp)
tagset_list = [ k for (k, v) in it ]
Expand Down Expand Up @@ -333,6 +357,9 @@ def _q_lookup(self, component):
return ResultInfo(self.coord, self.package, component)

class ResultInfo(Directory):
"""
URL: /p/<package>/<result>/
"""
_q_exports = ['', 'inspect', 'files' ]
def __init__(self, coord, package, result_key):
self.coord = coord
Expand All @@ -357,7 +384,12 @@ def _q_index(self):
timestamp = format_timestamp(receipt['time'])
tags = ", ".join(client_info['tags'])

template = env.get_template('results_detail.html')
def files_exist():
x = self.coord.get_files_for_result(key)
x = [ f for f in x if f.visible and f.exists() ]
return len(x)

template = env.get_template('results_index.html')
return template.render(locals()).encode('latin-1', 'replace')

def inspect(self):
Expand Down Expand Up @@ -392,6 +424,9 @@ def request_build(self):
return quixote.redirect('./')

class ResultFiles(Directory):
"""
URL: /p/<package>/<result>/files/
"""
_q_exports = ['']

def __init__(self, coord, package, result_key):
Expand Down
6 changes: 5 additions & 1 deletion pony_build/qx_web/templates/package_summary.html
Expand Up @@ -18,7 +18,11 @@ <h4><i>Summary view of results</i></h4>
<td>{{ calc_status(tagset) }}</td>
<td>{{ calc_time(tagset) }}</td>
<td><a href='./{{ get_result_key(tagset) }}/'>view details</a> |
<a href='./{{ get_result_key(tagset) }}/inspect'>request build</a> | <a href='./{{get_result_key(tagset) }}/files'>files</a></td>
<a href='./{{ get_result_key(tagset) }}/inspect'>request build</a>
{% if files_exist(tagset) %}
| <a href='./{{get_result_key(tagset) }}/files'>files</a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
Expand Down
2 changes: 1 addition & 1 deletion pony_build/qx_web/templates/results_files_index.html
Expand Up @@ -36,7 +36,7 @@ <h2>Files for package '{{ package }}'</h2>
{% if file_list %}
{% for fileobj in file_list %}
{% if fileobj.visible %}
{{ loop.index }}. <a href='{{ fileobj.filename|e }}'>{{ fileobj.filename }}</a> - {{ fileobj.description }}<br>
{{ loop.index }}. <a href='{{ fileobj.filename|e }}'>{{ fileobj.filename }}</a> - {{ fileobj.description }} ({{ (fileobj.size() / 1000 + 1)|int }} kb)<br>
{% endif %}
{% endfor %}
{% else %}
Expand Down
Expand Up @@ -6,7 +6,12 @@

<h2>Result detail</h2>

<i><a href='../{{ key }}/'>permanent link</a></i> | <i><a href='./inspect'>inspect raw record</a></i>
<i><a href='../{{ key }}/'>permanent link</a></i> |
<i><a href='./inspect'>inspect raw record</a></i>
{% if files_exist() %}
| <i><a href='./files/'>attached files</a></i>
{% endif %}

<br><br>

<p>
Expand Down

0 comments on commit 0774a18

Please sign in to comment.