From: Michael Tremer Date: Sun, 1 Aug 2010 10:22:07 +0000 (+0200) Subject: Remove unused stuff. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2dcbbcadc732079603cf9e9b8e9c0c98f97d1bb1;p=ipfire.org.git Remove unused stuff. --- diff --git a/www/static/js/cluster.js b/www/static/js/cluster.js deleted file mode 100644 index 8aaee75d..00000000 --- a/www/static/js/cluster.js +++ /dev/null @@ -1,65 +0,0 @@ -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 = ""; - row += " "; - row += " " + node.arch + ""; - row += " "; - row += " "; - row += " " + node.speed + ""; - row += ""; - $("#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); -}) diff --git a/www/static/js/jquery.progressbar.js b/www/static/js/jquery.progressbar.js deleted file mode 100644 index 54229d21..00000000 --- a/www/static/js/jquery.progressbar.js +++ /dev/null @@ -1,19 +0,0 @@ - -(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.incrementconfig.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 diff --git a/www/templates/static/cluster.html b/www/templates/static/cluster.html deleted file mode 100644 index b5d4cea2..00000000 --- a/www/templates/static/cluster.html +++ /dev/null @@ -1,35 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Cluster") }}{% end block %} - -{% block content %} -

{{ _("Icecream Cluster Monitoring") }}

- -

{{ _("Cluster's CPU load") }}: - - - {{ _("Job load") }}: - -

- - - - - - - - - - - - - -
{{ _("Name") }}{{ _("Arch") }}{{ _("CPU-Load") }}{{ _("Jobs") }}{{ _("Speed") }}
- -

 
{{ _("Number of nodes") }}: -

- -{% end block %} - -{% block javascript %} - - -{% end block %} diff --git a/www/templates/translations.html b/www/templates/translations.html deleted file mode 100644 index 549abb5b..00000000 --- a/www/templates/translations.html +++ /dev/null @@ -1,55 +0,0 @@ -{% extends "base.html" %} - -{% block title %}{{ _("Translations") }}{% end block %} - -{% block content %} -

IPFire {{ _("Translation Status") }}

- -
- -
- - {% for project in projects %} -
-

{{ _("Description") }}: {{ project.desc }}

-
- - - - - - - - - - {% for translation in project.translations %} - - - - - - - - {% end %} -
{{ _("Language") }}{{ _("Translated") }}{{ _("Untranslated") }}{{ _("Fuzzy") }}{{ _("Status") }}
{{ translation.code }}{{ translation.lang }}{{ translation.translated }}{{ translation.untranslated }}{{ translation.fuzzy }}{{ translation.percent }}
- {% end %} - -

- {{ _("Template") }} - {{ project.total_strings }} strings -

-{% end block %} - -{% block javascript %} - -{% end block %} diff --git a/www/webapp/__init__.py b/www/webapp/__init__.py index b3d38d07..905d6579 100644 --- a/www/webapp/__init__.py +++ b/www/webapp/__init__.py @@ -58,7 +58,6 @@ class Application(tornado.web.Application): (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), @@ -68,8 +67,6 @@ class Application(tornado.web.Application): # 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) diff --git a/www/webapp/cluster.py b/www/webapp/cluster.py deleted file mode 100644 index 7afc2977..00000000 --- a/www/webapp/cluster.py +++ /dev/null @@ -1,149 +0,0 @@ -#!/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 "" % 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() diff --git a/www/webapp/handlers.py b/www/webapp/handlers.py index 88944e23..1c29bc71 100644 --- a/www/webapp/handlers.py +++ b/www/webapp/handlers.py @@ -23,9 +23,7 @@ from news import news from releases import releases import builds -import cluster import menu -import translations #import uriel class BaseHandler(tornado.web.RequestHandler): @@ -196,25 +194,6 @@ class UrielHandler(UrielBaseHandler): 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" diff --git a/www/webapp/translations.py b/www/webapp/translations.py deleted file mode 100644 index af44823c..00000000 --- a/www/webapp/translations.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/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."), -]