Comments (4)
I checked the environment variables with my current terminal (myenv) and inside the tox pytest process (testenv). These are the common environment variables:
key my test
----------- -------------------------------------------------- --------------------------------------------------
LANG en_US.UTF-8 en_US.UTF-8
TERM xterm-256color xterm-256color
PATH /home/niko/.local/bin:/home/niko/venvs/wakepy/bin: /home/niko/tmp/repos/wakepy/.tox/py310/bin:/home/n
VIRTUAL_ENV /home/niko/venvs/wakepy /home/niko/tmp/repos/wakepy/.tox/py310
HOME /home/niko /home/niko
These are the environment variables specific to the test environment:
key test
----------------------------- -----------------------------------------------------------------------------
LINES 26
TOX_PACKAGE /home/niko/tmp/repos/wakepy/.tox/.tmp/package/5/wakepy-0.6.0-py3-none-any.whl
TOX_ENV_NAME py310
PYTHONHASHSEED 424929341
PYTHONIOENCODING utf-8
TOX_ENV_DIR /home/niko/tmp/repos/wakepy/.tox/py310
PYTEST_CURRENT_TEST tests/test_wakepy.py::test_import_set_and_unset_keeepawake (call)
COLUMNS 156
PIP_DISABLE_PIP_VERSION_CHECK 1
TOX_WORK_DIR /home/niko/tmp/repos/wakepy/.tox
The test environment is really missing the environment variable DBUS_SESSION_BUS_ADDRESS
. It is set on my current terminal to:
$ echo $DBUS_SESSION_BUS_ADDRESS
unix:path=/run/user/1000/bus
from wakepy.
Wakepy 0.6.0 uses by default the Inhibit/Uninhibit methods of the org.freedesktop.Screensaver interface of the session D-Bus.
Reading at Well-known Message Bus Instances from D-Bus Specification:
The address of the login session message bus is given in the DBUS_SESSION_BUS_ADDRESS environment variable.
When using a breakpoint inside the test (tox+pytest), I can see that the dbus is running:
(Pdb) os.system('ps -x | grep dbus')
1107 ? Ss 0:03 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
1246 ? S 0:00 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 11 --address=un
14110 pts/0 S+ 0:00 sh -c ps -x | grep dbus
14113 pts/0 S+ 0:00 grep dbus
0
but there is no DBUS_SESSION_BUS_ADDRESS
environment variable:
(Pdb) pprint.pprint(dict(os.environ))
{'COLUMNS': '151',
'HOME': '/home/niko',
'LANG': 'en_US.UTF-8',
'LINES': '15',
'PATH': '/home/niko/tmp/repos/wakepy/.tox/py310/bin:/home/niko/.local/bin:/home/niko/venvs/wakepy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin',
'PIP_DISABLE_PIP_VERSION_CHECK': '1',
'PYTEST_CURRENT_TEST': 'tests/test_wakepy.py::test_import_set_and_unset_keeepawake '
'(call)',
'PYTHONHASHSEED': '1404011170',
'PYTHONIOENCODING': 'utf-8',
'TERM': 'xterm-256color',
'TOX_ENV_DIR': '/home/niko/tmp/repos/wakepy/.tox/py310',
'TOX_ENV_NAME': 'py310',
'TOX_PACKAGE': '/home/niko/tmp/repos/wakepy/.tox/.tmp/package/11/wakepy-0.6.0-py3-none-any.whl',
'TOX_WORK_DIR': '/home/niko/tmp/repos/wakepy/.tox',
'VIRTUAL_ENV': '/home/niko/tmp/repos/wakepy/.tox/py310'}
(Pdb) os.environ['DBUS_SESSION_BUS_ADDRESS']
*** KeyError: 'DBUS_SESSION_BUS_ADDRESS'
from wakepy.
This can be fixed with adding DBUS_SESSION_BUS_ADDRESS
to pass_env
of the corresponding tox.ini section. For example:
[testenv]
description = run the tests with pytest
package = wheel
wheel_build_env = .pkg
pass_env =
DBUS_SESSION_BUS_ADDRESS
This way tox will pass the environment variable DBUS_SESSION_BUS_ADDRESS
which contains the session D-Bus address, to the process running the test.
from wakepy.
The reason for the exception is now clear. User should always pass the DBUS_SESSION_BUS_ADDRESS
environment variable to subprocess if using wakepy with dbus method in subprocesses. I'll close this one since there are these new tickets that should make usage of wakepy more convenient:
I'm also considering if there should be some automation trying to get the DBUS_SESSION_BUS_ADDRESS
from the parent python process or the dbus-daemon process. but that seems a bit hacky.
from wakepy.
Related Issues (20)
- inv test failing on Windows
- Code coverage not shown on windows (inv test)
- Importing wakeypy nukes logging config HOT 3
- GitHub Releases are not shown (except to repo owner) HOT 3
- There's still one place calling the log methods of the logging module directly (logging.info())
- Publish also to conda-forge?
- Rename the CLI flags: Have same naming convention everywhere. --keep-presenting and -r
- Android support
- Add support for BSD systems HOT 3
- Keep a remote server awake after closing SSH connection? HOT 2
- Improve Supported Platforms table
- Wakepy on browser (Pyodide, PyPy.js, Brython, Transcrypt, Skulpt)
- Add support for cygwin
- Add support for ChromeOS
- Add to docs: "Prior to Windows 11 power requests were held an additional 2 minutes after they were dropped by the application. "
- Update migration guide: Add on_fail action example
- Docs: Tell that (most of?) the wakepy Methods will keep the idle/sleep timer at zero for the duration of the context manager
- Conditionally using wakepy modes
- on_success / on_activation hook? (similar to on_fail)
- Include `on_fail="warn"` in the examples of the README / docs?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wakepy.