Skip to content

Commit

Permalink
remove EasyProcess dependency #47 #48
Browse files Browse the repository at this point in the history
  • Loading branch information
ponty committed Jan 23, 2022
1 parent 735286a commit 5d699fd
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def thread_function(index):
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()) as proc:
with EasyProcess(cmd, env=disp.env()):
img = disp.waitgrab()
img.save("xmessage{}.png".format(index))

Expand Down
29 changes: 22 additions & 7 deletions pyvirtualdisplay/abstractdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import time
from threading import Lock

from easyprocess import EasyProcess, EasyProcessError

from pyvirtualdisplay import xauth
from pyvirtualdisplay.util import get_helptext, platform_is_osx

Expand Down Expand Up @@ -244,17 +242,34 @@ def _start1(self):
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
Expand Down
24 changes: 17 additions & 7 deletions pyvirtualdisplay/util.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 2 additions & 1 deletion requirements-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ vncdotool==0.13.0
# psutil
# for travis xenial
# attrs
# pytest-xdist
# pytest-xdist
EasyProcess
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ attrs
pytest-xdist
mypy
flake8
EasyProcess
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"Programming Language :: Python :: 3.10",
]

install_requires = ["EasyProcess"]

setup(
name=PYPI_NAME,
Expand All @@ -53,7 +52,7 @@
url=URL,
license="BSD",
packages=PACKAGES,
install_requires=install_requires,
# install_requires=install_requires,
package_data={
NAME: ["py.typed"],
},
Expand Down

0 comments on commit 5d699fd

Please sign in to comment.