Skip to content

Commit 67e7ffc

Browse files
committed
ENH: add option to silence printing
1 parent 5329ae8 commit 67e7ffc

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
source /tmp/install_sdist/bin/activate
5656
python -m pip install "setuptools ~= 42.0" "pip>=10.0.1"
5757
python -m pip install dist/templateflow*.tar.gz
58-
INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")' | tail -1)
58+
INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")')
5959
echo "VERSION: \"${THISVERSION}\""
6060
echo "INSTALLED: \"${INSTALLED_VERSION}\""
6161
test "${INSTALLED_VERSION}" = "${THISVERSION}"
@@ -87,7 +87,7 @@ jobs:
8787
source /tmp/install_wheel/bin/activate
8888
python -m pip install "setuptools ~= 42.0" "pip>=10.0.1"
8989
python -m pip install dist/templateflow*.whl
90-
INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")' | tail -1)
90+
INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")')
9191
echo "INSTALLED: \"${INSTALLED_VERSION}\""
9292
test "${INSTALLED_VERSION}" = "${THISVERSION}"
9393
@@ -121,7 +121,7 @@ jobs:
121121
python -m pip install "setuptools ~= 42.0" wheel "setuptools_scm[toml] >= 3.4" \
122122
setuptools_scm_git_archive "pip>=10.0.1"
123123
python setup.py install
124-
INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")' | tail -1)
124+
INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")')
125125
echo "INSTALLED: \"${INSTALLED_VERSION}\""
126126
test "${INSTALLED_VERSION}" = "${THISVERSION}"
127127
@@ -153,7 +153,7 @@ jobs:
153153
python -m pip install "setuptools ~= 42.0" wheel "setuptools_scm[toml] >= 3.4" \
154154
setuptools_scm_git_archive "pip>=10.0.1"
155155
python setup.py develop
156-
INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")' | tail -1)
156+
INSTALLED_VERSION=$(python -c 'import templateflow as tf; print(tf.__version__, end="")')
157157
echo "INSTALLED: \"${INSTALLED_VERSION}\""
158158
test "${INSTALLED_VERSION}" = "${THISVERSION}"
159159

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ script:
6666
INTENDED_VERSION="$(python setup.py --version)"
6767
mkdir for_testing
6868
cd for_testing
69-
INSTALLED_VERSION="$(python -c 'import templateflow; print(templateflow.__version__)' | tail -1)"
69+
INSTALLED_VERSION="$(python -c 'import templateflow; print(templateflow.__version__)')"
7070
python -c 'import templateflow; print(templateflow.__file__)'
7171
echo "Intended: $INTENDED_VERSION"
7272
echo "Installed: $INSTALLED_VERSION"

templateflow/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
"n",
2828
):
2929
# trigger skeleton autoupdate
30-
update(local=True, overwrite=False)
31-
30+
update(local=True, overwrite=False, silent=True)
3231

3332
__all__ = [
3433
'__copyright__',

templateflow/conf/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242
_update_s3(TF_HOME, local=True, overwrite=True)
4343

4444

45-
def update(local=False, overwrite=True):
45+
def update(local=False, overwrite=True, silent=False):
4646
"""Update an existing DataLad or S3 home."""
4747
if TF_USE_DATALAD and _update_datalad():
4848
return True
4949

5050
from ._s3 import update as _update_s3
5151

52-
return _update_s3(TF_HOME, local=local, overwrite=overwrite)
52+
return _update_s3(TF_HOME, local=local, overwrite=overwrite, silent=silent)
5353

5454

5555
def setup_home(force=False):

templateflow/conf/_s3.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
).read_text()
1414

1515

16-
def update(dest, local=True, overwrite=True):
16+
def update(dest, local=True, overwrite=True, silent=False):
1717
"""Update an S3-backed TEMPLATEFLOW_HOME repository."""
1818
skel_file = Path((_get_skeleton_file() if not local else None) or TF_SKEL_PATH)
1919

20-
retval = _update_skeleton(skel_file, dest, overwrite=overwrite)
20+
retval = _update_skeleton(skel_file, dest, overwrite=overwrite, silent=silent)
2121
if skel_file != TF_SKEL_PATH:
2222
skel_file.unlink()
2323
return retval
@@ -45,7 +45,7 @@ def _get_skeleton_file():
4545
return skel_file
4646

4747

48-
def _update_skeleton(skel_file, dest, overwrite=True):
48+
def _update_skeleton(skel_file, dest, overwrite=True, silent=False):
4949
from zipfile import ZipFile
5050

5151
dest = Path(dest)
@@ -62,11 +62,12 @@ def _update_skeleton(skel_file, dest, overwrite=True):
6262
]
6363
newfiles = sorted(set(allfiles) - set(existing))
6464
if newfiles:
65-
print(
66-
"Updating TEMPLATEFLOW_HOME using S3. "
67-
"Adding: \n%s" % "\n".join(newfiles)
68-
)
65+
if not silent:
66+
print(
67+
"Updating TEMPLATEFLOW_HOME using S3. Adding:\n%s" % '\n'.join(newfiles)
68+
)
6969
zipref.extractall(str(dest), members=newfiles)
7070
return True
71-
print("TEMPLATEFLOW_HOME directory (S3 type) was up-to-date.")
71+
if not silent:
72+
print("TEMPLATEFLOW_HOME directory (S3 type) was up-to-date.")
7273
return False

0 commit comments

Comments
 (0)