Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #93 from tinyclues/90-fix
Browse files Browse the repository at this point in the history
Fix non-supported syntax in python2.6 in string formatting. Fix #90
  • Loading branch information
Lothiraldan committed Nov 10, 2015
2 parents 6c5205a + 490a46c commit 7e6415e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 6 additions & 3 deletions saltpad/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,14 @@ def job_result(jid):
renderer = request.args.get('renderer', 'raw')
job = client.job(jid)

context = {}

if renderer == 'highstate':
try:
job = parse_highstate(job)
except NotHighstateOutput:
return redirect(url_for('job_result', jid=jid, minion=minion,
renderer='raw'))
renderer='raw'))
elif renderer == 'aggregate':
aggregate_result = {}

Expand All @@ -192,12 +194,13 @@ def job_result(jid):
missing_minions = set(job['info']['Minions']) - set(job['return'].keys())
if missing_minions:
aggregate_result['Missing results'] = missing_minions
job['return'] = aggregate_result
job['aggregate_return'] = aggregate_result
context['total_minions'] = sum(len(minions) for minions in aggregate_result.values())

if not job:
return "Unknown jid", 404
return render_template('job_result_{0}.html'.format(renderer), job=job, minion=minion,
renderer=renderer)
renderer=renderer, **context)

@app.route("/templates")
@login_required
Expand Down
6 changes: 2 additions & 4 deletions saltpad/templates/job_result_aggregate.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@

{% block job_result %}

{% set total_minions_length = job.info.Minions|length %}

<div class="row">
<div class="col-lg-12">
<p>
<button class="btn btn-primary btn-sm" id="expand-all"><i class="fa fa-sitemap"></i> Expand all</button>
</p>
</div>
{% for result, minions in job.return|aggregate_len_sort %}
{% for result, minions in job.aggregate_return|aggregate_len_sort %}

<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3>{{hiding_control('hide_control_minion', True)|safe }} {{ minions|length }} ({{ '{:.0%}'.format(minions|length / total_minions_length) }}) minion(s) with this result:</h3>
<h3>{{hiding_control('hide_control_minion', True)|safe }} {{ minions|length }} ({{ '{0:.0%}'.format(minions|length / total_minions) }}) minion(s) with this result:</h3>
</div>
<pre class="panel-body">{{ result }}</pre>
<ul class="list-group" style="display: none">
Expand Down
4 changes: 2 additions & 2 deletions saltpad/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def format_arguments(arguments):
for argument in arguments:
if isinstance(argument, dict):
argument.pop('__kwarg__')
yield "--{}={}".format(*list(argument.items())[0])
yield "--{0}={1}".format(*list(argument.items())[0])
else:
yield argument

Expand Down Expand Up @@ -253,7 +253,7 @@ def process_lowstate(lowstate):
require_state, require_name = list(require.items())[0]

if require_state == 'sls':
requires.append((state['order'], 'cluster_{}'.format(require_name.replace('.', '_').replace('-', '_'))))
requires.append((state['order'], 'cluster_{0}'.format(require_name.replace('.', '_').replace('-', '_'))))
continue

required_state = id_map[(require_state, require_name)]
Expand Down

0 comments on commit 7e6415e

Please sign in to comment.