|
6 | 6 |
|
7 | 7 |
|
8 | 8 | import os |
9 | | -import warnings |
10 | 9 |
|
| 10 | +from ... import logging |
11 | 11 | from ...utils.filemanip import split_filename |
12 | 12 | from ..base import ( |
13 | 13 | CommandLine, traits, CommandLineInputSpec, isdefined, File, TraitedSpec) |
14 | 14 |
|
15 | | -warn = warnings.warn |
| 15 | +# Use nipype's logging system |
| 16 | +iflogger = logging.getLogger('interface') |
16 | 17 |
|
17 | 18 |
|
18 | 19 | class Info(object): |
@@ -40,26 +41,29 @@ def version(): |
40 | 41 | try: |
41 | 42 | clout = CommandLine(command='afni_vcheck', |
42 | 43 | terminal_output='allatonce').run() |
| 44 | + |
| 45 | + # Try to parse the version number |
| 46 | + currv = clout.runtime.stdout.split('\n')[1].split('=', 1)[1].strip() |
43 | 47 | except IOError: |
44 | 48 | # If afni_vcheck is not present, return None |
45 | | - warn('afni_vcheck executable not found.') |
| 49 | + iflogger.warn('afni_vcheck executable not found.') |
46 | 50 | return None |
47 | 51 | except RuntimeError as e: |
48 | | - # If AFNI is outdated, afni_vcheck throws error |
49 | | - warn('AFNI is outdated') |
50 | | - return str(e).split('\n')[4].split('=', 1)[1].strip() |
51 | | - |
52 | | - # Try to parse the version number |
53 | | - out = clout.runtime.stdout.split('\n')[1].split('=', 1)[1].strip() |
| 52 | + # If AFNI is outdated, afni_vcheck throws error. |
| 53 | + # Show new version, but parse current anyways. |
| 54 | + currv = str(e).split('\n')[4].split('=', 1)[1].strip() |
| 55 | + nextv = str(e).split('\n')[6].split('=', 1)[1].strip() |
| 56 | + iflogger.warn( |
| 57 | + 'AFNI is outdated, detected version %s and %s is available.' % (currv, nextv)) |
54 | 58 |
|
55 | | - if out.startswith('AFNI_'): |
56 | | - out = out[5:] |
| 59 | + if currv.startswith('AFNI_'): |
| 60 | + currv = currv[5:] |
57 | 61 |
|
58 | | - v = out.split('.') |
| 62 | + v = currv.split('.') |
59 | 63 | try: |
60 | 64 | v = [int(n) for n in v] |
61 | 65 | except ValueError: |
62 | | - return out |
| 66 | + return currv |
63 | 67 | return tuple(v) |
64 | 68 |
|
65 | 69 | @classmethod |
|
0 commit comments