Skip to content

Commit 82a2c6a

Browse files
committed
address @effigies' comments
1 parent fc75e0f commit 82a2c6a

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

doc/users/config_file.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,16 @@ Execution
7373
``false``; default value: ``true``)
7474

7575
*display_variable*
76-
What ``$DISPLAY`` environment variable should utilize those interfaces
77-
that require an X server. These interfaces should have the attribute
78-
``_redirect_x = True``. This option is very useful when the system has
79-
an X server listening in the default port 6000, but ``$DISPLAY`` is
80-
not defined. In that case, set ``display_variable = :0``. Similarly,
81-
it can be used to point X-based interfaces to other servers, like VNC,
82-
`xnest <http://www.x.org/archive/X11R7.5/doc/man/man1/Xnest.1.html>`_
83-
or `Xvfb <http://www.x.org/archive/X11R6.8.1/doc/Xvfb.1.html>`_
84-
and you would like to redirect all spawned windows to
85-
it. If not set, nipype will try to configure a new virtual server using
86-
Xvfb. (possible values: any X server address; default value: not
87-
set)
76+
Override the ``$DISPLAY`` environment variable for interfaces that require
77+
an X server. This option is useful if there is a running X server, but
78+
``$DISPLAY`` was not defined in nipype's environment. For example, if an X
79+
server is listening on the default port of 6000, set ``display_variable = :0``
80+
to enable nipype interfaces to use it. It may also point to displays provided
81+
by VNC, `xnest <http://www.x.org/archive/X11R7.5/doc/man/man1/Xnest.1.html>`_
82+
or `Xvfb <http://www.x.org/archive/X11R6.8.1/doc/Xvfb.1.html>`_.
83+
If neither ``display_variable`` nor the ``$DISPLAY`` environment variable are
84+
set, nipype will try to configure a new virtual server using Xvfb.
85+
(possible values: any X server address; default value: not set)
8886

8987
*remove_unnecessary_outputs*
9088
This will remove any interface outputs not needed by the workflow. If the

nipype/utils/tests/test_config.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
@pytest.mark.parametrize('dispnum', range(5))
2323
def test_display_config(monkeypatch, dispnum):
24-
"""Check that the display_variable option is used"""
24+
"""Check that the display_variable option is used ($DISPLAY not set)"""
2525
config._display = None
2626
dispstr = ':%d' % dispnum
2727
config.set('execution', 'display_variable', dispstr)
@@ -44,12 +44,12 @@ def test_display_config_and_system(monkeypatch):
4444
config._display = None
4545
dispstr = ':10'
4646
config.set('execution', 'display_variable', dispstr)
47-
monkeypatch.setitem(os.environ, 'DISPLAY', dispstr)
47+
monkeypatch.setitem(os.environ, 'DISPLAY', ':0')
4848
assert config.get_display() == dispstr
4949

5050

5151
def test_display_noconfig_nosystem_patched(monkeypatch):
52-
"""Check that when no display is specified, a virtual Xvfb is used"""
52+
"""Check that when no $DISPLAY nor option are specified, a virtual Xvfb is used"""
5353
config._display = None
5454
if config.has_option('execution', 'display_variable'):
5555
config._config.remove_option('execution', 'display_variable')
@@ -59,7 +59,10 @@ def test_display_noconfig_nosystem_patched(monkeypatch):
5959

6060

6161
def test_display_empty_patched(monkeypatch):
62-
"""Check that when no display is specified, a virtual Xvfb is used"""
62+
"""
63+
Check that when $DISPLAY is empty string and no option is specified,
64+
a virtual Xvfb is used
65+
"""
6366
config._display = None
6467
if config.has_option('execution', 'display_variable'):
6568
config._config.remove_option('execution', 'display_variable')
@@ -69,7 +72,10 @@ def test_display_empty_patched(monkeypatch):
6972

7073

7174
def test_display_noconfig_nosystem_notinstalled(monkeypatch):
72-
"""Check that when no display is specified, a virtual Xvfb is used"""
75+
"""
76+
Check that an exception is raised if xvfbwrapper is not installed
77+
but necessary (no config and $DISPLAY unset)
78+
"""
7379
config._display = None
7480
if config.has_option('execution', 'display_variable'):
7581
config._config.remove_option('execution', 'display_variable')
@@ -80,7 +86,10 @@ def test_display_noconfig_nosystem_notinstalled(monkeypatch):
8086

8187

8288
def test_display_empty_notinstalled(monkeypatch):
83-
"""Check that when no display is specified, a virtual Xvfb is used"""
89+
"""
90+
Check that an exception is raised if xvfbwrapper is not installed
91+
but necessary (no config and $DISPLAY empty)
92+
"""
8493
config._display = None
8594
if config.has_option('execution', 'display_variable'):
8695
config._config.remove_option('execution', 'display_variable')
@@ -92,7 +101,10 @@ def test_display_empty_notinstalled(monkeypatch):
92101

93102
@pytest.mark.skipif(not has_Xvfb, reason='xvfbwrapper not installed')
94103
def test_display_noconfig_nosystem_installed(monkeypatch):
95-
"""Check that when no display is specified, a virtual Xvfb is used"""
104+
"""
105+
Check that actually uses xvfbwrapper when installed (not mocked)
106+
and necessary (no config and $DISPLAY unset)
107+
"""
96108
config._display = None
97109
if config.has_option('execution', 'display_variable'):
98110
config._config.remove_option('execution', 'display_variable')
@@ -102,7 +114,10 @@ def test_display_noconfig_nosystem_installed(monkeypatch):
102114

103115
@pytest.mark.skipif(not has_Xvfb, reason='xvfbwrapper not installed')
104116
def test_display_empty_installed(monkeypatch):
105-
"""Check that when no display is specified, a virtual Xvfb is used"""
117+
"""
118+
Check that actually uses xvfbwrapper when installed (not mocked)
119+
and necessary (no config and $DISPLAY empty)
120+
"""
106121
config._display = None
107122
if config.has_option('execution', 'display_variable'):
108123
config._config.remove_option('execution', 'display_variable')
@@ -111,7 +126,11 @@ def test_display_empty_installed(monkeypatch):
111126

112127

113128
def test_display_empty_macosx(monkeypatch):
114-
"""Check that when no display is specified, a virtual Xvfb is used"""
129+
"""
130+
Check that an exception is raised if xvfbwrapper is necessary
131+
(no config and $DISPLAY unset) but platform is OSX. See
132+
https://github.com/nipy/nipype/issues/1400
133+
"""
115134
config._display = None
116135
if config.has_option('execution', 'display_variable'):
117136
config._config.remove_option('execution', 'display_variable')

0 commit comments

Comments
 (0)