Skip to content

Commit

Permalink
Python: turn off output when updating path to Python unless `--verbos…
Browse files Browse the repository at this point in the history
…e` given.
  • Loading branch information
dbrnz committed Oct 4, 2017
1 parent f6d650b commit e75b459
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions distrib/bin/set_python_path.py
Expand Up @@ -43,6 +43,7 @@
import os
import re
import sys
import logging
import marshal
import argparse
import subprocess
Expand Down Expand Up @@ -97,8 +98,8 @@ def update_script(script_filename, new_path):
else:
args[0] = new_bin

logging.info('S: %s', script_filename)
lines[0] = '#!%s\n' % ' '.join(args)
print('S %s' % script_filename)
with open(script_filename, 'w') as f:
f.writelines(lines)

Expand All @@ -111,7 +112,6 @@ def update_scripts(bin_dir, new_path):

def update_pyc(filename, new_path):
"""Updates the filenames stored in pyc files."""
print("PYCL %s" % filename)
with open(filename, 'rb') as f:
if sys.version_info < (3, 3): magic = f.read(8)
else: magic = f.read(12)
Expand All @@ -138,7 +138,7 @@ def _process(code):
new_code = _process(code)

if new_code is not code:
print('B %s' % filename)
logging.info('B: %s', filename)
with open(filename, 'wb') as f:
f.write(magic)
marshal.dump(new_code, f)
Expand Down Expand Up @@ -209,12 +209,18 @@ def main():
parser.add_argument('--update-path', dest='update_path',
help='Path to scripts. Set to "auto" '
'for autodetection')
parser.add_argument('--verbose', dest='verbose',
help='Show names of updated scripts')

parser.add_argument('path', help='Path to new Python installation.')

args = parser.parse_args()
if not args.update_path:
args.update_path = 'auto'

if not args.verbose:
logging.disable(logging.INFO)

rv = 0
if not update_paths(args.path, args.update_path):
rv = 1
Expand Down

0 comments on commit e75b459

Please sign in to comment.