class_docstr: Base nipype config class
class_docstr_tok: ["Base","nipype","config","class"]
docstr: Returns the first display available
docstr_tok: ["Returns","the","first","display","available"]
code: def get_display(self):
      """Returns the first display available"""
  
      # Check if an Xorg server is listening
      # import subprocess as sp
      # if not hasattr(sp, 'DEVNULL'):
      #     setattr(sp, 'DEVNULL', os.devnull)
      # x_listening = bool(sp.call('ps au | grep -v grep | grep -i xorg',
      #                    shell=True, stdout=sp.DEVNULL))
  
      if self._display is not None:
          return ":%d" % self._display.new_display
  
      sysdisplay = None
      if self._config.has_option("execution", "display_variable"):
          sysdisplay = self._config.get("execution", "display_variable")
  
      sysdisplay = sysdisplay or os.getenv("DISPLAY")
      if sysdisplay:
          from collections import namedtuple
  
          def _mock():
              pass
  
          # Store a fake Xvfb object. Format - <host>:<display>[.<screen>]
          ndisp = sysdisplay.split(":")[-1].split(".")[0]
          Xvfb = namedtuple("Xvfb", ["new_display", "stop"])
          self._display = Xvfb(int(ndisp), _mock)
          return self.get_display()
      else:
          if "darwin" in sys.platform:
              raise RuntimeError(
                  "Xvfb requires root permissions to run in OSX. Please "
                  "make sure that an X server is listening and set the "
                  "appropriate config on either $DISPLAY or nipype's "
                  '"display_variable" config. Valid X servers include '
                  "VNC, XQuartz, or manually started Xvfb."
              )
  
          # If $DISPLAY is empty, it confuses Xvfb so unset
          if sysdisplay == "":
              del os.environ["DISPLAY"]
          try:
              from xvfbwrapper import Xvfb
          except ImportError:
              raise RuntimeError(
                  "A display server was required, but $DISPLAY is not "
                  "defined and Xvfb could not be imported."
              )
  
          self._display = Xvfb(nolisten="tcp")
          self._display.start()
  
          # Older versions of xvfbwrapper used vdisplay_num
          if not hasattr(self._display, "new_display"):
              setattr(
                  self._display,
                  "new_display",
                  self._display.vdisplay_num,
              )
          return self.get_display()
  
imports: import os
  import sys
  import errno
  import atexit
  from warnings import warn
  from looseversion import LooseVersion
  import configparser
  import numpy
  from simplejson import load, dump
  from .misc import str2bool
  from filelock import SoftFileLock
label_desc: Use image node_id 20 for calling the NipypeConfig obj's underlying member method code with example usage: obj.get_display() and returns: unknown, self, self