honor -i and -o as advertised
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 2 May 2011 10:41:36 +0000 (12:41 +0200)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 2 May 2011 10:41:36 +0000 (12:41 +0200)
sfa/client/sfiAddSliver.py

index 387f9df..2b9668b 100755 (executable)
@@ -11,20 +11,24 @@ command = Commands(usage="%prog [options] node1 node2...",
 command.add_nodefile_option()
 command.prep()
 
-if command.opts.infile:
-    rspec = parse_rspec(command.opts.infile)
-    nodes = []
-    if command.opts.nodefile:
-        f = open(command.opts.nodefile, "r")
-        nodes = f.read().split()
-        f.close()
-
-    try:
-        rspec.add_slivers(nodes)
-    except:
-        print >> sys.stderr, "FAILED: %s" % node
-
-    print rspec.toxml()
+if not command.opts.nodefile:
+    print "Missing node list -- exiting"
+    command.parser.print_help()
+    sys.exit(1)
     
+if command.opts.infile:
+    infile=file(command.opts.infile)
+else:
+    infile=sys.stdin
+if command.opts.outfile:
+    outfile=file(command.opts.outfile,"w")
+else:
+    outfile=sys.stdout
 
-    
+rspec = parse_rspec(infile)
+nodes = file(command.opts.nodefile).read().split()
+try:
+    rspec.add_slivers(nodes)
+except:
+    print >> sys.stderr, "FAILED: %s" % node
+print >>outfile, rspec.toxml()