From: Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Date: Mon, 2 May 2011 10:41:36 +0000 (+0200)
Subject: honor -i and -o as advertised
X-Git-Tag: sfa-1.0-21-ckp1~28
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=df431b8b14ac91f9bd7cc477130a611a65321a2d;p=sfa.git

honor -i and -o as advertised
---

diff --git a/sfa/client/sfiAddSliver.py b/sfa/client/sfiAddSliver.py
index 387f9df2..2b9668b5 100755
--- a/sfa/client/sfiAddSliver.py
+++ b/sfa/client/sfiAddSliver.py
@@ -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()