From df431b8b14ac91f9bd7cc477130a611a65321a2d Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 2 May 2011 12:41:36 +0200 Subject: [PATCH] honor -i and -o as advertised --- sfa/client/sfiAddSliver.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) 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() -- 2.43.0