[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24806 - gnunet-planetlab/gplmt
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24806 - gnunet-planetlab/gplmt |
Date: |
Tue, 6 Nov 2012 15:12:04 +0100 |
Author: wachs
Date: 2012-11-06 15:12:04 +0100 (Tue, 06 Nov 2012)
New Revision: 24806
Modified:
gnunet-planetlab/gplmt/gplmt.py
Log:
- getpass and interupt mgmt
Modified: gnunet-planetlab/gplmt/gplmt.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt.py 2012-11-06 13:47:05 UTC (rev 24805)
+++ gnunet-planetlab/gplmt/gplmt.py 2012-11-06 14:12:04 UTC (rev 24806)
@@ -49,7 +49,7 @@
import gplmt.Tasks as Tasks
import gplmt.Worker as Worker
import gplmt.Notifications as Notifications
- import getopt
+ import getopt, getpass
except ImportError as e:
print "That's a bug! please check README: " + str (e)
@@ -57,129 +57,136 @@
def main():
global main
- main = Main ()
-
-# Init
- main.pl_password = None
-
-# Check dependencies
- if (False == elementtree_loaded):
- print "ElementTree XML parsing module is required for execution,
please check README"
- sys.exit(2)
- if (False == paramiko_loaded):
- print "paramiko SSH module is required for execution, please check
README"
- sys.exit(2)
- if (False == minixsv_loaded):
- print "minixsv module is required for execution, please check README"
- sys.exit(2)
-
-# Parse command line arguments
-
try:
- opts, args = getopt.getopt(sys.argv[1:], "hvc:n:t:ap:s:H:", ["help",
"config=", "nodes=", "tasks=", "all", "password", "startid", "host"])
- except getopt.GetoptError, err:
- # print help information and exit:
- print str(err) # will print something like "option -a not recognized"
- usage()
- sys.exit(2)
- for o, a in opts:
- if o == "-v":
- main.verbose = True
- elif o in ("-h", "--help"):
+ main = Main ()
+
+ # Init
+ main.pl_password = None
+
+ # Check dependencies
+ if (False == elementtree_loaded):
+ print "ElementTree XML parsing module is required for execution,
please check README"
+ sys.exit(2)
+ if (False == paramiko_loaded):
+ print "paramiko SSH module is required for execution, please check
README"
+ sys.exit(2)
+ if (False == minixsv_loaded):
+ print "minixsv module is required for execution, please check
README"
+ sys.exit(2)
+
+ # Parse command line arguments
+
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "hvc:n:t:ap:s:H:",
["help", "config=", "nodes=", "tasks=", "all", "password", "startid", "host"])
+ except getopt.GetoptError, err:
+ # print help information and exit:
+ print str(err) # will print something like "option -a not
recognized"
usage()
- sys.exit()
- elif o in ("-c", "--config"):
- main.config_file = Util.handle_filename(a)
- elif o in ("-H", "--host"):
- main.single_host = a
- elif o in ("-n", "--nodes"):
- main.nodes_file = Util.handle_filename(a)
- elif o in ("-t", "--tasks"):
- main.tasks_file = Util.handle_filename(a)
- elif o in ("-a", "--all"):
- main.pl_use_nodes = True
- elif o in ("-p", "--password"):
- main.pl_password = a
- elif o in ("-s", "--startid"):
- main.startid = a
+ sys.exit(2)
+ for o, a in opts:
+ if o == "-v":
+ main.verbose = True
+ elif o in ("-h", "--help"):
+ usage()
+ sys.exit()
+ elif o in ("-c", "--config"):
+ main.config_file = Util.handle_filename(a)
+ elif o in ("-H", "--host"):
+ main.single_host = a
+ elif o in ("-n", "--nodes"):
+ main.nodes_file = Util.handle_filename(a)
+ elif o in ("-t", "--tasks"):
+ main.tasks_file = Util.handle_filename(a)
+ elif o in ("-a", "--all"):
+ main.pl_use_nodes = True
+ elif o in ("-p", "--password"):
+ main.pl_password = a
+ elif o in ("-s", "--startid"):
+ main.startid = a
+ else:
+ assert False, "unhandled option"
+
+ if (main.verbose == True):
+ main.logger = Util.Logger (True)
else:
- assert False, "unhandled option"
-
- if (main.verbose == True):
- main.logger = Util.Logger (True)
- else:
- main.logger = Util.Logger (False)
+ main.logger = Util.Logger (False)
+
+ if (main.config_file == ""):
+ print "No configuration file given!\n"
+ usage()
+ sys.exit(1)
+
+ # Load configuration file
+ configuration = Configuration.Configuration (main.config_file,
main.logger);
+ if (configuration.load() == False):
+ sys.exit(2)
- if (main.config_file == ""):
- print "No configuration file given!\n"
- usage()
- sys.exit(1)
+ # command line beats configuration
+ if ((main.nodes_file == "") and (main.pl_use_nodes == False) and
(main.single_host == None)):
+ if (configuration.nodesfile != ""):
+ main.nodes_file = configuration.nodesfile
+ else:
+ print "No nodes file given!\n"
+ usage()
+ sys.exit(3)
-# Load configuration file
- configuration = Configuration.Configuration (main.config_file,
main.logger);
- if (configuration.load() == False):
- sys.exit(2)
+ if (main.tasks_file == ""):
+ if (configuration.taskfile != ""):
+ main.tasks_file = configuration.taskfile
+ else:
+ print "No tasks file given!\n"
+ usage()
+ sys.exit(4)
+
+ if ((True == main.pl_use_nodes) and (main.pl_password != None)):
+ configuration.pl_password = main.pl_password
+ if ((True == main.pl_use_nodes) and (main.pl_password == None)):
+ while ((main.pl_password == None) or (main.pl_password == "")):
+ print "Please enter PlanetLab password:"
+ main.pl_password = getpass.getpass()
+ main.pl_password = main.pl_password.strip()
+ configuration.pl_password = main.pl_password
- # command line beats configuration
- if ((main.nodes_file == "") and (main.pl_use_nodes == False) and
(main.single_host == None)):
- if (configuration.nodesfile != ""):
- main.nodes_file = configuration.nodesfile
- else:
- print "No nodes file given!\n"
- usage()
- sys.exit(3)
+ # Load hosts files
+ if (main.single_host != None):
+ nodes = Nodes.StringNodes (main.single_host, main.logger)
+ if (nodes.load() == False):
+ sys.exit(5)
+ elif ((main.pl_use_nodes == True) or (configuration.pl_use_nodes ==
True)):
+ nodes = Nodes.PlanetLabNodes (configuration, main.logger)
+ if (nodes.load() == False):
+ sys.exit(6)
+ elif (main.nodes_file != ""):
+ nodes = Nodes.Nodes (main.nodes_file, main.logger);
+ if (nodes.load() == False):
+ sys.exit(7)
+ else:
+ print "No nodes file given!\n"
+ sys.exit(8)
- if (main.tasks_file == ""):
- if (configuration.taskfile != ""):
- main.tasks_file = configuration.taskfile
- else:
- print "No tasks file given!\n"
- usage()
- sys.exit(4)
-
- if ((True == main.pl_use_nodes) and (main.pl_password != None)):
- configuration.pl_password = main.pl_password
- if ((True == main.pl_use_nodes) and (main.pl_password == None)):
- while ((main.pl_password == None) or (main.pl_password == "")):
- print "Please enter PlanetLab password:"
- main.pl_password = sys.stdin.readline()
- main.pl_password = main.pl_password.strip()
- configuration.pl_password = main.pl_password
+ # Load actions file
+ tasks = Tasks.Tasks (main.tasks_file, main.logger, main.startid);
+ if (tasks.load() == False):
+ sys.exit(2)
+
+ # Set up notifications
+
+ if (configuration.notifications == "simple"):
+ notifications = Notifications.SimpleNotification (main.logger)
+ if (configuration.notifications == "result"):
+ notifications = Notifications.TaskListResultNotification
(main.logger)
+ else:
+ notifications = Notifications.TaskListResultNotification
(main.logger)
+ except KeyboardInterrupt:
+ sys.exit(0)
-# Load hosts files
- if (main.single_host != None):
- nodes = Nodes.StringNodes (main.single_host, main.logger)
- if (nodes.load() == False):
- sys.exit(5)
- elif ((main.pl_use_nodes == True) or (configuration.pl_use_nodes == True)):
- nodes = Nodes.PlanetLabNodes (configuration, main.logger)
- if (nodes.load() == False):
- sys.exit(6)
- elif (main.nodes_file != ""):
- nodes = Nodes.Nodes (main.nodes_file, main.logger);
- if (nodes.load() == False):
- sys.exit(7)
- else:
- print "No nodes file given!\n"
- sys.exit(8)
-
-# Load actions file
- tasks = Tasks.Tasks (main.tasks_file, main.logger, main.startid);
- if (tasks.load() == False):
- sys.exit(2)
-
-# Set up notifications
-
- if (configuration.notifications == "simple"):
- notifications = Notifications.SimpleNotification (main.logger)
- if (configuration.notifications == "result"):
- notifications = Notifications.TaskListResultNotification (main.logger)
- else:
- notifications = Notifications.TaskListResultNotification (main.logger)
-
# Start execution
- worker = Worker.Worker (main.logger, configuration, nodes, tasks,
notifications)
- worker.start()
+ try:
+ worker = Worker.Worker (main.logger, configuration, nodes, tasks,
notifications)
+ worker.start()
+ except KeyboardInterrupt:
+ print "Interrupt during execution, FIXME!"
+ sys.exit(0)
# Clean up
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24806 - gnunet-planetlab/gplmt,
gnunet <=