gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r14294 - gauger


From: gnunet
Subject: [GNUnet-SVN] r14294 - gauger
Date: Mon, 31 Jan 2011 14:46:38 +0100

Author: bartpolot
Date: 2011-01-31 14:46:37 +0100 (Mon, 31 Jan 2011)
New Revision: 14294

Modified:
   gauger/gauger-cli.c
   gauger/gauger-cli.py
   gauger/gauger.py
Log:
Fixed copied code, added extra checks, started server refactor

Modified: gauger/gauger-cli.c
===================================================================
--- gauger/gauger-cli.c 2011-01-31 12:32:27 UTC (rev 14293)
+++ gauger/gauger-cli.c 2011-01-31 13:46:37 UTC (rev 14294)
@@ -6,12 +6,13 @@
 
 void gauger_log(char *counter, int value) {
     char __gauger_s[32];
-    char __gauger_p;
+    pid_t __gauger_p;
 
     if( ! (__gauger_p = fork()) ) {
         if(!fork()){
             sprintf(__gauger_s, "%d", value);
-            execl("gauger-cli.py", counter, __gauger_s, NULL);
+            execlp("gauger-cli.py", counter, __gauger_s, NULL);
+            perror("gauger exec: ");
             _exit(1);
         } else {
             _exit(0);

Modified: gauger/gauger-cli.py
===================================================================
--- gauger/gauger-cli.py        2011-01-31 12:32:27 UTC (rev 14293)
+++ gauger/gauger-cli.py        2011-01-31 13:46:37 UTC (rev 14294)
@@ -24,10 +24,12 @@
 """
 import socket
 import sys
+import os
 import subprocess
 
 def svnversion():
-    p = subprocess.Popen("svnversion", shell=True, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
+    p = subprocess.Popen("svnversion", shell=True,
+      stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (stdout, stderr) = p.communicate()
     x = 1
     while (stdout[0:x].isdigit()):
@@ -45,8 +47,13 @@
   configfile = open("gauger-cli.conf", "r")
   remotehost, username, password = configfile.readline().strip().split()
 except:
-  print "please put 'remotehost username password' in gauger-cli.conf"
-  exit(1)
+  try:
+      homefilename = os.path.join(os.path.expanduser('~'), ".gauger-cli.conf")
+      configfile = open(homefilename, "r")
+      remotehost, username, password = configfile.readline().strip().split()
+  except:
+    print "please put 'remotehost username password' in gauger-cli.conf"
+    exit(1)
   
 revision = svnversion()
 

Modified: gauger/gauger.py
===================================================================
--- gauger/gauger.py    2011-01-31 12:32:27 UTC (rev 14293)
+++ gauger/gauger.py    2011-01-31 13:46:37 UTC (rev 14294)
@@ -40,7 +40,7 @@
     print "ERROR: please create 'gauger.conf' with 'user password hostname'"
     return ''
   for line in file.readlines():
-    if (line[0] == '#'):
+    if (line[0] == '#' or line[0] == ' '):
       continue
     u, p, h = line.split()
     if(u == user and p == password):
@@ -49,6 +49,10 @@
   file.close()
   return ''
 
+def add_data_to_file(datafile, revision, result):
+  datafile.seek(0, 2)
+  datafile.write(revision + ' ' + result + "\n")
+
 s1 = socket(AF_INET, SOCK_STREAM)
 s1.bind(("0.0.0.0", 10111))
 s1.listen(5)
@@ -64,16 +68,23 @@
     print "ERROR: malformed data", data.strip()
     continue
   hostname = gethostfromlogin(user, password)
+  if (not hostname):
+    print "ERROR: username/password not correct"
+    continue
   if (not os.path.exists(hostname)):
     os.mkdir(hostname)
     print "Created new host directory: ", hostname
   if (not os.access(hostname, os.W_OK) or not os.path.isdir(hostname)):
     print "Not a directory or not writable: ", hostname
     continue
+  #TODO:
+  # - ~sort
+  # - add
+  # - calculate avg, stddev
+  # - write to tmpfile
+  # - plot tmpfile
   datafile = open(hostname + '/' + dataname, "a+")
-  datafile.seek(0, 2)
-  datafile.write(revision + ' ' + result + "\n")
+  add_data_to_file(datafile, revision, result);
+  #create_avg_file(datafile)
   datafile.close()
   updateplot(hostname, dataname)
-
-




reply via email to

[Prev in Thread] Current Thread [Next in Thread]