mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 03:06:33 +00:00
python3 compatibility for show-tool-versions.py for CI
This commit is contained in:
parent
838610dfed
commit
5adde83acf
@ -11,6 +11,7 @@ def foldlines(s, numlines=None):
|
||||
lines = lines[:numlines]
|
||||
return " ".join(lines).replace("\r", "")
|
||||
|
||||
|
||||
def print_platform():
|
||||
try:
|
||||
import platform
|
||||
@ -24,16 +25,18 @@ def print_platform():
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
sys.stderr.flush()
|
||||
|
||||
|
||||
def print_python_ver():
|
||||
print("python:", foldlines(sys.version))
|
||||
print('maxunicode: ' + str(sys.maxunicode))
|
||||
|
||||
|
||||
def print_python_encoding_settings():
|
||||
print('filesystem.encoding: ' + str(sys.getfilesystemencoding()))
|
||||
print('locale.getpreferredencoding: ' + str(locale.getpreferredencoding()))
|
||||
try:
|
||||
print('locale.defaultlocale: ' + str(locale.getdefaultlocale()))
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
print('got exception from locale.getdefaultlocale(): ', e)
|
||||
print('locale.locale: ' + str(locale.getlocale()))
|
||||
|
||||
@ -43,8 +46,8 @@ def print_stdout(cmdlist, label=None, numlines=None):
|
||||
label = cmdlist[0]
|
||||
res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
|
||||
stdout=subprocess.PIPE).communicate()[0]
|
||||
print(label + ': ' + foldlines(res, numlines))
|
||||
except EnvironmentError, e:
|
||||
print(label + ': ' + foldlines(res.decode('utf-8'), numlines))
|
||||
except EnvironmentError as e:
|
||||
if isinstance(e, OSError) and e.errno == 2:
|
||||
print(label + ': no such file or directory')
|
||||
return
|
||||
@ -52,14 +55,16 @@ def print_stdout(cmdlist, label=None, numlines=None):
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
sys.stderr.flush()
|
||||
|
||||
|
||||
def print_as_ver():
|
||||
if os.path.exists('a.out'):
|
||||
print("WARNING: a file named a.out exists, and getting the version of the 'as' assembler writes to that filename, so I'm not attempting to get the version of 'as'.")
|
||||
print("WARNING: a file named a.out exists, and getting the version of the 'as' assembler "
|
||||
"writes to that filename, so I'm not attempting to get the version of 'as'.")
|
||||
return
|
||||
try:
|
||||
res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
|
||||
stdout, stderr = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
|
||||
print('as: ' + foldlines(res[0]+' '+res[1]))
|
||||
print('as: ' + foldlines(stdout.decode('utf-8') + ' ' + stderr.decode('utf-8')))
|
||||
if os.path.exists('a.out'):
|
||||
os.remove('a.out')
|
||||
except EnvironmentError:
|
||||
@ -67,6 +72,7 @@ def print_as_ver():
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
sys.stderr.flush()
|
||||
|
||||
|
||||
def print_setuptools_ver():
|
||||
try:
|
||||
import pkg_resources
|
||||
@ -79,6 +85,7 @@ def print_setuptools_ver():
|
||||
except pkg_resources.DistributionNotFound:
|
||||
print('setuptools: DistributionNotFound')
|
||||
|
||||
|
||||
def print_py_pkg_ver(pkgname, modulename=None):
|
||||
if modulename is None:
|
||||
modulename = pkgname
|
||||
@ -105,6 +112,7 @@ def print_py_pkg_ver(pkgname, modulename=None):
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
print_platform()
|
||||
print()
|
||||
print_python_ver()
|
||||
|
Loading…
Reference in New Issue
Block a user