From aec9d263e7ec6202c9ae74d4b1999ec458cc4d25 Mon Sep 17 00:00:00 2001 From: "gasperfele@fri1.uni-lj.si" Date: Fri, 7 Oct 2016 20:27:08 +0000 Subject: An image depicting the setup is now shown for each task git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@358 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/web/kpov_judge/icons/computer.svg | 1877 ----------- kpov_judge/web/kpov_judge/icons/drive-harddisk.svg | 491 --- kpov_judge/web/kpov_judge/icons/internet.svg | 3398 -------------------- kpov_judge/web/kpov_judge/kpov_draw_setup.py | 50 +- kpov_judge/web/kpov_judge/kpov_judge.py | 19 +- .../web/kpov_judge/static/icons/computer.png | Bin 0 -> 15600 bytes .../web/kpov_judge/static/icons/computer.svg | 1877 +++++++++++ .../web/kpov_judge/static/icons/drive-harddisk.png | Bin 0 -> 1940 bytes .../web/kpov_judge/static/icons/drive-harddisk.svg | 491 +++ .../web/kpov_judge/static/icons/internet.png | Bin 0 -> 9438 bytes .../web/kpov_judge/static/icons/internet.svg | 3398 ++++++++++++++++++++ .../web/kpov_judge/templates/task_greeting.html | 4 + 12 files changed, 5811 insertions(+), 5794 deletions(-) delete mode 100644 kpov_judge/web/kpov_judge/icons/computer.svg delete mode 100644 kpov_judge/web/kpov_judge/icons/drive-harddisk.svg delete mode 100644 kpov_judge/web/kpov_judge/icons/internet.svg create mode 100644 kpov_judge/web/kpov_judge/static/icons/computer.png create mode 100644 kpov_judge/web/kpov_judge/static/icons/computer.svg create mode 100644 kpov_judge/web/kpov_judge/static/icons/drive-harddisk.png create mode 100644 kpov_judge/web/kpov_judge/static/icons/drive-harddisk.svg create mode 100644 kpov_judge/web/kpov_judge/static/icons/internet.png create mode 100644 kpov_judge/web/kpov_judge/static/icons/internet.svg diff --git a/kpov_judge/web/kpov_judge/icons/computer.svg b/kpov_judge/web/kpov_judge/icons/computer.svg deleted file mode 100644 index 6da674d..0000000 --- a/kpov_judge/web/kpov_judge/icons/computer.svg +++ /dev/null @@ -1,1877 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kpov_judge/web/kpov_judge/icons/drive-harddisk.svg b/kpov_judge/web/kpov_judge/icons/drive-harddisk.svg deleted file mode 100644 index 5f36f85..0000000 --- a/kpov_judge/web/kpov_judge/icons/drive-harddisk.svg +++ /dev/null @@ -1,491 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Drive - Hard Disk - - - Jakub Steiner - - - - - hdd - hard drive - fixed - media - solid - - - - - http://jimmac.musichall.cz - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kpov_judge/web/kpov_judge/icons/internet.svg b/kpov_judge/web/kpov_judge/icons/internet.svg deleted file mode 100644 index 5efbd24..0000000 --- a/kpov_judge/web/kpov_judge/icons/internet.svg +++ /dev/null @@ -1,3398 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kpov_judge/web/kpov_judge/kpov_draw_setup.py b/kpov_judge/web/kpov_judge/kpov_draw_setup.py index a6ffc82..0042389 100644 --- a/kpov_judge/web/kpov_judge/kpov_draw_setup.py +++ b/kpov_judge/web/kpov_judge/kpov_draw_setup.py @@ -1,35 +1,41 @@ import pygraphviz as pgv -def draw_setup(computers, networks, destination = None): - G = pgv.AGraph() +def draw_setup(computers, networks, destination=None, + icon_prefix = '../../../static/icons/', + format='svg', icon_path = '', icon_suffix = None): + if icon_suffix is None: + icon_suffix = format + icon_suffix = '.' + icon_suffix + G = pgv.AGraph(imagepath=icon_path + '/') + print G.graph_attr have_internet = [] - for net, net_params in networks.iteritems(): - if net_params.get('public', False): - have_internet.append(net) - G.add_node('net-' + net, label=net, shape='rectangle') + for net in networks: + net_name = net.get('name', 'net') + if net.get('public', False): + have_internet.append(net_name) + G.add_node('net-' + net_name, label=net_name, shape='rectangle') if len(have_internet): G.add_node('net-' + 'internet', label='internet', - labelloc='b', image='icons/internet.svg', shape='none') + labelloc='b', + image=icon_prefix + 'internet' + icon_suffix, + shape='none') for n in have_internet: G.add_edge('net-' + n, 'net-internet') - for c, properties in computers.iteritems(): - G.add_node('comp-' + c, - label = c, - image='icons/computer.svg', - shape='none', labelloc='b') - G_sub = G.add_subgraph(['comp-' + c], name='cluster-' + c, - label = c, - rank='same', pack=True) + for properties in computers: + c = properties.get('name', '') + label_str = '< ' + label = label_str.format(c, icon_prefix + 'computer' + icon_suffix) for hdd in properties.get('disks', []): - G_sub.add_node('disk-' + hdd['name'], - label=hdd['name'], - shape='none', - image='icons/drive-harddisk.svg') - G_sub.add_edge('comp-' + c, 'disk-' + hdd['name']) - for iface in properties.get('network_interfaces'): + icon = icon_prefix + 'drive-harddisk' + icon_suffix + label += ''.format(icon, hdd['name']) + label += '
{}
{}
>' + G.add_node('comp-' + c, + label = label, + shape='box', labelloc='b') + for iface in properties.get('network_interfaces', []): G.add_edge('comp-' + c, 'net-' + iface['network']) - return G.draw(path=destination, format='svg', prog='dot') + return G.draw(path=destination, format=format, prog='dot') if __name__ == '__main__': import sample_task as task diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py index d02ba99..21233f4 100755 --- a/kpov_judge/web/kpov_judge/kpov_judge.py +++ b/kpov_judge/web/kpov_judge/kpov_judge.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import flask -from flask import Flask, g, session, redirect, url_for, abort, render_template, flash, app, request +from flask import Flask, g, session, redirect, url_for, abort, render_template, flash, app, request, Response import pymongo import json import random @@ -104,11 +104,18 @@ def results_json(task_id): return json.dumps(results_post(task_id, json.loads(flask.app.request.form['results']))) return json.dumps(results_dict(task_id)) -@app.route('/tasks//setup.svg', methods=['GET']) -def setup_svg(task_id): - networks = db.networks.find({'task_id': task_id}) - computers = db.computers_meta.find({'task_id': task_id}) - return draw_setup(computers, networks) +@app.route('/tasks///setup.', methods=['GET']) +def setup_svg(task_id, lang, ending): + db = g.db + fmt, mimetype = { + 'svg':('svg', 'image/svg+xml'), + 'png':('png', 'image/png'), + }[ending] + networks = list(db.networks.find({'task_id': task_id})) + computers = list(db.computers_meta.find({'task_id': task_id})) + return Response(draw_setup(computers, networks, format=fmt, + icon_path=app.config['STATIC_DIR']), + mimetype=mimetype) @app.route('/tasks///results.html') def results_html(task_id, lang): diff --git a/kpov_judge/web/kpov_judge/static/icons/computer.png b/kpov_judge/web/kpov_judge/static/icons/computer.png new file mode 100644 index 0000000..aebd82e Binary files /dev/null and b/kpov_judge/web/kpov_judge/static/icons/computer.png differ diff --git a/kpov_judge/web/kpov_judge/static/icons/computer.svg b/kpov_judge/web/kpov_judge/static/icons/computer.svg new file mode 100644 index 0000000..6da674d --- /dev/null +++ b/kpov_judge/web/kpov_judge/static/icons/computer.svg @@ -0,0 +1,1877 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kpov_judge/web/kpov_judge/static/icons/drive-harddisk.png b/kpov_judge/web/kpov_judge/static/icons/drive-harddisk.png new file mode 100644 index 0000000..ce482f2 Binary files /dev/null and b/kpov_judge/web/kpov_judge/static/icons/drive-harddisk.png differ diff --git a/kpov_judge/web/kpov_judge/static/icons/drive-harddisk.svg b/kpov_judge/web/kpov_judge/static/icons/drive-harddisk.svg new file mode 100644 index 0000000..5f36f85 --- /dev/null +++ b/kpov_judge/web/kpov_judge/static/icons/drive-harddisk.svg @@ -0,0 +1,491 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Drive - Hard Disk + + + Jakub Steiner + + + + + hdd + hard drive + fixed + media + solid + + + + + http://jimmac.musichall.cz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kpov_judge/web/kpov_judge/static/icons/internet.png b/kpov_judge/web/kpov_judge/static/icons/internet.png new file mode 100644 index 0000000..2f70cbf Binary files /dev/null and b/kpov_judge/web/kpov_judge/static/icons/internet.png differ diff --git a/kpov_judge/web/kpov_judge/static/icons/internet.svg b/kpov_judge/web/kpov_judge/static/icons/internet.svg new file mode 100644 index 0000000..5efbd24 --- /dev/null +++ b/kpov_judge/web/kpov_judge/static/icons/internet.svg @@ -0,0 +1,3398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kpov_judge/web/kpov_judge/templates/task_greeting.html b/kpov_judge/web/kpov_judge/templates/task_greeting.html index f19f534..f188def 100644 --- a/kpov_judge/web/kpov_judge/templates/task_greeting.html +++ b/kpov_judge/web/kpov_judge/templates/task_greeting.html @@ -13,6 +13,7 @@

Podrobna navodila (HOWTO)

+

Računalniki v vaji

{% for c in computers %}

{{c['name']}}

@@ -28,6 +29,9 @@ {% endfor %}

+ +

+

Lahko si ogledate surove: