From: David-Sarah Hopwood Date: Fri, 15 Mar 2013 04:28:35 +0000 (+0000) Subject: Ensure that bin/tahoe and setup.py fail quickly on Python 3.3+. fixes #1775 X-Git-Tag: allmydata-tahoe-1.10a1~15 X-Git-Url: https://git.rkrishnan.org/%5B/frontends/%22news.html/cyclelanguage?a=commitdiff_plain;h=edfb40e57c30fcac2d85be3f298d5c1f080322dd;p=tahoe-lafs%2Ftahoe-lafs.git Ensure that bin/tahoe and setup.py fail quickly on Python 3.3+. fixes #1775 Signed-off-by: David-Sarah Hopwood --- diff --git a/bin/tahoe-script.template b/bin/tahoe-script.template index 5f144b22..abcdaa01 100644 --- a/bin/tahoe-script.template +++ b/bin/tahoe-script.template @@ -1,5 +1,5 @@ #!/bin/false # You must specify a python interpreter. -u"Tahoe-LAFS does not run under Python 3. Please use a version of Python between 2.5 and 2.7.x inclusive." +ur"Tahoe-LAFS does not run under Python 3. Please use a version of Python between 2.5 and 2.7.x inclusive." import sys, os, subprocess @@ -21,13 +21,13 @@ distribution, and only if you have already run "python setup.py build". # look for Tahoe.home . homemarker = os.path.join(base, "Tahoe.home") if not os.path.exists(homemarker): - print whoami - print '''\ + print(whoami) + print('''\ I just tried to run and found that I am not living in such a directory, so I am stopping now. To run Tahoe after it has been is installed, please execute my brother, who gets installed into the appropriate place for executables when you run "make install" (perhaps as "%s"). -''' % (perhaps_installed_tahoe,) +''' % (perhaps_installed_tahoe,)) sys.exit(1) # we've found our home. Put the tahoe support/lib etc. in our PYTHONPATH. @@ -104,25 +104,25 @@ else: command = prefix + [script] + args if not os.path.exists(script): - print whoami - print '''\ + print(whoami) + print('''\ I could not find the support script "%s". To run an installed version of Tahoe-LAFS, please execute the "tahoe" script that is installed into the appropriate place for executables when you run "python setup.py install" (perhaps as "%s"). -''' % (script, perhaps_installed_tahoe) +''' % (script, perhaps_installed_tahoe)) sys.exit(1) try: res = subprocess.call(command, env=os.environ) -except Exception, le: - print whoami - print '''\ +except Exception as le: + print(whoami) + print('''\ I just tried to invoke "%s" and got an exception. -''' % (runner,) +''' % (runner,)) raise else: sys.exit(res) diff --git a/setup.py b/setup.py index bbb662df..6276151b 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ #! /usr/bin/env python # -*- coding: utf-8 -*- -u"Tahoe-LAFS does not run under Python 3. Please use a version of Python between 2.5 and 2.7.x inclusive." +ur"Tahoe-LAFS does not run under Python 3. Please use a version of Python between 2.5 and 2.7.x inclusive." # Tahoe-LAFS -- secure, distributed storage grid # @@ -49,7 +49,7 @@ except EnvironmentError: open(APPNAMEFILE, "w").write(APPNAMEFILESTR) else: if curappnamefilestr.strip() != APPNAMEFILESTR: - print "Error -- this setup.py file is configured with the 'application name' to be '%s', but there is already a file in place in '%s' which contains the contents '%s'. If the file is wrong, please remove it and setup.py will regenerate it and write '%s' into it." % (APPNAME, APPNAMEFILE, curappnamefilestr, APPNAMEFILESTR) + print("Error -- this setup.py file is configured with the 'application name' to be '%s', but there is already a file in place in '%s' which contains the contents '%s'. If the file is wrong, please remove it and setup.py will regenerate it and write '%s' into it." % (APPNAME, APPNAMEFILE, curappnamefilestr, APPNAMEFILESTR)) sys.exit(-1) # setuptools/zetuptoolz looks in __main__.__requires__ for a list of @@ -279,15 +279,15 @@ def run_command(args, cwd=None, verbose=False): try: # remember shell=False, so use git.cmd on windows, not just git p = subprocess.Popen(args, stdout=subprocess.PIPE, cwd=cwd) - except EnvironmentError, e: + except EnvironmentError as e: if verbose: - print "unable to run %s" % args[0] - print e + print("unable to run %s" % args[0]) + print(e) return None stdout = p.communicate()[0].strip() if p.returncode != 0: if verbose: - print "unable to run %s (error)" % args[0] + print("unable to run %s (error)" % args[0]) return None return stdout @@ -326,7 +326,7 @@ def versions_from_git(tag_prefix, verbose=False): return {} if not stdout.startswith(tag_prefix): if verbose: - print "tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix) + print("tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix)) return {} version = stdout[len(tag_prefix):] pieces = version.split("-") @@ -359,7 +359,7 @@ class UpdateVersion(Command): elif os.path.isdir(os.path.join(basedir, ".git")): verstr = self.try_from_git(target) else: - print "no version-control data found, leaving _version.py alone" + print("no version-control data found, leaving _version.py alone") return if verstr: self.distribution.metadata.version = verstr @@ -384,7 +384,7 @@ class UpdateVersion(Command): "normalized": versions["normalized"], "full": versions["full"] }) f.close() - print "git-version: wrote '%s' into '%s'" % (versions["version"], fn) + print("git-version: wrote '%s' into '%s'" % (versions["version"], fn)) return versions.get("normalized", None)