X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=blobdiff_plain;f=clientbin%2FsfiAddLinks.py;h=24284ef70763b292476eeef9bb56c8ad92bc361d;hp=2e667b1bfe204e62269d8fc69c4422a7b73e9aaf;hb=HEAD;hpb=1db1a879ffde8991aa95dd80142d555551655e88 diff --git a/clientbin/sfiAddLinks.py b/clientbin/sfiAddLinks.py index 2e667b1b..24284ef7 100755 --- a/clientbin/sfiAddLinks.py +++ b/clientbin/sfiAddLinks.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#!/usr/bin/env python3 import sys @@ -16,32 +16,33 @@ command.add_linkfile_option() command.prep() if not command.opts.linkfile: - print "Missing link list -- exiting" + print("Missing link list -- exiting") command.parser.print_help() sys.exit(1) - + if command.opts.infile: - infile=file(command.opts.infile) + infile = open(command.opts.infile) else: - infile=sys.stdin + infile = sys.stdin if command.opts.outfile: - outfile=file(command.opts.outfile,"w") + outfile = open(command.opts.outfile, "w") else: - outfile=sys.stdout + outfile = sys.stdout ad_rspec = RSpec(infile) -links = file(command.opts.linkfile).read().split('\n') -link_tuples = map(lambda x: tuple(x.split()), links) +links = open(command.opts.linkfile).read().split('\n') +link_tuples = [tuple(x.split()) for x in links] version_manager = VersionManager() try: type = ad_rspec.version.type version_num = ad_rspec.version.version - request_version = version_manager._get_version(type, version_num, 'request') + request_version = version_manager._get_version( + type, version_num, 'request') request_rspec = RSpec(version=request_version) request_rspec.version.merge(ad_rspec) request_rspec.version.add_link_requests(link_tuples) except: logger.log_exc("sfiAddLinks FAILED with links %s" % links) sys.exit(1) -print >>outfile, request_rspec.toxml() +print(request_rspec.toxml(), file=outfile) sys.exit(0)