[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14433 - gauger
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14433 - gauger |
Date: |
Thu, 17 Feb 2011 04:09:36 +0100 |
Author: bartpolot
Date: 2011-02-17 04:09:36 +0100 (Thu, 17 Feb 2011)
New Revision: 14433
Modified:
gauger/ajax.php
gauger/explore.php
gauger/gauger.py
gauger/params.php
gauger/template.php
gauger/template_host.php
Log:
Added option to auto adjust range plotting, set default y origin to 0, fixed
problem with slash in counter name, fixed regex filtering, fixed gauger server
socket creation to reuse address
Modified: gauger/ajax.php
===================================================================
--- gauger/ajax.php 2011-02-16 16:54:23 UTC (rev 14432)
+++ gauger/ajax.php 2011-02-17 03:09:36 UTC (rev 14433)
@@ -3,12 +3,6 @@
include "explore.php";
include "params.php";
-foreach (Array('x_max', 'x_min', 'y_max', 'y_min') as $param_name) {
- if (array_key_exists($param_name, $_SESSION)) {
- echo "$param_name:$_SESSION[$param_name] ";
- }
- $$param_name = get_param($param_name, '', get_param('persist') == 'true');
- if(!is_numeric($$param_name)) $$param_name = '*';
-}
+process_range();
die("OK");
Modified: gauger/explore.php
===================================================================
--- gauger/explore.php 2011-02-16 16:54:23 UTC (rev 14432)
+++ gauger/explore.php 2011-02-17 03:09:36 UTC (rev 14433)
@@ -1,10 +1,12 @@
<?php
function get_counter_name($s) {
+ $s = str_replace('-SLASH-', '/', $s);
return preg_replace('/([^_]+).*/', '\1', $s);
}
function get_counter_unit($s) {
+ $s = str_replace('-SLASH-', '/', $s);
if(strpos($s, '_') !== FALSE)
return preg_replace('/.+_([^_]+)/', '\1', $s);
else
@@ -39,14 +41,13 @@
$hosts[$entry] = array();
$d2 = dir($entry);
while (false !== ($counter = $d2->read())) {
- if (preg_match("/[\.|~]/", $counter) === 0) { // Do not include
files containing dots or tildes
+ if (preg_match("/(\.|~)/", $counter) === 0) { // Do not include
files containing dots or tildes
$hosts[$entry][] = $counter;
}
}
}
}
$d->close();
-//echo '<pre>';
-//print_r(get_range("testhost", "c1_kbps"));
-//print_r(get_range('', ''));
-//die();
+// echo '<pre>';
+// print_r($hosts);
+// die();
Modified: gauger/gauger.py
===================================================================
--- gauger/gauger.py 2011-02-16 16:54:23 UTC (rev 14432)
+++ gauger/gauger.py 2011-02-17 03:09:36 UTC (rev 14433)
@@ -22,7 +22,7 @@
Gauger server.
"""
-from socket import socket, AF_INET, SOCK_STREAM
+from socket import socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR
import os
import glob
import math
@@ -75,7 +75,7 @@
def updateplot(host, data):
""" Regenerates the plot for a given host / counter combination """
- os.system("./plot.sh %s %s" % (host, data))
+ # os.system("./plot.sh %s %s" % (host, data))
def gethostfromlogin(user, password):
@@ -138,6 +138,7 @@
processedfile.close()
+""" ******************* MAIN ******************************** """
try:
f = open("global_range.dat", "r");
xrange_min,xrange_max = f.readline().split(' ');
@@ -148,6 +149,7 @@
create_global_range()
s1 = socket(AF_INET, SOCK_STREAM)
+s1.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
s1.bind(("0.0.0.0", 10111))
s1.listen(5)
while(True):
@@ -172,6 +174,7 @@
print "Not a directory or not writable: ", hostname
continue
+ dataname = dataname.replace('/', '-SLASH-');
try:
datafile = open(hostname + '/' + dataname, "r+")
except IOError:
Modified: gauger/params.php
===================================================================
--- gauger/params.php 2011-02-16 16:54:23 UTC (rev 14432)
+++ gauger/params.php 2011-02-17 03:09:36 UTC (rev 14433)
@@ -15,13 +15,32 @@
}
function get_session($name, $default = '') {
- if (array_key_exists($name, $_SESSION)) {
+ if (array_key_exists($name, $_SESSION) && $_SESSION[$name]) {
return $_SESSION[$name];
} else {
return $default;
}
}
+function process_range() {
+ foreach (Array('x_max', 'x_min', 'y_max', 'y_min') as $param_name) {
+ if (array_key_exists($param_name, $_SESSION)) {
+ $bck = $_SESSION[$param_name];
+ }
+ $$param_name = get_param($param_name, '', get_param('persist') ==
'true');
+ if(!is_numeric($$param_name)) {
+ if(get_param('persist') == 'true' && isset($bck)) {
+ $_SESSION[$param_name] = $bck;
+ }
+ $_SESSION[$param_name."_a"] = 1;
+ $$param_name = '*';
+ } else if(get_param('persist') == 'true') {
+ $_SESSION[$param_name."_a"] = 0;
+ }
+
+ }
+}
+
session_start();
if (get_param('logout')) {
@@ -45,6 +64,10 @@
$r = get_range('','');
$_SESSION['xrange_min'] = $r[0];
$_SESSION['xrange_max'] = $r[1];
+ $_SESSION['y_min'] = 0;
+ foreach (Array('x_max', 'x_min', 'y_max', 'y_min') as $param_name) {
+ $_SESSION[$param_name.'_a'] = 1;
+ }
}
// die("#".get_session("xrange_min", "default") ."#");
Modified: gauger/template.php
===================================================================
--- gauger/template.php 2011-02-16 16:54:23 UTC (rev 14432)
+++ gauger/template.php 2011-02-17 03:09:36 UTC (rev 14433)
@@ -29,6 +29,12 @@
if(this.id == "default_range_slider") {
$(".left-range").html(ui.values[0]);
$(".right-range").html(ui.values[1]);
+ if($(this).slider('values', 0) !=
ui.values[0]) {
+ $( ".auto_min" ).attr('checked',
false);
+ }
+ if($(this).slider('values', 1) !=
ui.values[1]) {
+ $( ".auto_max" ).attr('checked',
false);
+ }
$( ".slider-range" ).each(function(){
$(this).slider('values', 0,
ui.values[0]);
$(this).slider('values', 1,
ui.values[1]);
@@ -36,13 +42,21 @@
} else {
$(this).parents("tr").find(".left-range").html(ui.values[0]);
$(this).parents("tr").find(".right-range").html(ui.values[1]);
+ if($(this).slider('values', 0) !=
ui.values[0]) {
+ $(this).parents("tr").find(
".auto_min" ).attr('checked', false);
+ }
+ if($(this).slider('values', 1) !=
ui.values[1]) {
+ $(this).parents("tr").find(
".auto_max" ).attr('checked', false);
+ }
}
},
stop: function( event, ui ) {
if(this.id == "default_range_slider") {
+ min =
$(this).parents(".slider_control").find(".auto_min").attr('checked') ? "auto" :
$(this).slider('values', 0);
+ max =
$(this).parents(".slider_control").find(".auto_max").attr('checked') ? "auto" :
$(this).slider('values', 1);
$.get("ajax.php", {
- x_min: ui.values[0],
- x_max: ui.values[1],
+ x_min: min,
+ x_max: max,
persist: "true"
}, function(data) {
$( ".plot" ).each(function() {
@@ -51,8 +65,10 @@
}
);
} else {
+ min =
$(this).parents("tr").find(".auto_min").attr('checked') ? "auto" :
$(this).slider('values', 0);
+ max =
$(this).parents("tr").find(".auto_max").attr('checked') ? "auto" :
$(this).slider('values', 1);
$(this).parents("tr").find(".plot").each(function(){
- this.src =
this.src.replace(/&x_m(ax|in)=[^&]+/g,
'')+"&x_min="+ui.values[0]+"&x_max="+ui.values[1];
+ this.src =
this.src.replace(/&x_m(ax|in)=[^&]+/g, '')+"&x_min="+min+"&x_max="+max;
});
}
}
@@ -88,6 +104,34 @@
if(was == "none")
$( "#change_origin_control" ).show();
});
+ $( ".auto_min" ).click(function(){
+ if($(this).parents("#default_range_control").length > 0) {
+ $( ".auto_min" ).attr('checked', this.checked);
+ min = this.checked ? "auto" :
$(this).parents(".slider_control").find(".slider-range").slider('values', 0);
+ $( ".plot" ).each(function() {
+ this.src = this.src.replace(/&x_min=[^&]+/g,
'')+"&x_min="+min;
+ });
+ } else {
+ min = this.checked ? "auto" :
$(this).parents("tr").find(".slider-range").slider('values', 0);
+ $(this).parents("tr").find(".plot").each(function(){
+ this.src = this.src.replace(/&x_min=[^&]+/g,
'')+"&x_min="+min;
+ });
+ }
+ });
+ $( ".auto_max" ).click(function(){
+ if($(this).parents("#default_range_control").length > 0) {
+ $( ".auto_max" ).attr('checked', this.checked);
+ max = this.checked ? "auto" :
$(this).parents(".slider_control").find(".slider-range").slider('values', 1);
+ $( ".plot" ).each(function() {
+ this.src = this.src.replace(/&x_max=[^&]+/g,
'')+"&x_max="+max;
+ });
+ } else {
+ min = this.checked ? "auto" :
$(this).parents("tr").find(".slider-range").slider('values', 1);
+ $(this).parents("tr").find(".plot").each(function(){
+ this.src = this.src.replace(/&x_max=[^&]+/g,
'')+"&x_max="+max;
+ });
+ }
+ });
});
function get_command(element) {
@@ -97,10 +141,6 @@
});
}
- function ajax_handler() {
-
- }
-
function debug(param) {
$( "#debug" ).html($( "#debug" ).html() + param + ' ');
}
@@ -116,7 +156,11 @@
<div class="slider-range" id="default_range_slider"></div>
<div class="left-range"><?php echo get_session('x_min',
get_session('xrange_min', '0')) ?></div>
<div class="right-range"><?php echo get_session('x_max',
get_session('xrange_max', '0')) ?></div>
- <div class="auto_range"><input style="float:left"
type="checkbox"/>Auto<input style="float:right;" type="checkbox"/></div>
+ <div class="auto_range">
+ <input class="auto_min" type="checkbox" <?php
if(get_session('x_min_a')) echo 'checked="checked"'?>/>
+ Auto
+ <input class="auto_max" type="checkbox" <?php
if(get_session('x_max_a')) echo 'checked="checked"'?>/>
+ </div>
</div> |
<a href="#" id="change_origin" >Change Origin</a>
<div class="slider_control" id="change_origin_control">
Modified: gauger/template_host.php
===================================================================
--- gauger/template_host.php 2011-02-16 16:54:23 UTC (rev 14432)
+++ gauger/template_host.php 2011-02-17 03:09:36 UTC (rev 14433)
@@ -14,10 +14,15 @@
<br/>
<br/>Range
<br/>
- <div>
+ <div class="side_slider_control">
<div class="slider-range" id="other_slider" ></div>
- <div class="left-range"><?php echo get_session('x_min',
'0') ?></div>
- <div class="right-range"><?php echo get_session('x_max',
'100') ?></div>
+ <div class="left-range"><?php echo get_session('x_min',
get_session('xrange_min', '0')) ?></div>
+ <div class="right-range"><?php echo get_session('x_max',
get_session('xrange_max', '100')) ?></div>
+ <div class="auto_range">
+ <input class="auto_min" type="checkbox" <?php
if(get_session('x_min_a')) echo 'checked="checked"'?>/>
+ Auto
+ <input class="auto_max" type="checkbox" <?php
if(get_session('x_max_a')) echo 'checked="checked"'?>/>
+ </div>
</div>
<br/>
<br/><a href="#" onclick="get_command(this); return false;"
>Get Command</a>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14433 - gauger,
gnunet <=