gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r25777 - in gnunet-planetlab/gplmt: . gplmt


From: gnunet
Subject: [GNUnet-SVN] r25777 - in gnunet-planetlab/gplmt: . gplmt
Date: Mon, 14 Jan 2013 14:31:35 +0100

Author: wachs
Date: 2013-01-14 14:31:35 +0100 (Mon, 14 Jan 2013)
New Revision: 25777

Modified:
   gnunet-planetlab/gplmt/gplmt.py
   gnunet-planetlab/gplmt/gplmt/Tasks.py
   gnunet-planetlab/gplmt/gplmt/Worker.py
Log:
added: run cmd given as arg


Modified: gnunet-planetlab/gplmt/gplmt/Tasks.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt/Tasks.py       2013-01-14 13:12:40 UTC (rev 
25776)
+++ gnunet-planetlab/gplmt/gplmt/Tasks.py       2013-01-14 13:31:35 UTC (rev 
25777)
@@ -263,6 +263,25 @@
         self.l = list ()
         self.startid = startid
         self.startid_found = False
+    def load_singletask (self, cmd, logger):
+        t = Task()
+        self.name = "Execute single command"
+        
+        t.id = 0
+        t.name = "Executing single command: '" +str(cmd)+"'" 
+        t.type = Operation.run
+        t.command = cmd
+        t.timeout = 0
+        t.expected_return_code = -1
+        t.expected_output = None
+        t.stop_on_fail = True
+        t.set = None
+        t.src = None
+        t.dest = None
+        t.command_file = None
+        t.output_prefix = None
+        
+        self.l.append(t)
     def load (self):        
         self.logger.log ("Loading tasks file '" + self.filename + "'")
         enabled = True

Modified: gnunet-planetlab/gplmt/gplmt/Worker.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt/Worker.py      2013-01-14 13:12:40 UTC (rev 
25776)
+++ gnunet-planetlab/gplmt/gplmt/Worker.py      2013-01-14 13:31:35 UTC (rev 
25777)
@@ -170,13 +170,13 @@
                     data = r[0].recv(4096)
                     if data:
                         got_data = True
-                        #g_logger.log ('STDOUT: ' + data)
+                        g_logger.log (self.node + " : " + data)
                         stdout_data += data
                 if channel.recv_stderr_ready():
                     data = r[0].recv_stderr(4096)
                     if data:
                         got_data = True
-                        #g_logger.log ('STDERR: ' + data)
+                        g_logger.log (self.node + " : " + data)
                         stderr_data += data
                 if not got_data:
                     break

Modified: gnunet-planetlab/gplmt/gplmt.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt.py     2013-01-14 13:12:40 UTC (rev 25776)
+++ gnunet-planetlab/gplmt/gplmt.py     2013-01-14 13:31:35 UTC (rev 25777)
@@ -64,6 +64,7 @@
     config_file = None    
     pl_use_nodes = False
     verbose = False
+    command = None
     startid = -1
 
     try:
@@ -85,7 +86,7 @@
     # Parse command line arguments
         
         try:
-            opts, args = getopt.getopt(sys.argv[1:], "hvVc:n:t:ap:s:H:", 
["help", "verbose", "config=", "nodes=", "tasks=", "all", "password", 
"startid", "host"])
+            opts, args = getopt.getopt(sys.argv[1:], "C:hvVc:n:t:ap:s:H:", 
["help", "verbose", "config=", "nodes=", "tasks=", "command=", "all", 
"password", "startid", "host"])
         except getopt.GetoptError, err:
             # print help information and exit:
             print str(err) # will print something like "option -a not 
recognized"
@@ -109,6 +110,8 @@
                 pl_use_nodes = True
             elif o in ("-p", "--password"):
                 pl_password = a
+            elif o in ("-C", "--command"):
+                command = a                
             elif o in ("-s", "--startid"):
                 startid = a                                        
             else:
@@ -174,9 +177,14 @@
             sys.exit(8)        
     
        # Load actions file
-        tasks = Tasks.Tasks (configuration.taskfile, main.logger, startid);
-        if (tasks.load() == False):
-            sys.exit(2)        
+        if (None == command):
+            tasks = Tasks.Tasks (configuration.taskfile, main.logger, startid);
+            if (tasks.load() == False):
+                sys.exit(2)  
+        else:      
+            print "Running single command : " + str (command)
+            tasks = Tasks.Tasks (configuration.taskfile, main.logger, startid);
+            tasks.load_singletask(command, main.logger) 
     
        # Set up notification
         if (configuration.notifications == "simple"):
@@ -207,6 +215,7 @@
   -c, --config=FILENAME      use configuration file FILENAME\n\
   -n, --nodes=FILENAME       use node file FILENAME\n\
   -t, --tasks=FILENAME       use tasks file FILENAME\n\
+  -C, --command=             run single command instead of taskfile, print 
output using -v\n\
   -a, --all                  use all nodes assigned to PlanetLab slice instead 
of nodes file\n\
   -p, --password             password to access PlanetLab API\n\
   -H, --host                 run tasklist on given host\n\




reply via email to

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