gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r14165 - gauger


From: gnunet
Subject: [GNUnet-SVN] r14165 - gauger
Date: Fri, 14 Jan 2011 02:06:44 +0100

Author: bartpolot
Date: 2011-01-14 02:06:44 +0100 (Fri, 14 Jan 2011)
New Revision: 14165

Added:
   gauger/gauger-cli.py
Modified:
   gauger/gauger.py
Log:
Added a gauger client and plaintext file login

Added: gauger/gauger-cli.py
===================================================================
--- gauger/gauger-cli.py                                (rev 0)
+++ gauger/gauger-cli.py        2011-01-14 01:06:44 UTC (rev 14165)
@@ -0,0 +1,24 @@
+#!/usr/bin/env python2
+import socket
+import sys
+
+if (len(sys.argv) != 4):
+  print "usage:", sys.argv[0], "counter revision value"
+  exit(1)
+
+try:
+  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)
+
+s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+try:
+  s1.connect((remotehost, 1111))
+except:
+  print "ERROR: Couldn't connect to", remotehost
+  exit(1)
+l1 = [username, password]
+l1.extend(sys.argv[1:])
+s1.send(",".join(l1))
\ No newline at end of file


Property changes on: gauger/gauger-cli.py
___________________________________________________________________
Added: svn:executable
   + *

Modified: gauger/gauger.py
===================================================================
--- gauger/gauger.py    2011-01-13 20:43:54 UTC (rev 14164)
+++ gauger/gauger.py    2011-01-14 01:06:44 UTC (rev 14165)
@@ -1,11 +1,26 @@
 #!/usr/bin/env python2
 from socket import socket, AF_INET, SOCK_STREAM
 import os
-import csv
 
 def updateplot(host, data):
   filename = host + '/' + data
   os.system("gnuplot -e 'set terminal png; set output \"" + filename + 
".png\"; plot \"" + filename + "\" using 2:xticlabel(1) with line title \"" + 
host + ", " + data + "\" lw 3 lt rgb \"green\" '")
+  
+def gethostfromlogin(user, password):
+  try:
+    file = open("gauger.conf", "r")
+  except:
+    print "ERROR: please create 'gauger.conf' with 'user password hostname'"
+    return ''
+  for line in [file.readlines()]:
+    if (line[0] == '#'):
+      continue
+    u, p, h = line.split()
+    if(u == user and p == password):
+      file.close()
+      return h
+  file.close()
+  return ''
 
 s1 = socket(AF_INET, SOCK_STREAM)
 s1.bind(("0.0.0.0", 1111))
@@ -16,8 +31,12 @@
   print address
   data = s2.recv(4096)
   s2.close()
-  print data.split(',')
-  hostname, dataname, revision, result = data.strip().split(',')
+  try:
+    user,password, dataname, revision, result = data.strip().split(',')
+  except:
+    print "ERROR: malformed data", data.strip()
+    continue
+  hostname = gethostfromlogin(user, password)
   if (not os.path.exists(hostname)):
     os.mkdir(hostname)
     print "Created new host directory: ", hostname




reply via email to

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