From 70fe6254fbc16d2f417c617c86b6185e911bc8bc Mon Sep 17 00:00:00 2001 From: Michael Hanke Date: Mon, 16 May 2011 09:36:06 -0400 Subject: [PATCH] No automatic figure generation on the webserver * More silent, more efficient, compatible with python 2.5 --- survey/Makefile | 17 ++++++++++++----- survey/makestats | 29 +++++++++++++++++------------ survey/surveycollector.cgi | 4 ++-- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/survey/Makefile b/survey/Makefile index a9a706c..8b60230 100644 --- a/survey/Makefile +++ b/survey/Makefile @@ -18,7 +18,14 @@ results_snippet.html: results.html | tail -n$$(echo "$$(wc -l < results.html) - $$(grep -n '' \ < results.html | cut -d ':' -f 1,1) - 2" | bc ) > $@ -stats: *.txt +statfigures: oslist.txt swlist.txt datamodlist.txt +# create "lockfile' + @touch $@ + @[ "$$(cat nsubmissions.stamp || true)" != "$$(ls -1 data |wc -l)" ] \ + && ls -1 data |wc -l > nsubmissions.stamp \ + && MVPA_MATPLOTLIB_BACKEND=agg ./makestats data figures || true +# remove lockfile + @-rm $@ getdata: rsync -rvzlhp --delete \ @@ -36,9 +43,9 @@ datamodlist.txt: survey.rst grep '"bg_datamod"' survey.rst | sed -e 's/.*name="bg_datamod" value="//' \ -e 's," />,: ",' -e 's,
$$,",' -e 's/ "$$/ "Other"/' > $@ -upload: index.html results.html results_snippet.html jquery.form.js survey.css +upload: index.html results.html results_snippet.html jquery.form.js survey.css surveycollector.cgi rsync -rvzlhp --delete \ - --exclude=Makefile --exclude='*.inc' --exclude='*.rst' --exclude='*.txt' \ - --exclude=makestats --exclude=surveydata --exclude='*.cgi' \ - --chmod=Dg+s,g+rw * neurodebian@www.pymvpa.org:/home/www/neuro.debian.net/www/survey/ + --exclude='*.txt' --exclude=surveydata --exclude='*.cgi' --exclude=figures \ + --chmod=Dg+s,g+rw * neurodebian@www.pymvpa.org:/home/neurodebian/survey/ + scp surveycollector.cgi neurodebian@www.pymvpa.org:/srv/neuro.debian.net/cgi-bin/ diff --git a/survey/makestats b/survey/makestats index 5dd7633..4ca6abc 100755 --- a/survey/makestats +++ b/survey/makestats @@ -1,12 +1,19 @@ #!/usr/bin/python +from mvpa.misc.plot.base import plot_bars from glob import glob -import json +try: + from json import load as jload + def jsonload(f): + return jload(f) +except ImportError: + from json import read as jread + def jsonload(f): + return jread(f.read()) import sys import pylab as pl import numpy as np import time -from mvpa.misc.plot.base import plot_bars # uniform colors for OS results os_colors = ['#B63537', '#4E4DA0', '#008200', 'gray'] @@ -93,7 +100,7 @@ class DB(dict): return datafilenames = glob('%s/*.json' % srcdir) for dfn in datafilenames: - rawdata = json.load(open(dfn)) + rawdata = jsonload(open(dfn)) self[rawdata['timestamp']] = rawdata def get_unique(self, key): @@ -176,7 +183,7 @@ def mkpic_os_per_env(db, destdir): stats[osf] = float(stats[osf]) / total_count env_stats[env] = stats # make stacked barplot - pl.figure(figsize=(6.4, 4.8), facecolor='w', edgecolor='k') + pl.figure(figsize=(6.4, 4.8)) x = np.arange(len(envs)) bottoms = np.zeros(len(envs)) for i, os in enumerate(os_order): @@ -196,7 +203,7 @@ def mkpic_submissions_per_datamod(db, destdir): spd = db.get_counts('bg_datamod') spd = sorted(spd.items(), cmp=lambda x, y: cmp(x[1], y[1]))[::-1] x = np.arange(len(spd)) - pl.figure(figsize=(6.4, 4.8), facecolor='w', edgecolor='k') + pl.figure(figsize=(6.4, 4.8)) pl.title('Submissions per data modality') pl.bar(x, [s[1] for s in spd]) pl.xticks(x + 0.5, [db.datamod_dict[k[0]] for k in spd], rotation=-10) @@ -207,7 +214,7 @@ def mkpic_resources(db, destdir): res = db.get_counts('software_resource') res = res.items() x = np.arange(len(res)) - pl.figure(figsize=(6.4, 4.8), facecolor='w', edgecolor='k') + pl.figure(figsize=(6.4, 4.8)) pl.title('Software resources') pl.bar(x + (1./8), [s[1] for s in res], width=0.75, color = '#008200') pl.xticks(x + 0.5, ['' for s in res]) @@ -215,15 +222,14 @@ def mkpic_resources(db, destdir): pl.text(i+.5, 0.1, db.get_nice_name(s[0]), rotation=90, horizontalalignment='center', verticalalignment='bottom', - bbox=dict(facecolor='white', alpha=0.8, edgecolor='white', - color='white')) + bbox=dict(facecolor='white', alpha=0.8, edgecolor='white')) pl.ylabel('Number of submissions') pl.savefig('%s/software_resources.png' % destdir, format='png', dpi=80) def mkpic_software(db, destdir): for typ in sw_categories.keys(): counts = db.get_counts('sw_%s' % typ) - pl.figure(figsize=(6.4, 4.8), facecolor='w', edgecolor='k') + pl.figure(figsize=(6.4, 4.8)) pl.title("Software popularity: %s" % db.get_nice_name(typ)) if not len(counts): pl.text(.5, .5, "[Insufficient data for this figure]", @@ -239,14 +245,13 @@ def mkpic_software(db, destdir): pl.text(i+.5, 0.1, db.get_nice_name(s[0]), rotation=90, horizontalalignment='center', verticalalignment='bottom', - bbox=dict(facecolor='white', alpha=0.8, edgecolor='white', - color='white')) + bbox=dict(facecolor='white', alpha=0.8, edgecolor='white')) pl.xlim(0, len(stats)) pl.ylabel("Number of submissions") pl.savefig('%s/sw_%s.png' % (destdir, typ), format='png', dpi=80) def mkpic_rating_by_os(db, env, items, destdir, title): - pl.figure(figsize=(6.4, 4.8), facecolor='w', edgecolor='k') + pl.figure(figsize=(6.4, 4.8)) for i, os in enumerate(os_order): ratings = [db.select_match(env, os_family[os]).get_not_none('%s' % (it,))[0] diff --git a/survey/surveycollector.cgi b/survey/surveycollector.cgi index 6ab3f33..4cd491a 100755 --- a/survey/surveycollector.cgi +++ b/survey/surveycollector.cgi @@ -83,7 +83,7 @@ def main(): result['success'] = True result = extract_results(form, result) try: - logfile = open('/home/neurodebian/surveydata/%s.json' % result['timestamp'], 'w+') + logfile = open('/home/neurodebian/survey/data/%s.json' % result['timestamp'], 'w+') logfile.write(json.write(result)) logfile.write('\n') logfile.close() @@ -92,7 +92,7 @@ def main(): result['message'] = 'We are very sorry, but the server is unable to store your submission. Please contact team@neuro.debian.net.' # send HTML snippet to let the submitter see the results try: - result['results'] = open('/home/www/neuro.debian.net/www/survey/results_snippet.html').read() + result['results'] = open('/home/neurodebian/survey/results_snippet.html').read() except: result['results'] = 'We are very sorry, but the statistics could not be displayed. Please contact team@neuro.debian.net to get access.' else: -- 2.39.2