Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-PyVirtualDisplay for openSUSE:Factory checked in at 2022-11-27 12:52:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-PyVirtualDisplay (Old) and /work/SRC/openSUSE:Factory/.python-PyVirtualDisplay.new.1597 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-PyVirtualDisplay" Sun Nov 27 12:52:57 2022 rev:18 rq:1038366 version:3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-PyVirtualDisplay/python-PyVirtualDisplay.changes 2021-11-09 23:54:10.127939119 +0100 +++ /work/SRC/openSUSE:Factory/.python-PyVirtualDisplay.new.1597/python-PyVirtualDisplay.changes 2022-11-27 12:53:11.831265443 +0100 @@ -1,0 +2,6 @@ +Sat Nov 26 17:51:26 UTC 2022 - Torsten Gruner <simmpho...@opensuse.org> + +- Update to v3.0 + * no release notes + +------------------------------------------------------------------- Old: ---- PyVirtualDisplay-2.2.tar.gz New: ---- PyVirtualDisplay-3.0.tar.gz _multibuild ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-PyVirtualDisplay.spec ++++++ --- /var/tmp/diff_new_pack.2OTzFD/_old 2022-11-27 12:53:12.311268229 +0100 +++ /var/tmp/diff_new_pack.2OTzFD/_new 2022-11-27 12:53:12.315268252 +0100 @@ -1,7 +1,7 @@ # -# spec file for package python-PyVirtualDisplay +# spec file # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,10 +16,18 @@ # +%global flavor @BUILD_FLAVOR@%{nil} +%if "%{flavor}" == "test" +%define psuffix -test +%bcond_without test +%else +%define psuffix %{nil} +%bcond_with test +%endif %{?!python_module:%define python_module() python3-%{**}} %define skip_python2 1 -Name: python-PyVirtualDisplay -Version: 2.2 +Name: python-PyVirtualDisplay%{psuffix} +Version: 3.0 Release: 0 Summary: Python wrapper for Xvfb, Xephyr and Xvnc License: BSD-2-Clause @@ -33,7 +41,9 @@ Suggests: xorg-x11-Xvnc Suggests: xorg-x11-server-extra BuildArch: noarch +%if %{with test} # SECTION test requirements +BuildRequires: %{python_module PyVirtualDisplay} BuildRequires: %{python_module EasyProcess} BuildRequires: %{python_module Pillow} BuildRequires: %{python_module attrs} @@ -46,6 +56,7 @@ BuildRequires: xorg-x11-server-extra BuildRequires: xvfb-run # /SECTION +%endif %python_subpackages %description @@ -58,9 +69,12 @@ %python_build %install +%if !%{with test} %python_install %python_expand %fdupes %{buildroot}%{$python_sitelib} +%endif +%if %{with test} %check donttest="examples or smart" %{python_expand # @@ -68,11 +82,14 @@ xvfb-run --server-args "-screen 0 1920x1080x24" \ $python -m pytest -v tests -rs -k "not ($donttest)" -n auto } +%endif +%if !%{with test} %files %{python_files} %license LICENSE.txt %doc README.md %{python_sitelib}/pyvirtualdisplay %{python_sitelib}/PyVirtualDisplay-%{version}-*info +%endif %changelog ++++++ PyVirtualDisplay-2.2.tar.gz -> PyVirtualDisplay-3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/PKG-INFO new/PyVirtualDisplay-3.0/PKG-INFO --- old/PyVirtualDisplay-2.2/PKG-INFO 2021-05-30 18:52:55.595889800 +0200 +++ new/PyVirtualDisplay-3.0/PKG-INFO 2022-02-13 08:55:10.275886300 +0100 @@ -1,13 +1,13 @@ Metadata-Version: 2.1 Name: PyVirtualDisplay -Version: 2.2 +Version: 3.0 Summary: python wrapper for Xvfb, Xephyr and Xvnc Home-page: https://github.com/ponty/pyvirtualdisplay Author: ponty License: BSD Description: pyvirtualdisplay is a python wrapper for Xvfb, Xephyr and Xvnc - Documentation: https://github.com/ponty/pyvirtualdisplay/tree/2.2 + Documentation: https://github.com/ponty/pyvirtualdisplay/tree/3.0 Keywords: Xvfb Xephyr X wrapper Platform: UNKNOWN Classifier: License :: OSI Approved :: BSD License @@ -20,4 +20,5 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Description-Content-Type: text/x-rst diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/PyVirtualDisplay.egg-info/PKG-INFO new/PyVirtualDisplay-3.0/PyVirtualDisplay.egg-info/PKG-INFO --- old/PyVirtualDisplay-2.2/PyVirtualDisplay.egg-info/PKG-INFO 2021-05-30 18:52:55.000000000 +0200 +++ new/PyVirtualDisplay-3.0/PyVirtualDisplay.egg-info/PKG-INFO 2022-02-13 08:55:10.000000000 +0100 @@ -1,13 +1,13 @@ Metadata-Version: 2.1 Name: PyVirtualDisplay -Version: 2.2 +Version: 3.0 Summary: python wrapper for Xvfb, Xephyr and Xvnc Home-page: https://github.com/ponty/pyvirtualdisplay Author: ponty License: BSD Description: pyvirtualdisplay is a python wrapper for Xvfb, Xephyr and Xvnc - Documentation: https://github.com/ponty/pyvirtualdisplay/tree/2.2 + Documentation: https://github.com/ponty/pyvirtualdisplay/tree/3.0 Keywords: Xvfb Xephyr X wrapper Platform: UNKNOWN Classifier: License :: OSI Approved :: BSD License @@ -20,4 +20,5 @@ Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Description-Content-Type: text/x-rst diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/PyVirtualDisplay.egg-info/SOURCES.txt new/PyVirtualDisplay-3.0/PyVirtualDisplay.egg-info/SOURCES.txt --- old/PyVirtualDisplay-2.2/PyVirtualDisplay.egg-info/SOURCES.txt 2021-05-30 18:52:55.000000000 +0200 +++ new/PyVirtualDisplay-3.0/PyVirtualDisplay.egg-info/SOURCES.txt 2022-02-13 08:55:10.000000000 +0100 @@ -5,12 +5,12 @@ PyVirtualDisplay.egg-info/PKG-INFO PyVirtualDisplay.egg-info/SOURCES.txt PyVirtualDisplay.egg-info/dependency_links.txt -PyVirtualDisplay.egg-info/requires.txt PyVirtualDisplay.egg-info/top_level.txt pyvirtualdisplay/__init__.py pyvirtualdisplay/about.py pyvirtualdisplay/abstractdisplay.py pyvirtualdisplay/display.py +pyvirtualdisplay/py.typed pyvirtualdisplay/smartdisplay.py pyvirtualdisplay/util.py pyvirtualdisplay/xauth.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/PyVirtualDisplay.egg-info/requires.txt new/PyVirtualDisplay-3.0/PyVirtualDisplay.egg-info/requires.txt --- old/PyVirtualDisplay-2.2/PyVirtualDisplay.egg-info/requires.txt 2021-05-30 18:52:55.000000000 +0200 +++ new/PyVirtualDisplay-3.0/PyVirtualDisplay.egg-info/requires.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -EasyProcess diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/README.md new/PyVirtualDisplay-3.0/README.md --- old/PyVirtualDisplay-2.2/README.md 2021-03-21 14:45:01.000000000 +0100 +++ new/PyVirtualDisplay-3.0/README.md 2022-01-26 17:19:50.000000000 +0100 @@ -4,11 +4,11 @@ * home: https://github.com/ponty/pyvirtualdisplay * PYPI: https://pypi.python.org/pypi/pyvirtualdisplay -[](https://travis-ci.org/ponty/pyvirtualdisplay) + Features: - python wrapper - - supported python versions: 3.6, 3.7, 3.8, 3.9 + - supported python versions: 3.6, 3.7, 3.8, 3.9, 3.10 - back-ends: [Xvfb][1], [Xephyr][2] and [Xvnc][3] Possible applications: @@ -31,16 +31,28 @@ $ python3 -m pip install pillow ``` +optional: [EasyProcess][EasyProcess] should be installed for some examples: + +```console +$ python3 -m pip install EasyProcess +``` +optional: xmessage and gnumeric should be installed for some examples. + +On Ubuntu 20.04: +```console +$ sudo apt install x11-utils gnumeric +``` + If you get this error message on Linux then your Pillow version is old. ``` ImportError: ImageGrab is macOS and Windows only ``` -on Ubuntu 20.04: +Install all dependencies and backends on Ubuntu 20.04: ```console -$ sudo apt-get install xvfb xserver-xephyr tigervnc-standalone-server xfonts-base -$ python3 -m pip install pyvirtualdisplay pillow +$ sudo apt-get install xvfb xserver-xephyr tigervnc-standalone-server x11-utils gnumeric +$ python3 -m pip install pyvirtualdisplay pillow EasyProcess ``` Usage @@ -59,7 +71,7 @@ After Xvfb display is activated "DISPLAY" environment variable is set for Xvfb. (e.g. `os.environ["DISPLAY"] = :1`) -After Xvfb display is stopped "DISPLAY" environment variable is restored to its original value. +After Xvfb display is stopped `start()` and `stop()` are not allowed to be called again, "DISPLAY" environment variable is restored to its original value. Controlling the display with context manager: @@ -109,7 +121,7 @@ Headless run ------------ -The display is hidden. +A messagebox is displayed on a hidden display. ```py # pyvirtualdisplay/examples/headless.py @@ -125,6 +137,10 @@ proc.wait() ``` +Run it: +```console +$ python3 -m pyvirtualdisplay.examples.headless +``` If `visible=True` then a nested Xephyr window opens and the GUI can be controlled. @@ -296,34 +312,46 @@ ```py # pyvirtualdisplay/examples/threadsafe.py -"Start Xvfb server. Open xmessage window. Thread safe." +"Start Xvfb server and open xmessage window. Thread safe." + +import threading from easyprocess import EasyProcess -from pyvirtualdisplay import Display +from pyvirtualdisplay.smartdisplay import SmartDisplay -# manage_global_env=False is thread safe -with Display(manage_global_env=False) as disp: - # disp.new_display_var should be used for new processes - print("disp.new_display_var=" + disp.new_display_var) - # disp.env() copies global os.environ and adds disp.new_display_var - print("disp.env()['DISPLAY']=" + disp.env()["DISPLAY"]) - - # set $DISPLAY for subprocesses - with EasyProcess(["xmessage", "-timeout", "1", "hello"], env=disp.env()) as proc: - proc.wait() +def thread_function(index): + # manage_global_env=False is thread safe + with SmartDisplay(manage_global_env=False) as disp: + cmd = ["xmessage", str(index)] + # disp.new_display_var should be used for new processes + # disp.env() copies global os.environ and adds disp.new_display_var + with EasyProcess(cmd, env=disp.env()): + img = disp.waitgrab() + img.save("xmessage{}.png".format(index)) + + +t1 = threading.Thread(target=thread_function, args=(1,)) +t2 = threading.Thread(target=thread_function, args=(2,)) +t1.start() +t2.start() +t1.join() +t2.join() ``` -<!-- embedme doc/gen/python3_-m_pyvirtualdisplay.examples.threadsafe.txt --> + Run it: ```console $ python3 -m pyvirtualdisplay.examples.threadsafe -disp.new_display_var=:2 -disp.env()['DISPLAY']=:2 ``` +Images: + + + + Hierarchy ========= @@ -335,3 +363,4 @@ [3]: https://tigervnc.org/ [pillow]: https://pillow.readthedocs.io [environ]: https://docs.python.org/3/library/os.html#os.environ +[EasyProcess]: https://github.com/ponty/EasyProcess \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/pyvirtualdisplay/about.py new/PyVirtualDisplay-3.0/pyvirtualdisplay/about.py --- old/PyVirtualDisplay-2.2/pyvirtualdisplay/about.py 2021-05-30 18:49:28.000000000 +0200 +++ new/PyVirtualDisplay-3.0/pyvirtualdisplay/about.py 2022-02-12 11:53:19.000000000 +0100 @@ -1 +1 @@ -__version__ = "2.2" +__version__ = "3.0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/pyvirtualdisplay/abstractdisplay.py new/PyVirtualDisplay-3.0/pyvirtualdisplay/abstractdisplay.py --- old/PyVirtualDisplay-2.2/pyvirtualdisplay/abstractdisplay.py 2021-01-25 17:57:19.000000000 +0100 +++ new/PyVirtualDisplay-3.0/pyvirtualdisplay/abstractdisplay.py 2022-01-24 17:46:38.000000000 +0100 @@ -2,14 +2,11 @@ import logging import os import select -import signal import subprocess import tempfile import time from threading import Lock -from easyprocess import EasyProcess, EasyProcessError - from pyvirtualdisplay import xauth from pyvirtualdisplay.util import get_helptext, platform_is_osx @@ -244,17 +241,34 @@ break try: - xdpyinfo = EasyProcess(["xdpyinfo"], env=self._env()) - xdpyinfo.enable_stdout_log = False - xdpyinfo.enable_stderr_log = False - exit_code = xdpyinfo.call().return_code - except EasyProcessError: + xdpyinfo = subprocess.Popen( + ["xdpyinfo"], + env=self._env(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=False, + ) + _, _ = xdpyinfo.communicate() + exit_code = xdpyinfo.returncode + except FileNotFoundError: log.warning( "xdpyinfo was not found, X start can not be checked! Please install xdpyinfo!" ) time.sleep(_X_START_WAIT) # old method ok = True break + # try: + # xdpyinfo = EasyProcess(["xdpyinfo"], env=self._env()) + # xdpyinfo.enable_stdout_log = False + # xdpyinfo.enable_stderr_log = False + # exit_code = xdpyinfo.call().return_code + # except EasyProcessError: + # log.warning( + # "xdpyinfo was not found, X start can not be checked! Please install xdpyinfo!" + # ) + # time.sleep(_X_START_WAIT) # old method + # ok = True + # break if exit_code != 0: pass @@ -276,7 +290,7 @@ def _wait_for_pipe_text(self, rfd): s = "" - # start_time = time.time() + start_time = time.time() while True: (rfd_changed_ls, _, _) = select.select([rfd], [], [], 0.1) if not self.is_alive(): @@ -289,11 +303,16 @@ if c == b"\n": break s += c.decode("ascii") - # if time.time() - start_time >= _X_START_TIMEOUT: - # raise XStartTimeoutError( - # "No reply from program %s. command:%s" - # % (self._program, self._command,) - # ) + + # this timeout is for "eternal" hang. see #62 + if time.time() - start_time >= 600: # = 10 minutes + raise XStartTimeoutError( + "No reply from program %s. command:%s" + % ( + self._program, + self._command, + ) + ) return s def stop(self): @@ -310,10 +329,7 @@ if self.is_alive(): try: - try: - self._subproc.terminate() - except AttributeError: - os.kill(self._subproc.pid, signal.SIGKILL) + self._subproc.kill() except OSError as oserror: log.debug("exception in terminate:%s", oserror) @@ -372,17 +388,22 @@ def is_alive(self): if not self._subproc: return False - return self.return_code is None - - @property - def return_code(self): - if not self._subproc: - return None + # return self.return_code is None rc = self._subproc.poll() if rc is not None: # proc exited self._read_stdout_stderr() - return rc + return rc is None + + # @property + # def return_code(self): + # if not self._subproc: + # return None + # rc = self._subproc.poll() + # if rc is not None: + # # proc exited + # self._read_stdout_stderr() + # return rc @property def pid(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/pyvirtualdisplay/display.py new/PyVirtualDisplay-3.0/pyvirtualdisplay/display.py --- old/PyVirtualDisplay-2.2/pyvirtualdisplay/display.py 2021-01-10 19:02:53.000000000 +0100 +++ new/PyVirtualDisplay-3.0/pyvirtualdisplay/display.py 2022-01-23 23:29:12.000000000 +0100 @@ -17,7 +17,7 @@ :param visible: True -> Xephyr, False -> Xvfb :param backend: 'xvfb', 'xvnc' or 'xephyr', ignores ``visible`` :param xauth: If a Xauthority file should be created. - :param manage_global_env: if True then $DISPLAY is set in os.environ + :param manage_global_env: if True then $DISPLAY is set in os.environ which is not thread-safe. Use False to make it thread-safe. """ @@ -93,9 +93,9 @@ def is_alive(self) -> bool: return self._obj.is_alive() - @property - def return_code(self): - return self._obj.return_code + # @property + # def return_code(self): + # return self._obj.return_code @property def pid(self) -> int: @@ -108,12 +108,12 @@ @property def display(self) -> int: - """The new $DISPLAY variable as int. Example 1 if $DISPLAY=':1' """ + """The new $DISPLAY variable as int. Example 1 if $DISPLAY=':1'""" return self._obj.display @property def new_display_var(self) -> str: - """The new $DISPLAY variable like ':1' """ + """The new $DISPLAY variable like ':1'""" return self._obj.new_display_var def env(self) -> Dict[str, str]: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/pyvirtualdisplay/examples/threadsafe.py new/PyVirtualDisplay-3.0/pyvirtualdisplay/examples/threadsafe.py --- old/PyVirtualDisplay-2.2/pyvirtualdisplay/examples/threadsafe.py 2020-12-30 08:54:24.000000000 +0100 +++ new/PyVirtualDisplay-3.0/pyvirtualdisplay/examples/threadsafe.py 2022-01-23 23:29:12.000000000 +0100 @@ -1,17 +1,26 @@ -"Start Xvfb server. Open xmessage window. Thread safe." +"Start Xvfb server and open xmessage window. Thread safe." + +import threading from easyprocess import EasyProcess -from pyvirtualdisplay import Display +from pyvirtualdisplay.smartdisplay import SmartDisplay + + +def thread_function(index): + # manage_global_env=False is thread safe + with SmartDisplay(manage_global_env=False) as disp: + cmd = ["xmessage", str(index)] + # disp.new_display_var should be used for new processes + # disp.env() copies global os.environ and adds disp.new_display_var + with EasyProcess(cmd, env=disp.env()): + img = disp.waitgrab() + img.save("xmessage{}.png".format(index)) + -# manage_global_env=False is thread safe -with Display(manage_global_env=False) as disp: - # disp.new_display_var should be used for new processes - print("disp.new_display_var=" + disp.new_display_var) - - # disp.env() copies global os.environ and adds disp.new_display_var - print("disp.env()['DISPLAY']=" + disp.env()["DISPLAY"]) - - # set $DISPLAY for subprocesses - with EasyProcess(["xmessage", "-timeout", "1", "hello"], env=disp.env()) as proc: - proc.wait() +t1 = threading.Thread(target=thread_function, args=(1,)) +t2 = threading.Thread(target=thread_function, args=(2,)) +t1.start() +t2.start() +t1.join() +t2.join() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/pyvirtualdisplay/smartdisplay.py new/PyVirtualDisplay-3.0/pyvirtualdisplay/smartdisplay.py --- old/PyVirtualDisplay-2.2/pyvirtualdisplay/smartdisplay.py 2021-01-02 09:22:23.000000000 +0100 +++ new/PyVirtualDisplay-3.0/pyvirtualdisplay/smartdisplay.py 2022-01-23 23:29:12.000000000 +0100 @@ -16,9 +16,9 @@ def autocrop(im, bgcolor): """Crop borders off an image. - :param im: Source image. - :param bgcolor: Background color, using either a color tuple. - :return: An image without borders, or None if there's no actual content in the image. + :param im: Source image. + :param bgcolor: Background color, using either a color tuple. + :return: An image without borders, or None if there's no actual content in the image. """ if im.mode != "RGB": im = im.convert("RGB") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/pyvirtualdisplay/util.py new/PyVirtualDisplay-3.0/pyvirtualdisplay/util.py --- old/PyVirtualDisplay-2.2/pyvirtualdisplay/util.py 2020-12-31 11:34:48.000000000 +0100 +++ new/PyVirtualDisplay-3.0/pyvirtualdisplay/util.py 2022-01-23 23:29:12.000000000 +0100 @@ -1,14 +1,24 @@ +import subprocess import sys -from easyprocess import EasyProcess - def get_helptext(program): - p = EasyProcess([program, "-help"]) - p.enable_stdout_log = False - p.enable_stderr_log = False - p.call() - helptext = p.stderr + cmd = [program, "-help"] + + # py3.7+ + # p = subprocess.run(cmd, capture_output=True) + # stderr = p.stderr + + # py3.6 also + p = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=False, + ) + _, stderr = p.communicate() + + helptext = stderr.decode("utf-8", "ignore") return helptext diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/pyvirtualdisplay/xauth.py new/PyVirtualDisplay-3.0/pyvirtualdisplay/xauth.py --- old/PyVirtualDisplay-2.2/pyvirtualdisplay/xauth.py 2020-06-08 19:27:48.000000000 +0200 +++ new/PyVirtualDisplay-3.0/pyvirtualdisplay/xauth.py 2022-01-23 23:29:12.000000000 +0100 @@ -1,8 +1,7 @@ """Utility functions for xauth.""" import hashlib import os - -from easyprocess import EasyProcess +import subprocess class NotFoundError(Exception): @@ -14,11 +13,18 @@ Return whether or not xauth is installed. """ try: - p = EasyProcess(["xauth", "-V"]) - p.enable_stdout_log = False - p.enable_stderr_log = False - p.call() - except Exception: + xauth = subprocess.Popen( + ["xauth", "-V"], + # env=self._env(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + _, _ = xauth.communicate() + # p = EasyProcess(["xauth", "-V"]) + # p.enable_stdout_log = False + # p.enable_stderr_log = False + # p.call() + except FileNotFoundError: return False else: return True @@ -36,4 +42,11 @@ """ Call xauth with the given args. """ - EasyProcess(["xauth"] + list(args)).call() + xauth = subprocess.Popen( + ["xauth"] + list(args), + # env=self._env(), + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + _, _ = xauth.communicate() + # EasyProcess(["xauth"] + list(args)).call() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/pyvirtualdisplay/xephyr.py new/PyVirtualDisplay-3.0/pyvirtualdisplay/xephyr.py --- old/PyVirtualDisplay-2.2/pyvirtualdisplay/xephyr.py 2021-04-02 22:56:02.000000000 +0200 +++ new/PyVirtualDisplay-3.0/pyvirtualdisplay/xephyr.py 2022-01-23 23:29:12.000000000 +0100 @@ -46,13 +46,17 @@ self._has_resizeable = "-resizeable" in helptext def _cmd(self): - cmd = [ - PROGRAM, - ] + (["-parent", self._parent] if self._parent else []) + [ - dict(black="-br", white="-wr")[self._bgcolor], - "-screen", - "x".join(map(str, list(self._size) + [self._color_depth])), - ] + cmd = ( + [ + PROGRAM, + ] + + (["-parent", self._parent] if self._parent else []) + + [ + dict(black="-br", white="-wr")[self._bgcolor], + "-screen", + "x".join(map(str, list(self._size) + [self._color_depth])), + ] + ) if self._has_displayfd: cmd += ["-displayfd", str(self._pipe_wfd)] else: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/pyvirtualdisplay/xvnc.py new/PyVirtualDisplay-3.0/pyvirtualdisplay/xvnc.py --- old/PyVirtualDisplay-2.2/pyvirtualdisplay/xvnc.py 2020-12-31 23:34:32.000000000 +0100 +++ new/PyVirtualDisplay-3.0/pyvirtualdisplay/xvnc.py 2022-01-23 23:29:12.000000000 +0100 @@ -26,7 +26,9 @@ ): """ :param bgcolor: 'black' or 'white' - :param rfbport: Specifies the TCP port on which Xvnc listens for connections from viewers (the protocol used in VNC is called RFB - "remote framebuffer"). The default is 5900 plus the display number. + :param rfbport: Specifies the TCP port on which Xvnc listens for connections from viewers + (the protocol used in VNC is called RFB - "remote framebuffer"). + The default is 5900 plus the display number. :param rfbauth: Specifies the file containing the password used to authenticate viewers. """ self._size = size diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/setup.py new/PyVirtualDisplay-3.0/setup.py --- old/PyVirtualDisplay-2.2/setup.py 2021-01-12 21:00:52.000000000 +0100 +++ new/PyVirtualDisplay-3.0/setup.py 2022-01-23 23:29:12.000000000 +0100 @@ -35,9 +35,9 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", ] -install_requires = ["EasyProcess"] setup( name=PYPI_NAME, @@ -52,8 +52,8 @@ url=URL, license="BSD", packages=PACKAGES, - # include_package_data=True, - # zip_safe=False, - install_requires=install_requires, - # **extra + # install_requires=install_requires, + package_data={ + NAME: ["py.typed"], + }, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/tests/test_core.py new/PyVirtualDisplay-3.0/tests/test_core.py --- old/PyVirtualDisplay-2.2/tests/test_core.py 2021-01-25 17:57:19.000000000 +0100 +++ new/PyVirtualDisplay-3.0/tests/test_core.py 2022-01-23 23:29:12.000000000 +0100 @@ -1,28 +1,28 @@ from time import sleep import pytest +from tutil import has_xvnc, rfbport from pyvirtualdisplay import Display from pyvirtualdisplay.abstractdisplay import XStartError from pyvirtualdisplay.xephyr import XephyrDisplay from pyvirtualdisplay.xvfb import XvfbDisplay from pyvirtualdisplay.xvnc import XvncDisplay -from tutil import has_xvnc, rfbport def test_virt(): vd = Display() - assert vd.return_code is None + # assert vd.return_code is None assert not vd.is_alive() vd.start() - assert vd.return_code is None + # assert vd.return_code is None assert vd.is_alive() vd.stop() - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() vd = Display().start().stop() - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() @@ -32,7 +32,8 @@ nd = Display(visible=True).start().stop() - assert nd.return_code == 0 + # assert nd.return_code == 0 + assert not nd.is_alive() vd.stop() assert not vd.is_alive() @@ -46,7 +47,8 @@ # .assertEquals(d.return_code, 0) d = Display(visible=False).start().stop() - assert d.return_code == 0 + # assert d.return_code == 0 + assert not d.is_alive() vd.stop() assert not vd.is_alive() @@ -104,21 +106,21 @@ def test_double_stop(): vd = Display().start().stop() - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() vd.stop() - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() def test_stop_terminated(): vd = Display().start() assert vd.is_alive() - vd._obj._subproc.terminate() - sleep(0.2) + vd._obj._subproc.kill() + sleep(1) assert not vd.is_alive() vd.stop() - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/tests/test_examples.py new/PyVirtualDisplay-3.0/tests/test_examples.py --- old/PyVirtualDisplay-2.2/tests/test_examples.py 2020-12-30 20:04:21.000000000 +0100 +++ new/PyVirtualDisplay-3.0/tests/test_examples.py 2022-01-23 23:29:12.000000000 +0100 @@ -5,9 +5,9 @@ from time import sleep from easyprocess import EasyProcess +from tutil import has_xvnc, kill_process_tree, prog_check, worker from pyvirtualdisplay import Display -from tutil import has_xvnc, kill_process_tree, prog_check, worker log = logging.getLogger(__name__) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/tests/test_race.py new/PyVirtualDisplay-3.0/tests/test_race.py --- old/PyVirtualDisplay-2.2/tests/test_race.py 2021-01-26 22:33:58.000000000 +0100 +++ new/PyVirtualDisplay-3.0/tests/test_race.py 2022-01-23 23:29:12.000000000 +0100 @@ -3,9 +3,9 @@ from easyprocess import EasyProcess from entrypoint2 import entrypoint +from tutil import has_xvnc, worker from pyvirtualdisplay import Display -from tutil import has_xvnc, worker # ubuntu 14.04 no displayfd # ubuntu 16.04 displayfd @@ -26,7 +26,6 @@ # check_n(100, "xephyr") - if has_xvnc(): def test_race_10_xvnc(): @@ -77,7 +76,12 @@ d = Display(backend=backend, retries=retries, **kwargs).start() print( "my index:%s backend:%s disp:%s retries:%s" - % (i, backend, d.new_display_var, d._obj._retries_current,) + % ( + i, + backend, + d.new_display_var, + d._obj._retries_current, + ) ) ok = d.is_alive() d.stop() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/tests/test_smart.py new/PyVirtualDisplay-3.0/tests/test_smart.py --- old/PyVirtualDisplay-2.2/tests/test_smart.py 2020-12-31 11:34:48.000000000 +0100 +++ new/PyVirtualDisplay-3.0/tests/test_smart.py 2022-01-23 23:29:12.000000000 +0100 @@ -14,10 +14,12 @@ with Display(): d = SmartDisplay(visible=True).start().stop() - assert d.return_code == 0 + # assert d.return_code == 0 + assert not d.is_alive() d = SmartDisplay(visible=False).start().stop() - assert d.return_code == 0 + # assert d.return_code == 0 + assert not d.is_alive() def test_slowshot(): @@ -75,7 +77,7 @@ with disp: with proc: with pytest.raises(DisplayTimeoutError): - img = disp.waitgrab(timeout=1) + disp.waitgrab(timeout=1) def test_slowshot_timeout_nocrop(): @@ -85,4 +87,4 @@ with disp: with proc: with pytest.raises(DisplayTimeoutError): - img = disp.waitgrab(timeout=1, autocrop=False) + disp.waitgrab(timeout=1, autocrop=False) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/tests/test_with.py new/PyVirtualDisplay-3.0/tests/test_with.py --- old/PyVirtualDisplay-2.2/tests/test_with.py 2020-06-28 18:51:17.000000000 +0200 +++ new/PyVirtualDisplay-3.0/tests/test_with.py 2022-01-23 23:29:12.000000000 +0100 @@ -1,24 +1,25 @@ -from pyvirtualdisplay import Display from tutil import has_xvnc, rfbport +from pyvirtualdisplay import Display + def test_with_xvfb(): with Display(size=(800, 600)) as vd: assert vd.is_alive() assert vd._backend == "xvfb" - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() with Display(visible=False, size=(800, 600)) as vd: assert vd.is_alive() assert vd._backend == "xvfb" - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() with Display(backend="xvfb", size=(800, 600)) as vd: assert vd.is_alive() assert vd._backend == "xvfb" - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() @@ -27,13 +28,13 @@ with Display(visible=True, size=(800, 600)) as vd: assert vd.is_alive() assert vd._backend == "xephyr" - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() with Display(backend="xephyr", size=(800, 600)) as vd: assert vd.is_alive() assert vd._backend == "xephyr" - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() @@ -43,12 +44,12 @@ with Display(backend="xvnc", size=(800, 600), rfbport=rfbport()) as vd: assert vd.is_alive() assert vd._backend == "xvnc" - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() def test_dpi(): with Display(backend="xvfb", size=(800, 600), dpi=99) as vd: assert vd.is_alive() - assert vd.return_code == 0 + # assert vd.return_code == 0 assert not vd.is_alive() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/tests/test_xauth.py new/PyVirtualDisplay-3.0/tests/test_xauth.py --- old/PyVirtualDisplay-2.2/tests/test_xauth.py 2020-06-08 19:27:48.000000000 +0200 +++ new/PyVirtualDisplay-3.0/tests/test_xauth.py 2022-01-23 23:29:12.000000000 +0100 @@ -1,26 +1,29 @@ import os +from tutil import prog_check + from pyvirtualdisplay import Display, xauth +if prog_check(["xauth", "-V"]): + + def test_xauth_is_installed(): + assert xauth.is_installed() + + def test_xauth(): + """ + Test that a Xauthority file is created. + """ + old_xauth = os.getenv("XAUTHORITY") + display = Display(visible=False, use_xauth=True) + display.start() + new_xauth = os.getenv("XAUTHORITY") + + assert new_xauth is not None + assert os.path.isfile(new_xauth) + filename = os.path.basename(new_xauth) + assert filename.startswith("PyVirtualDisplay.") + assert filename.endswith("Xauthority") -def test_xauth(): - """ - Test that a Xauthority file is created. - """ - if not xauth.is_installed(): - print("This test needs xauth installed") - return - old_xauth = os.getenv("XAUTHORITY") - display = Display(visible=False, use_xauth=True) - display.start() - new_xauth = os.getenv("XAUTHORITY") - - assert new_xauth is not None - assert os.path.isfile(new_xauth) - filename = os.path.basename(new_xauth) - assert filename.startswith("PyVirtualDisplay.") - assert filename.endswith("Xauthority") - - display.stop() - assert old_xauth == os.getenv("XAUTHORITY") - assert not os.path.isfile(new_xauth) + display.stop() + assert old_xauth == os.getenv("XAUTHORITY") + assert not os.path.isfile(new_xauth) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/tests/test_xvnc.py new/PyVirtualDisplay-3.0/tests/test_xvnc.py --- old/PyVirtualDisplay-2.2/tests/test_xvnc.py 2020-12-31 13:37:22.000000000 +0100 +++ new/PyVirtualDisplay-3.0/tests/test_xvnc.py 2022-01-23 23:29:12.000000000 +0100 @@ -1,11 +1,11 @@ import tempfile from pathlib import Path +from tutil import has_xvnc, rfbport, worker from vncdotool import api from pyvirtualdisplay import Display from pyvirtualdisplay.xvnc import XvncDisplay -from tutil import has_xvnc, rfbport, worker if has_xvnc(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/PyVirtualDisplay-2.2/tests/vagrant/vagrant_boxes.py new/PyVirtualDisplay-3.0/tests/vagrant/vagrant_boxes.py --- old/PyVirtualDisplay-2.2/tests/vagrant/vagrant_boxes.py 2021-01-25 20:10:13.000000000 +0100 +++ new/PyVirtualDisplay-3.0/tests/vagrant/vagrant_boxes.py 2022-02-12 10:20:30.000000000 +0100 @@ -4,12 +4,13 @@ from time import sleep import fabric -import vagrant from entrypoint2 import entrypoint +import vagrant + # pip3 install fabric vncdotool python-vagrant entrypoint2 -DIR = Path(__file__).parent.parent.parent +DIR = Path(__file__).parent class Options: @@ -20,11 +21,12 @@ def run_box(options, vagrantfile, cmds): env = os.environ - env["VAGRANT_VAGRANTFILE"] = str(DIR / vagrantfile) - if vagrantfile != "Vagrantfile": - env["VAGRANT_DOTFILE_PATH"] = str(DIR / (".vagrant_" + vagrantfile)) - else: + if vagrantfile == "Vagrantfile": + env["VAGRANT_VAGRANTFILE"] = str(DIR.parent.parent / vagrantfile) env["VAGRANT_DOTFILE_PATH"] = "" + else: + env["VAGRANT_VAGRANTFILE"] = str(DIR / vagrantfile) + env["VAGRANT_DOTFILE_PATH"] = str(DIR / (".vagrant_" + vagrantfile)) v = vagrant.Vagrant(env=env, quiet_stdout=False, quiet_stderr=False) status = v.status() @@ -49,7 +51,10 @@ v.up() with fabric.Connection( - v.user_hostname_port(), connect_kwargs={"key_filename": v.keyfile(),}, + v.user_hostname_port(), + connect_kwargs={ + "key_filename": v.keyfile(), + }, ) as conn: with conn.cd("c:/vagrant" if options.win else "/vagrant"): if not options.win: @@ -71,16 +76,33 @@ config = { - "server2004": ("Vagrantfile", ["tox", "PYVIRTUALDISPLAY_DISPLAYFD=0 tox"],), - "server1804": ("Vagrantfile.18.04.rb", ["tox"],), - "server1404": ("Vagrantfile.14.04.rb", ["tox -e py36"],), - "osx": ( - "Vagrantfile.osx.rb", - [ - "bash --login -c 'python3 -m tox -e py3-osx'", - # TODO: "bash --login -c 'PYVIRTUALDISPLAY_DISPLAYFD=0 python3 -m tox -e py3-osx'", - ], + "debian10": ( + "Vagrantfile.debian10.rb", + ["tox -e py37"], + ), + "debian11": ( + "Vagrantfile.debian11.rb", + ["tox -e py39"], + ), + "ubuntu2204": ( + "Vagrantfile.ubuntu2204.rb", + ["tox -e py39"], ), + "ubuntu2004": ( + "Vagrantfile", + ["tox", "PYVIRTUALDISPLAY_DISPLAYFD=0 tox"], + ), + "ubuntu1804": ( + "Vagrantfile.ubuntu1804.rb", + ["tox -e py36"], + ), + # "osx": ( + # "Vagrantfile.osx.rb", + # [ + # "bash --login -c 'python3 -m tox -e py3-osx'", + # # TODO: "bash --login -c 'PYVIRTUALDISPLAY_DISPLAYFD=0 python3 -m tox -e py3-osx'", + # ], + # ), } @@ -95,9 +117,23 @@ boxes = list(config.keys()) else: boxes = boxes.split(",") + for k, v in config.items(): - if k in boxes: - options.win = k == "win" - options.osx = k == "osx" - print("-----> %s %s %s" % (k, v[0], v[1])) - run_box(options, v[0], v[1]) + name = k + vagrantfile, cmds = v[0], v[1] + if name in boxes: + options.win = k.startswith("win") + options.osx = k.startswith("osx") + print("----->") + print("----->") + print("-----> %s %s %s" % (name, vagrantfile, cmds)) + print("----->") + print("----->") + try: + run_box(options, vagrantfile, cmds) + finally: + print("<-----") + print("<-----") + print("<----- %s %s %s" % (name, vagrantfile, cmds)) + print("<-----") + print("<-----") ++++++ _multibuild ++++++ <multibuild> <package>test</package> </multibuild>