@@ -1010,32 +1010,6 @@ def _check_version_requirements(self, trait_object, raise_exception=True):
1010
1010
version , max_ver ))
1011
1011
return unavailable_traits
1012
1012
1013
- def _run_wrapper (self , runtime ):
1014
- sysdisplay = os .getenv ('DISPLAY' )
1015
- if self ._redirect_x :
1016
- try :
1017
- from xvfbwrapper import Xvfb
1018
- except ImportError :
1019
- iflogger .error ('Xvfb wrapper could not be imported' )
1020
- raise
1021
-
1022
- vdisp = Xvfb (nolisten = 'tcp' )
1023
- vdisp .start ()
1024
- try :
1025
- vdisp_num = vdisp .new_display
1026
- except AttributeError : # outdated version of xvfbwrapper
1027
- vdisp_num = vdisp .vdisplay_num
1028
-
1029
- iflogger .info ('Redirecting X to :%d' % vdisp_num )
1030
- runtime .environ ['DISPLAY' ] = ':%d' % vdisp_num
1031
-
1032
- runtime = self ._run_interface (runtime )
1033
-
1034
- if self ._redirect_x :
1035
- vdisp .stop ()
1036
-
1037
- return runtime
1038
-
1039
1013
def _run_interface (self , runtime ):
1040
1014
""" Core function that executes interface
1041
1015
"""
@@ -1071,6 +1045,9 @@ def run(self, **inputs):
1071
1045
1072
1046
# initialize provenance tracking
1073
1047
env = deepcopy (dict (os .environ ))
1048
+ if self ._redirect_x :
1049
+ env ['DISPLAY' ] = config .get_display ()
1050
+
1074
1051
runtime = Bunch (cwd = os .getcwd (),
1075
1052
returncode = None ,
1076
1053
duration = None ,
@@ -1080,8 +1057,9 @@ def run(self, **inputs):
1080
1057
platform = platform .platform (),
1081
1058
hostname = platform .node (),
1082
1059
version = self .version )
1060
+
1083
1061
try :
1084
- runtime = self ._run_wrapper (runtime )
1062
+ runtime = self ._run_interface (runtime )
1085
1063
outputs = self .aggregate_outputs (runtime )
1086
1064
runtime .endTime = dt .isoformat (dt .utcnow ())
1087
1065
timediff = parseutc (runtime .endTime ) - parseutc (runtime .startTime )
@@ -1446,7 +1424,7 @@ def get_max_resources_used(pid, mem_mb, num_threads, pyfunc=False):
1446
1424
return mem_mb , num_threads
1447
1425
1448
1426
1449
- def run_command (runtime , output = None , timeout = 0.01 , redirect_x = False ):
1427
+ def run_command (runtime , output = None , timeout = 0.01 ):
1450
1428
"""Run a command, read stdout and stderr, prefix with timestamp.
1451
1429
1452
1430
The returned runtime contains a merged stdout+stderr log with timestamps
@@ -1458,13 +1436,6 @@ def run_command(runtime, output=None, timeout=0.01, redirect_x=False):
1458
1436
# Init variables
1459
1437
PIPE = subprocess .PIPE
1460
1438
cmdline = runtime .cmdline
1461
-
1462
- if redirect_x :
1463
- exist_xvfb , _ = _exists_in_path ('xvfb-run' , runtime .environ )
1464
- if not exist_xvfb :
1465
- raise RuntimeError ('Xvfb was not found, X redirection aborted' )
1466
- cmdline = 'xvfb-run -a ' + cmdline
1467
-
1468
1439
env = _canonicalize_env (runtime .environ )
1469
1440
1470
1441
default_encoding = locale .getdefaultlocale ()[1 ]
@@ -1727,14 +1698,6 @@ def help(cls, returnhelp=False):
1727
1698
print (allhelp )
1728
1699
1729
1700
def _get_environ (self ):
1730
- out_environ = {}
1731
- if not self ._redirect_x :
1732
- try :
1733
- display_var = config .get ('execution' , 'display_variable' )
1734
- out_environ = {'DISPLAY' : display_var }
1735
- except NoOptionError :
1736
- pass
1737
- iflogger .debug (out_environ )
1738
1701
if isdefined (self .inputs .environ ):
1739
1702
out_environ .update (self .inputs .environ )
1740
1703
return out_environ
@@ -1754,10 +1717,6 @@ def version_from_command(self, flag='-v'):
1754
1717
o , e = proc .communicate ()
1755
1718
return o
1756
1719
1757
- def _run_wrapper (self , runtime ):
1758
- runtime = self ._run_interface (runtime )
1759
- return runtime
1760
-
1761
1720
def _run_interface (self , runtime , correct_return_codes = (0 ,)):
1762
1721
"""Execute command via subprocess
1763
1722
@@ -1785,8 +1744,7 @@ def _run_interface(self, runtime, correct_return_codes=(0,)):
1785
1744
setattr (runtime , 'command_path' , cmd_path )
1786
1745
setattr (runtime , 'dependencies' , get_dependencies (executable_name ,
1787
1746
runtime .environ ))
1788
- runtime = run_command (runtime , output = self .inputs .terminal_output ,
1789
- redirect_x = self ._redirect_x )
1747
+ runtime = run_command (runtime , output = self .inputs .terminal_output )
1790
1748
if runtime .returncode is None or \
1791
1749
runtime .returncode not in correct_return_codes :
1792
1750
self .raise_exception (runtime )
0 commit comments