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
...
```

Discussion:

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__,


Test patch:
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)