Repository: nipy/heudiconv

Issue:
something (etelemetry?) causes logger to puke a traceback upon startup
```shell
bids@rolando:~$ heudiconv -o /tmp/cmrr -l '' --files .... -f cmrr-test.py 
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 868, in emit
    msg = self.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 741, in format
    return fmt.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 465, in format
    record.message = record.getMessage()
  File "/usr/lib/python2.7/logging/__init__.py", line 329, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file run.py, line 255
INFO: Running heudiconv version 0.6.0 latest Unknown
...
```

Comments:

Patch:
diff --git a/heudiconv/cli/run.py b/heudiconv/cli/run.py
index ed17aad..516e163 100644
--- a/heudiconv/cli/run.py
+++ b/heudiconv/cli/run.py
@@ -248,11 +248,11 @@ def process_args(args):
 
     outdir = op.abspath(args.outdir)
 
-    import etelemetry
     try:
+        import etelemetry
         latest = etelemetry.get_project("nipy/heudiconv")
     except Exception as e:
-        lgr.warning("Could not check for version updates: ", e)
+        lgr.warning("Could not check for version updates: %s", str(e))
         latest = {"version": 'Unknown'}
 
     lgr.info(INIT_MSG(packname=__packagename__,
diff --git a/heudiconv/dicoms.py b/heudiconv/dicoms.py
index 8249aad..7c8c450 100644
--- a/heudiconv/dicoms.py
+++ b/heudiconv/dicoms.py
@@ -58,7 +58,9 @@ def group_dicoms_into_seqinfos(files, file_filter, dcmfilter, grouping):
         import nibabel.nicom.dicomwrappers as dw
         # TODO after getting a regression test check if the same behavior
         #      with stop_before_pixels=True
-        mw = dw.wrapper_from_data(dcm.read_file(filename, force=True))
+        mw = dw.wrapper_from_data(
+            dcm.read_file(filename, stop_before_pixels=True, force=True)
+        )
 
         for sig in ('iop', 'ICE_Dims', 'SequenceName'):
             try:


Test patch:
diff --git a/heudiconv/tests/test_dicoms.py b/heudiconv/tests/test_dicoms.py
index de8e9a1..4786cae 100644
--- a/heudiconv/tests/test_dicoms.py
+++ b/heudiconv/tests/test_dicoms.py
@@ -15,7 +15,7 @@ DICOM_FIELDS_TO_TEST = {
 
 def test_private_csa_header(tmpdir):
     dcm_file = op.join(TESTS_DATA_PATH, 'axasc35.dcm')
-    dcm_data = dcm.read_file(dcm_file)
+    dcm_data = dcm.read_file(dcm_file, stop_before_pixels=True)
     for pub, priv in DICOM_FIELDS_TO_TEST.items():
         # ensure missing public tag
         with pytest.raises(AttributeError):
diff --git a/heudiconv/tests/test_main.py b/heudiconv/tests/test_main.py
index f4b7700..2ee2d95 100644
--- a/heudiconv/tests/test_main.py
+++ b/heudiconv/tests/test_main.py
@@ -1,6 +1,9 @@
 # TODO: break this up by modules
 
-from heudiconv.cli.run import main as runner
+from heudiconv.cli.run import (
+    main as runner,
+    process_args,
+)
 from heudiconv import __version__
 from heudiconv.utils import (create_file_if_missing,
                              set_readonly,
@@ -271,3 +274,16 @@ def test_cache(tmpdir):
     assert (cachedir / 'dicominfo.tsv').exists()
     assert (cachedir / 'S01.auto.txt').exists()
     assert (cachedir / 'S01.edit.txt').exists()
+
+
+def test_no_etelemetry():
+    # smoke test at large - just verifying that no crash if no etelemetry
+    class args:
+        outdir = '/dev/null'
+        command = 'ls'
+        heuristic = 'reproin'
+        files = []  # Nothing to list
+
+    # must not fail if etelemetry no found
+    with patch.dict('sys.modules', {'etelemetry': None}):
+        process_args(args)