summaryrefslogtreecommitdiffstats
path: root/build_scripts/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'build_scripts/utils.py')
-rw-r--r--build_scripts/utils.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/build_scripts/utils.py b/build_scripts/utils.py
index 5c5f4927..66c844d1 100644
--- a/build_scripts/utils.py
+++ b/build_scripts/utils.py
@@ -58,11 +58,16 @@ import distutils.log as log
from distutils.errors import DistutilsOptionError
from distutils.errors import DistutilsSetupError
+_verbose = True
+
try:
WindowsError
except NameError:
WindowsError = None
+def set_quiet(quiet):
+ global _verbose
+ _verbose = not quiet
def filter_match(name, patterns):
for pattern in patterns:
@@ -254,7 +259,8 @@ def copyfile(src, dst, force=True, vars=None, force_copy_symlink=False,
return
if not os.path.islink(src) or force_copy_symlink:
- log.info("Copying file {} to {}.".format(src, dst))
+ if _verbose:
+ log.info("Copying file {} to {}.".format(src, dst))
shutil.copy2(src, dst)
if make_writable_by_owner:
make_file_writable_by_owner(dst)
@@ -270,8 +276,9 @@ def copyfile(src, dst, force=True, vars=None, force_copy_symlink=False,
os.chdir(target_dir)
if os.path.exists(link_name):
os.remove(link_name)
- log.info("Symlinking {} -> {} in {}.".format(link_name,
- link_target, target_dir))
+ if _verbose:
+ log.info("Symlinking {} -> {} in {}.".format(link_name,
+ link_target, target_dir))
os.symlink(link_target, link_name)
except OSError:
log.error("{} -> {}: Error creating symlink".format(link_name,
@@ -291,7 +298,8 @@ def makefile(dst, content=None, vars=None):
content = content.format(**vars)
dst = dst.format(**vars)
- log.info("Making file {}.".format(dst))
+ if _verbose:
+ log.info("Making file {}.".format(dst))
dstdir = os.path.dirname(dst)
if not os.path.exists(dstdir):
@@ -322,8 +330,9 @@ def copydir(src, dst, filter=None, ignore=None, force=True, recursive=True,
"filter={}. ignore={}.".format(src, dst, filter, ignore))
return []
- log.info("Copying tree {} to {}. filter={}. ignore={}.".format(src, dst,
- filter, ignore))
+ if _verbose:
+ log.info("Copying tree {} to {}. filter={}. ignore={}.".format(src,
+ dst, filter, ignore))
names = os.listdir(src)
@@ -405,9 +414,10 @@ def run_process(args, initial_env=None, redirect_stderr_to_stdout=True):
Prints both stdout and stderr to the console.
No output is captured.
"""
- log.info("Running process in directory {0}: command {1}".format(
- os.getcwd(),
- " ".join([(" " in x and '"{0}"'.format(x) or x) for x in args]))
+ if _verbose:
+ log.info("Running process in directory {0}: command {1}".format(
+ os.getcwd(),
+ " ".join([(" " in x and '"{0}"'.format(x) or x) for x in args]))
)
if initial_env is None:
@@ -493,8 +503,9 @@ def regenerate_qt_resources(src, pyside_rcc_path, pyside_rcc_options):
srcname_split = srcname.rsplit('.qrc', 1)
dstname = '_rc.py'.join(srcname_split)
if os.path.exists(dstname):
- log.info('Regenerating {} from {}'.format(dstname,
- os.path.basename(srcname)))
+ if _verbose:
+ log.info('Regenerating {} from {}'.format(dstname,
+ os.path.basename(srcname)))
run_process([pyside_rcc_path,
pyside_rcc_options,
srcname, '-o', dstname])