11#!/usr/bin/python
22
3+ from __future__ import absolute_import , division , print_function , unicode_literals
34import sys
45import subprocess
56import logging
@@ -53,14 +54,12 @@ class Environment(dict):
5354 assert len (paths ) < 2
5455 if subdir == 'bin' and options .warn :
5556 if len (paths ) == 0 :
56- print >> sys .stderr , \
57- "%s: warning: %s has no binary directory" % \
58- (sys .argv [0 ], mountpoint )
57+ print ("%s: warning: %s has no binary directory" % \
58+ (sys .argv [0 ], mountpoint ), file = sys .stderr )
5959 else :
6060 if False in [adir .is_native (p ) for p in paths ]:
61- print >> sys .stderr , \
62- "%s: warning: using compatibility for %s" % \
63- (sys .argv [0 ], mountpoint )
61+ print ("%s: warning: using compatibility for %s" % \
62+ (sys .argv [0 ], mountpoint ), file = sys .stderr )
6463 for p in paths :
6564 self [varmap [subdir ]].remove (p )
6665 if options .front :
@@ -97,13 +96,13 @@ def attach_filesys(filesys, options):
9796 if options .lookup :
9897 try :
9998 results = locker .resolve (filesys )
100- print "%s resolves to:" % (filesys )
99+ print ( "%s resolves to:" % (filesys ) )
101100 for r in results :
102- print "%s %s%s" % \
101+ print ( "%s %s%s" % \
103102 (r ['type' ], r ['data' ],
104- ' ' + str (r ['priority' ]) if r ['priority' ] > 0 else '' )
103+ ' ' + str (r ['priority' ]) if r ['priority' ] > 0 else '' ))
105104 except (locker .LockerNotFoundError , locker .LockerError ) as e :
106- print >> sys .stderr , e
105+ print ( e , file = sys .stderr )
107106 else :
108107 # Multiple entries will only be returned for FSGROUPs
109108 # which we want to try in order. Once successful, we're done
@@ -114,29 +113,29 @@ def attach_filesys(filesys, options):
114113 try :
115114 filesystems = locker .lookup (filesys )
116115 except locker .LockerError as e :
117- print >> sys .stderr , e
116+ print ( e , file = sys .stderr )
118117 for entry in filesystems :
119118 logger .debug ("Attempting to attach %s" , entry )
120119 if (options .map or options .remap ) and \
121120 (entry .authRequired or entry .authDesired ):
122121 try :
123122 subprocess .check_call (entry .getAuthCommandline ())
124123 except subprocess .CalledProcessError as e :
125- print >> sys . stderr , "Error while authenticating:" , e
124+ print ( "Error while authenticating:" , e , file = sys . stderr )
126125 if entry .authRequired :
127126 return None
128127 if options .mountpoint is not None :
129128 entry .mountpoint = options .mountpoint
130129 try :
131130 entry .attach (force = options .force )
132131 except locker .LockerError as e :
133- print >> sys .stderr , e
132+ print ( e , file = sys .stderr )
134133 continue
135134 if options .printpath :
136- print entry .mountpoint
135+ print ( entry .mountpoint )
137136 elif options .verbose :
138- print "%s: %s attached to %s for filesystem %s" % \
139- (sys .argv [0 ], entry .path , entry .mountpoint , entry .name )
137+ print ( "%s: %s attached to %s for filesystem %s" % \
138+ (sys .argv [0 ], entry .path , entry .mountpoint , entry .name ))
140139 return entry .mountpoint
141140 return None
142141
@@ -151,7 +150,7 @@ def deprecated_callback(option, opt_str, value, parser):
151150 """
152151 An OptionParser callback for deprecated options
153152 """
154- print >> sys . stderr , "WARNING: '%s' is obsolete and will be removed in future versions." % (opt_str )
153+ print ( "WARNING: '%s' is obsolete and will be removed in future versions." % (opt_str ), file = sys . stderr )
155154
156155def attachopts_callback (option , opt_str , value , parser ):
157156 # Consume all remaining values on the list
@@ -275,7 +274,7 @@ if (len(argv) > 0) and (argv[0] == "-Padd"):
275274 if options .printpath or len (lockers + paths ) < 1 :
276275 # See NOTES[5]
277276 pathsep = ':' if options .bourne else ' '
278- print >> sys . stderr , pathsep .join ([shorten_path (p ) for p in env ['PATH' ]])
277+ print ( pathsep .join ([shorten_path (p ) for p in env ['PATH' ]]), file = sys . stderr )
279278 sys .exit (0 )
280279 if options .remove :
281280 for p in paths :
@@ -285,7 +284,7 @@ if (len(argv) > 0) and (argv[0] == "-Padd"):
285284 if at is None :
286285 at = locker .read_attachtab ()
287286 if filesys not in at :
288- print >> sys . stderr , "%s: Not attached." % (filesys ,)
287+ print ( "%s: Not attached." % (filesys ,), file = sys . stderr )
289288 continue
290289 env .removeLocker (at [filesys ].mountpoint )
291290 else :
@@ -298,14 +297,14 @@ if (len(argv) > 0) and (argv[0] == "-Padd"):
298297 env ['PATH' ].insert (0 , p )
299298 else :
300299 env ['PATH' ].append (p )
301- print env .toShell (options .bourne )
300+ print ( env .toShell (options .bourne ) )
302301else :
303302 (options , args ) = attachParser .parse_args (argv )
304303 if options .debug :
305304 logging .basicConfig ()
306305 logger .setLevel (logging .DEBUG )
307306 if len (args ) < 1 :
308- print locker .read_attachtab ()._legacyFormat ()
307+ print ( locker .read_attachtab ()._legacyFormat () )
309308 if not options .map :
310309 options .remap = False
311310 if options .explicit and not options .mountpoint :
0 commit comments