+++ /dev/null
-nodes = new Array();
-id = 0;
-busy = false;
-
-update = function() {
- $.getJSON("/api/cluster_info", { id : id++ },
- function(data) {
- // If we are already busy then exit
- if (busy == true) return;
-
- var count = 0;
-
- if (data.error != "null") return;
-
- busy = true;
-
- $.each(data.result.nodes, function(i, node) {
- var nodeid = node.hostname.replace(/\./g, "");
- count++;
-
- nodes[nodeid] = true;
-
- if ($("#" + nodeid).length) {
- $("#" + nodeid + "_speed").html(node.speed);
- } else {
- row = "<tr id=\"" + nodeid + "\" class=\"node\">";
- row += " <td id=\"" + nodeid + "_hostname\"></td>";
- row += " <td id=\"" + nodeid + "_arch\">" + node.arch + "</td>";
- row += " <td><span id=\"" + nodeid + "_loadbar\"></span></td>";
- row += " <td><span id=\"" + nodeid + "_jobs\"></span></td>";
- row += " <td id=\"" + nodeid + "_speed\">" + node.speed + "</td>";
- row += "</tr>";
- $("#nodes").append(row);
- }
- $("#" + nodeid + "_loadbar").progressBar(node.load, {showText: false});
- $("#" + nodeid + "_jobs").progressBar(node.jobcount.split("/")[0], { max: node.jobcount.split("/")[1], textFormat: 'fraction'});
- if (node.installing == true) {
- $("#" + nodeid + "_hostname").html(node.hostname + " *");
- } else {
- $("#" + nodeid + "_hostname").html(node.hostname);
- }
- });
-
- $("#loadbar").progressBar(data.result.cluster.load);
- $("#jobbar").progressBar(data.result.cluster.jobcount.split("/")[0], { max: data.result.cluster.jobcount.split("/")[1], textFormat: 'fraction'});
- for (var nodeid in nodes) {
- if (nodes[nodeid] == false) {
- $("#" + nodeid).remove();
- nodes.pop(nodeid);
- } else {
- nodes[nodeid] = false;
- }
- }
- $("#count").html(count);
- busy = false;
- });
-}
-
-$(document).ready(function(){
- // Init loadbar
- $("#loadbar").progressBar();
-
- update();
- setInterval("update()", 2000);
-})
+++ /dev/null
-
-(function($){$.extend({progressBar:new function(){this.defaults={steps:20,step_duration:20,max:100,showText:true,textFormat:'percentage',width:120,height:12,callback:null,boxImage:'/static/images/progressbar.gif',barImage:{0:'/static/images/progressbg_green.gif',30:'/static/images/progressbg_orange.gif',70:'/static/images/progressbg_red.gif'},running_value:0,value:0,image:null};this.construct=function(arg1,arg2){var argvalue=null;var argconfig=null;if(arg1!=null){if(!isNaN(arg1)){argvalue=arg1;if(arg2!=null){argconfig=arg2;}}else{argconfig=arg1;}}
-return this.each(function(child){var pb=this;var config=this.config;if(argvalue!=null&&this.bar!=null&&this.config!=null){this.config.value=argvalue
-if(argconfig!=null)
-pb.config=$.extend(this.config,argconfig);config=pb.config;}else{var $this=$(this);var config=$.extend({},$.progressBar.defaults,argconfig);config.id=$this.attr('id')?$this.attr('id'):Math.ceil(Math.random()*100000);if(argvalue==null)
-argvalue=$this.html().replace("%","")
-config.value=argvalue;config.running_value=0;config.image=getBarImage(config);$this.html("");var bar=document.createElement('img');var text=document.createElement('span');var $bar=$(bar);var $text=$(text);pb.bar=$bar;$bar.attr('id',config.id+"_pbImage");$text.attr('id',config.id+"_pbText");$text.html(getText(config));$bar.attr('title',getText(config));$bar.attr('alt',getText(config));$bar.attr('src',config.boxImage);$bar.attr('width',config.width);$bar.css("width",config.width+"px");$bar.css("height",config.height+"px");$bar.css("background-image","url("+config.image+")");$bar.css("background-position",((config.width*-1))+'px 50%');$bar.css("padding","0");$bar.css("margin","0");$this.append($bar);$this.append($text);}
-function getPercentage(config){return parseInt(config.running_value*100/config.max);}
-function getBarImage(config){var image=config.barImage;if(typeof(config.barImage)=='object'){for(var i in config.barImage){if(config.running_value>=parseInt(i)){image=config.barImage[i];}else{break;}}}
-return image;}
-function getText(config){if(config.showText){if(config.textFormat=='percentage'){return" "+Math.round(config.running_value)+"%";}else if(config.textFormat=='fraction'){return" "+config.running_value+'/'+config.max;}}}
-config.increment=Math.round((config.value-config.running_value)/config.steps);if(config.increment<0)
-config.increment*=-1;if(config.increment<1)
-config.increment=1;var t=setInterval(function(){var pixels=config.width/100;var stop=false;if(config.running_value>config.value){if(config.running_value-config.increment<config.value){config.running_value=parseInt(config.value);}else{config.running_value-=config.increment;}}
-else if(config.running_value<config.value){if(config.running_value+config.increment>config.value){config.running_value=parseInt(config.value);}else{config.running_value+=config.increment;}}
-if(config.running_value==config.value)
-clearInterval(t);var $bar=$("#"+config.id+"_pbImage");var $text=$("#"+config.id+"_pbText");var image=getBarImage(config);if(image!=config.image){$bar.css("background-image","url("+image+")");config.image=image;}
-$bar.css("background-position",(((config.width*-1))+(getPercentage(config)*pixels))+'px 50%');$text.html(getText(config));if(config.callback!=null&&typeof(config.callback)=='function')
-config.callback(config);pb.config=config;},config.step_duration);});};}});$.fn.extend({progressBar:$.progressBar.construct});})(jQuery);
\ No newline at end of file
+++ /dev/null
-{% extends "../base.html" %}
-
-{% block title %}{{ _("Cluster") }}{% end block %}
-
-{% block content %}
- <h3>{{ _("Icecream Cluster Monitoring") }}</h3>
-
- <p>{{ _("Cluster's CPU load") }}:
- <span id="loadbar"></span>
- - {{ _("Job load") }}:
- <span id="jobbar"></span>
- </p>
-
- <table id="nodes">
- <thead>
- <tr>
- <th class="hostname">{{ _("Name") }}</th>
- <th class="arch">{{ _("Arch") }}</th>
- <th class="load">{{ _("CPU-Load") }}</th>
- <th class="jobs">{{ _("Jobs") }}</th>
- <th class="speed">{{ _("Speed") }}</th>
- </tr>
- </thead>
- <tbody>
- </tbody>
- </table>
-
- <p class="right"> <br />{{ _("Number of nodes") }}: <span id="count">-</span></p>
-
-{% end block %}
-
-{% block javascript %}
- <script type="text/javascript" src="{{ static_url("js/jquery.progressbar.js") }}"></script>
- <script type="text/javascript" src="{{ static_url("js/cluster.js") }}"></script>
-{% end block %}
+++ /dev/null
-{% extends "base.html" %}
-
-{% block title %}{{ _("Translations") }}{% end block %}
-
-{% block content %}
- <h3>IPFire {{ _("Translation Status") }}</h3>
-
- <div id="tabs">
- <ul>
- {% for project in projects %}
- <li>
- <a href="#{{ project.id }}">{{ project.name }}</a>
- </li>
- {% end %}
- </ul>
- </div>
-
- {% for project in projects %}
- <div id="{{ project.id }}">
- <p><strong>{{ _("Description") }}:</strong> {{ project.desc }}</p>
- <br />
- <table class="translate">
- <tr>
- <th>{{ _("Language") }}</th>
- <th>{{ _("Translated") }}</th>
- <th>{{ _("Untranslated") }}</th>
- <th>{{ _("Fuzzy") }}</th>
- <th>{{ _("Status") }}</th>
- </tr>
-
- {% for translation in project.translations %}
- <tr>
- <td class="lang"><img src="{{ static_url("images/flags/%s.png" % translation.code) }}"
- alt="{{ translation.code }}" />{{ translation.lang }}</td>
- <td>{{ translation.translated }}</td>
- <td>{{ translation.untranslated }}</td>
- <td>{{ translation.fuzzy }}</td>
- <td>{{ translation.percent }}</td>
- </tr>
- {% end %}
- </table>
- {% end %}
-
- <p class="right">
- <strong>{{ _("Template") }}</strong> - {{ project.total_strings }} strings
- </p>
-{% end block %}
-
-{% block javascript %}
- <script type="text/javascript">
- $(function() {
- $("#tabs").tabs();
- });
- </script>
-{% end block %}
(r"/[A-Za-z]{2}/index", IndexHandler),
(r"/[A-Za-z]{2}/news", NewsHandler),
(r"/[A-Za-z]{2}/builds", BuildHandler),
- (r"/[A-Za-z]{2}/translations?", TranslationHandler),
# Download sites
(r"/[A-Za-z]{2}/downloads?", DownloadHandler),
(r"/[A-Za-z]{2}/downloads?/all", DownloadAllHandler),
# RSS feed
(r"/([A-Za-z]{2})/news.rss", RSSHandler),
(r"/data/feeds/main-([A-Za-z]{2}).rss", RSSHandler),
- # API
- (r"/api/cluster_info", ApiClusterInfoHandler),
# Always the last rule
(r"/[A-Za-z]{2}/(.*)", StaticHandler),
] + static_handlers)
+++ /dev/null
-#!/usr/bin/python
-
-import os
-import telnetlib
-
-class Node(object):
- def __init__(self, hostname, address, arch, speed, jobcount, load, installing):
- self.hostname = hostname
- self.address = address
- self.arch = arch
- self.speed = speed
- self.installing = installing
-
- (jobs_cur, jobs_max) = jobcount.split("/")
- if jobs_cur > jobs_max:
- jobs_cur = jobs_max
- self.jobcount = "%s/%s" % (jobs_cur, jobs_max)
-
- self.load = int(load) / 10 # in percent
-
- self.jobs = []
-
- def __str__(self):
- return self.hostname
-
- def __repr__(self):
- return "<Node %s>" % self.hostname
-
- def __cmp__(self, other):
- return cmp(self.hostname, other.hostname)
-
- def print_node(self):
- print "Hostname : %s" % self.hostname
- print " Address: %s" % self.address
- print " Arch : %s" % self.arch
- print " Speed : %s" % self.speed
- print " Jobs : %s" % self.jobcount
- print " Load : %s" % self.load
-
-class Job(object):
- def __init__(self, id, status, submitter, compiler, file):
- self.id = id
- self.status = status
- self.submitter = submitter
- self.compiler = compiler
- self.file = file
-
-
-class Cluster(object):
- def __init__(self, scheduler, port=8766):
- self.scheduler = scheduler
- self.port = port
-
- self._nodes = None
-
- def command(self, command):
- connection = telnetlib.Telnet(self.scheduler, self.port)
- connection.read_until("quit.\n")
- connection.write("%s\nquit\n" % command)
- return connection.read_until("200 done").split("\n")
-
- @property
- def load(self):
- if not self.nodes:
- return 0
- load = 0
- for node in self.nodes:
- load += node.load
- load /= len(self.nodes)
- return load
-
- @property
- def jobcount(self):
- jobs_cur = jobs_max = 0
- for node in self.nodes:
- jobs_cur += int(node.jobcount.split("/")[0])
- jobs_max += int(node.jobcount.split("/")[1])
- return "%s/%s" % (jobs_cur, jobs_max)
-
- @property
- def nodes(self):
- if self._nodes:
- return self._nodes
- ret = []
- data = self.command("listcs")
- node = None
- for line in data:
- if not line.startswith(" "):
- continue # does not belong to the data
-
- if line.startswith(" ") and node: # Job
- (a, b, c, id, status, submitter, compiler, file) = line.split(" ")
- submitter = submitter[4:]
- compiler = compiler[3:]
- file = os.path.basename(file)
- job = Job(id, status, submitter, compiler, file)
- node.jobs.append(job)
-
- elif line.startswith(" "): # Node
- installing = False
- a = line.split(" ")
- if len(a) > 7:
- installing = True
- line = " ".join(a[0:7])
-
- (a, hostname, address, arch, speed, jobcount, load) = line.split(" ")
- address = address.strip("()")
- arch = arch.strip("[]")
- speed = speed[6:]
- jobcount = jobcount[5:]
- load = load[5:]
- node = Node(hostname, address, arch, speed, jobcount, load, installing)
- ret.append(node)
-
- self._nodes = sorted(ret)
- return ret
-
- @property
- def json(self, *args):
- nodes = []
- ret = {}
- for node in self.nodes:
- tmp = { "hostname" : node.hostname,
- "address" : node.address,
- "arch" : node.arch,
- "jobcount" : node.jobcount,
- "load" : node.load,
- "speed" : node.speed,
- "installing" : node.installing,}
- jobs = []
- for job in node.jobs:
- jobs.append({ "id" : job.id,
- "status" : job.status,
- "submitter" : job.submitter,
- "compiler" : job.compiler,
- "file" : job.file, })
- tmp["jobs"] = jobs
- nodes.append(tmp)
- ret["nodes"] = nodes
- ret["cluster"] = { "load" : self.load,
- "jobcount" : self.jobcount, }
- return ret
-
-
-if __name__ == "__main__":
- cluster = Cluster("minerva.ipfire.org")
- print cluster.command("listcs")
- for node in cluster.nodes:
- node.print_node()
from releases import releases
import builds
-import cluster
import menu
-import translations
#import uriel
class BaseHandler(tornado.web.RequestHandler):
pass
-class ApiClusterInfoHandler(BaseHandler):
- def get(self):
- id = self.get_argument("id", "null")
-
- c = cluster.Cluster(info["cluster"]["hostname"])
-
- self.write(simplejson.dumps({
- "version": "1.1",
- "id": id,
- "result" : c.json,
- "error" : "null", }))
- self.finish()
-
-
-class TranslationHandler(BaseHandler):
- def get(self):
- self.render("translations.html", projects=translations.projects)
-
-
class SourceHandler(BaseHandler):
def get(self):
source_path = "/srv/sources"
+++ /dev/null
-#!/usr/bin/python
-
-import os
-
-import tornado.locale
-
-class Po(object):
- def __init__(self, path, project):
- self.path = path
- self.project = project
-
- p = os.popen("msgfmt -v --statistics %s 2>&1" % self.path)
- self.line = p.readlines()[0]
-
- def __cmp__(self, other):
- return cmp(self.lang, other.lang)
-
- @property
- def code2lang(self):
- ret = {}
- for lang in tornado.locale.LOCALE_NAMES.keys():
- ret[lang[:2]] = "%(name)s (%(name_en)s)" % tornado.locale.LOCALE_NAMES[lang]
- return ret
-
- @property
- def code(self):
- return os.path.basename(self.path)[:-3]
-
- @property
- def lang(self):
- return self.code2lang.get(self.code, "Unknown (%s)" % self.code)
-
- @property
- def translated(self):
- return int(self.line.split()[0])
-
- @property
- def untranslated(self):
- l = self.line.split()
- if len(l) == 6:
- return int(l[3])
- elif len(l) == 9:
- return int(l[6])
- return 0
-
- @property
- def fuzzy(self):
- l = self.line.split()
- if len(l) == 9:
- return l[3]
- return 0
-
- @property
- def percent(self):
- if not self.project.total_strings:
- return "---.-- %"
-
- return "%3.1f%%" % (self.translated * 100 / self.project.total_strings)
-
-
-class Project(object):
- def __init__(self, id, path, **kwargs):
- self.id = id
- self.path = path
- self._name = kwargs.pop("name")
- self.desc = kwargs.pop("desc")
-
- self._translations = []
- self.pot = None
- self.find_pot()
-
- @property
- def name(self):
- if self._name:
- return self._name
- return self.id
-
- @property
- def translations(self):
- if not self._translations:
- for path in os.listdir(self.path):
- if path.endswith(".po"):
- self._translations.append(Po(os.path.join(self.path, path), self))
- self._translations.sort()
- return self._translations
-
- def find_pot(self):
- for path in os.listdir(self.path):
- if path.endswith(".pot"):
- self.pot = Po(os.path.join(self.path, path), self)
- break
-
- @property
- def total_strings(self):
- if not self.pot:
- return 0
- return self.pot.untranslated
-
-projects = [
- Project("pomona", "/srv/checkout/ipfire-3.x/src/pomona/po",
- name="Pomona", desc="The pomona installer for ipfire."),
-]