コード例 #1
0
    def __init__(self, program, use_xauth, randomizer, retries, extra_args):
        self.extra_args = extra_args
        self.retries = retries
        self.program = program
        self.randomizer = randomizer
        self.stdout = None
        self.stderr = None
        self.old_display_var = None
        self.subproc = None
        self.is_started = False

        helptext = get_helptext(program)
        self.has_displayfd = "-displayfd" in helptext
        if not self.has_displayfd:
            log.debug("-displayfd flag is missing.")
        # if check_startup and not has_displayfd:
        #     check_startup = False
        #     log.warning(
        #         program
        #         + " -displayfd flag is not supported, 'check_startup' parameter has been disabled"
        #     )
        self._check_flags(helptext)

        if use_xauth and not xauth.is_installed():
            raise xauth.NotFoundError()

        self.use_xauth = use_xauth
        self._old_xauth = None
        self._xauth_filename = None
コード例 #2
0
    def __init__(self, use_xauth=False, check_startup=False, randomizer=None):
        with mutex:
            self.display = self.search_for_display(randomizer=randomizer)
            while self.display in USED_DISPLAY_NR_LIST:
                self.display += 1

            USED_DISPLAY_NR_LIST.append(self.display)

        if use_xauth and not xauth.is_installed():
            raise xauth.NotFoundError()

        self.use_xauth = use_xauth
        self._old_xauth = None
        self._xauth_filename = None
        self.check_startup = check_startup
        if check_startup and not fcntl:
            self.check_startup = False
            log.warning(
                "fcntl module can't be imported, 'check_startup' parameter has been disabled"
            )
            log.warning("fnctl module does not exist on Windows")
        if self.check_startup:
            rp, wp = os.pipe()
            fcntl.fcntl(rp, fcntl.F_SETFD, fcntl.FD_CLOEXEC)
            # to properly allow to inherit fds to subprocess on
            # python 3.2+ the easyprocess needs small fix..
            fcntl.fcntl(wp, fcntl.F_SETFD, 0)
            self.check_startup_fd = wp
            self._check_startup_fd = rp
        EasyProcess.__init__(self, self._cmd)
コード例 #3
0
 def __init__(self, use_xauth=False):
     mutex.acquire()
     try:
         self.display = self.search_for_display()
         while self.display in USED_DISPLAY_NR_LIST:
             self.display+=1
         USED_DISPLAY_NR_LIST.append(self.display)
     finally:
         mutex.release()
     if use_xauth and not xauth.is_installed():
         raise xauth.NotFoundError()
     self.use_xauth = use_xauth
     self._old_xauth = None
     self._xauth_filename = None
     EasyProcess.__init__(self, self._cmd)
コード例 #4
0
def test_xauth():
    """
    Test that a Xauthority file is created.
    """
    if not xauth.is_installed():
        raise SkipTest("This test needs xauth installed")
    old_xauth = os.getenv("XAUTHORITY")
    display = Display(visible=0, use_xauth=True)
    display.start()
    new_xauth = os.getenv("XAUTHORITY")

    ok_(new_xauth is not None)
    ok_(os.path.isfile(new_xauth))
    filename = os.path.basename(new_xauth)
    ok_(filename.startswith("PyVirtualDisplay."))
    ok_(filename.endswith("Xauthority"))

    display.stop()
    eq_(old_xauth, os.getenv("XAUTHORITY"))
    ok_(not os.path.isfile(new_xauth))
コード例 #5
0
def test_xauth():
    '''
    Test that a Xauthority file is created.
    '''
    if not xauth.is_installed():
        raise SkipTest('This test needs xauth installed')
    old_xauth = os.getenv('XAUTHORITY')
    display = Display(visible=0, use_xauth=True)
    display.start()
    new_xauth = os.getenv('XAUTHORITY')

    ok_(new_xauth is not None)
    ok_(os.path.isfile(new_xauth))
    filename = os.path.basename(new_xauth)
    ok_(filename.startswith('PyVirtualDisplay.'))
    ok_(filename.endswith('Xauthority'))

    display.stop()
    eq_(old_xauth, os.getenv('XAUTHORITY'))
    ok_(not os.path.isfile(new_xauth))
コード例 #6
0
    def __init__(self, program, use_xauth, retries, extra_args,
                 manage_global_env):
        self._extra_args = extra_args
        self._retries = retries
        self._program = program
        self.stdout = None
        self.stderr = None
        self.old_display_var = None
        self._subproc = None
        self.display = None
        self._is_started = False
        self._manage_global_env = manage_global_env
        self._reset_global_env = False
        self._pipe_wfd = None
        self._retries_current = 0

        helptext = get_helptext(program)
        self._has_displayfd = "-displayfd" in helptext
        if not self._has_displayfd:
            log.debug("-displayfd flag is missing.")
        PYVIRTUALDISPLAY_DISPLAYFD = os.environ.get(
            "PYVIRTUALDISPLAY_DISPLAYFD")
        if PYVIRTUALDISPLAY_DISPLAYFD:
            log.debug("PYVIRTUALDISPLAY_DISPLAYFD=%s",
                      PYVIRTUALDISPLAY_DISPLAYFD)
            # '0'->false, '1'->true
            self._has_displayfd = bool(int(PYVIRTUALDISPLAY_DISPLAYFD))
        else:
            # TODO: macos: displayfd is available on XQuartz-2.7.11 but it doesn't work, always 0 is returned
            if platform_is_osx():
                self._has_displayfd = False

        self._check_flags(helptext)

        if use_xauth and not xauth.is_installed():
            raise xauth.NotFoundError()

        self._use_xauth = use_xauth
        self._old_xauth = None
        self._xauth_filename = None