mosquito / cysystemd Goto Github PK
View Code? Open in Web Editor NEWsystemd wrapper on Cython
License: Apache License 2.0
systemd wrapper on Cython
License: Apache License 2.0
python3.7 -m pip install systemd
Collecting systemd
Downloading https://files.pythonhosted.org/packages/d4/c2/2195b049effd866b5d26926e672be83fc6f3263aa71ea0639e8eab44851
e/systemd-0.16.1.tar.gz (173kB)
|████████████████████████████████| 174kB 2.8MB/s
Building wheels for collected packages: systemd
Building wheel for systemd (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-t02fpw57/sy
stemd/setup.py'"'"'; __file__='"'"'/tmp/pip-install-t02fpw57/systemd/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"',
open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'
"'))' bdist_wheel -d /tmp/pip-wheel-ampnr8_x --python-tag cp37
cwd: /tmp/pip-install-t02fpw57/systemd/
Complete output (19 lines):
/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'build_requires'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/systemd
copying systemd/__init__.py -> build/lib.linux-x86_64-3.7/systemd
copying systemd/daemon.py -> build/lib.linux-x86_64-3.7/systemd
copying systemd/journal.py -> build/lib.linux-x86_64-3.7/systemd
running build_ext
building 'systemd._daemon' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/systemd
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-st
rong -Wformat -Werror=format-security -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTI
FY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c systemd/_daemon.c -o build/temp.linux-x86_64-3.7/systemd/_daemon.o
systemd/_daemon.c:20:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for systemd
Running setup.py clean for systemd
Failed to build systemd
Installing collected packages: syste
from systemd.daemon import notify, Notification
That doesn't work: ImportError: cannot import name 'Notification'
I'm calling it as notify('READY=1')
, but please do put examples that work.
I got the following failure, switched back to 1.4.8 and pip install worked
An error occurred while installing cysystemd==1.5.2 --hash=sha256:c9701b260d7746fa3daca3bd3cbedc58c12bba094288e12d27fb840b443d7238! Will try again.
Installing initially failed dependencies...
[InstallError]: File "/home/jcormier/.local/lib/python3.8/site-packages/pipenv/cli/command.py", line 233, in install
[InstallError]: retcode = do_install(
[InstallError]: File "/home/jcormier/.local/lib/python3.8/site-packages/pipenv/core.py", line 2193, in do_install
[InstallError]: do_init(
[InstallError]: File "/home/jcormier/.local/lib/python3.8/site-packages/pipenv/core.py", line 1304, in do_init
[InstallError]: do_install_dependencies(
[InstallError]: File "/home/jcormier/.local/lib/python3.8/site-packages/pipenv/core.py", line 899, in do_install_dependencies
[InstallError]: batch_install(
[InstallError]: File "/home/jcormier/.local/lib/python3.8/site-packages/pipenv/core.py", line 796, in batch_install
[InstallError]: _cleanup_procs(procs, failed_deps_queue, retry=retry)
[InstallError]: File "/home/jcormier/.local/lib/python3.8/site-packages/pipenv/core.py", line 703, in _cleanup_procs
[InstallError]: raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: Collecting cysystemd==1.5.2
[pipenv.exceptions.InstallError]: Using cached cysystemd-1.5.2.tar.gz (201 kB)
[pipenv.exceptions.InstallError]: Building wheels for collected packages: cysystemd
[pipenv.exceptions.InstallError]: Building wheel for cysystemd (setup.py): started
[pipenv.exceptions.InstallError]: Building wheel for cysystemd (setup.py): finished with status 'error'
[pipenv.exceptions.InstallError]: ERROR: Command errored out with exit status 1:
[pipenv.exceptions.InstallError]: command: /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-i0nd1nkt/cysystemd_784bfb2d3df54afcbd7ffa7975a21b69/setup.py'"'"'; __file__='"'"'/tmp/pip-install-i0nd1nkt/cysystemd_784bfb2d3df54afcbd7ffa7975a21b69/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-cfosfpqb
[pipenv.exceptions.InstallError]: cwd: /tmp/pip-install-i0nd1nkt/cysystemd_784bfb2d3df54afcbd7ffa7975a21b69/
[pipenv.exceptions.InstallError]: Complete output (25 lines):
[pipenv.exceptions.InstallError]: /home/jcormier/.pyenv/versions/3.6.9/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'build_requires'
[pipenv.exceptions.InstallError]: warnings.warn(msg)
[pipenv.exceptions.InstallError]: running bdist_wheel
[pipenv.exceptions.InstallError]: running build
[pipenv.exceptions.InstallError]: running build_py
[pipenv.exceptions.InstallError]: creating build
[pipenv.exceptions.InstallError]: creating build/lib.linux-x86_64-3.6
[pipenv.exceptions.InstallError]: creating build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: copying cysystemd/__init__.py -> build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: copying cysystemd/async_reader.py -> build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: copying cysystemd/daemon.py -> build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: copying cysystemd/journal.py -> build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: copying cysystemd/py.typed -> build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: warning: build_py: byte-compiling is disabled, skipping.
[pipenv.exceptions.InstallError]:
[pipenv.exceptions.InstallError]: running build_ext
[pipenv.exceptions.InstallError]: building 'cysystemd._daemon' extension
[pipenv.exceptions.InstallError]: creating build/temp.linux-x86_64-3.6
[pipenv.exceptions.InstallError]: creating build/temp.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/include -I/home/jcormier/.pyenv/versions/3.6.9/include/python3.6m -c cysystemd/_daemon.c -o build/temp.linux-x86_64-3.6/cysystemd/_daemon.o
[pipenv.exceptions.InstallError]: cysystemd/_daemon.c:634:10: fatal error: systemd/sd-daemon.h: No such file or directory
[pipenv.exceptions.InstallError]: 634 | #include <systemd/sd-daemon.h>
[pipenv.exceptions.InstallError]: | ^~~~~~~~~~~~~~~~~~~~~
[pipenv.exceptions.InstallError]: compilation terminated.
[pipenv.exceptions.InstallError]: error: command 'gcc' failed with exit status 1
[pipenv.exceptions.InstallError]: ----------------------------------------
[pipenv.exceptions.InstallError]: ERROR: Failed building wheel for cysystemd
[pipenv.exceptions.InstallError]: Running setup.py clean for cysystemd
[pipenv.exceptions.InstallError]: Failed to build cysystemd
[pipenv.exceptions.InstallError]: Installing collected packages: cysystemd
[pipenv.exceptions.InstallError]: Attempting uninstall: cysystemd
[pipenv.exceptions.InstallError]: Found existing installation: cysystemd 1.4.8
[pipenv.exceptions.InstallError]: Uninstalling cysystemd-1.4.8:
[pipenv.exceptions.InstallError]: Successfully uninstalled cysystemd-1.4.8
[pipenv.exceptions.InstallError]: Running setup.py install for cysystemd: started
[pipenv.exceptions.InstallError]: Running setup.py install for cysystemd: finished with status 'error'
[pipenv.exceptions.InstallError]: ERROR: Command errored out with exit status 1:
[pipenv.exceptions.InstallError]: command: /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-i0nd1nkt/cysystemd_784bfb2d3df54afcbd7ffa7975a21b69/setup.py'"'"'; __file__='"'"'/tmp/pip-install-i0nd1nkt/cysystemd_784bfb2d3df54afcbd7ffa7975a21b69/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-04q573_0/install-record.txt --single-version-externally-managed --compile --install-headers /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/include/site/python3.6/cysystemd
[pipenv.exceptions.InstallError]: cwd: /tmp/pip-install-i0nd1nkt/cysystemd_784bfb2d3df54afcbd7ffa7975a21b69/
[pipenv.exceptions.InstallError]: Complete output (25 lines):
[pipenv.exceptions.InstallError]: /home/jcormier/.pyenv/versions/3.6.9/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'build_requires'
[pipenv.exceptions.InstallError]: warnings.warn(msg)
[pipenv.exceptions.InstallError]: running install
[pipenv.exceptions.InstallError]: running build
[pipenv.exceptions.InstallError]: running build_py
[pipenv.exceptions.InstallError]: creating build
[pipenv.exceptions.InstallError]: creating build/lib.linux-x86_64-3.6
[pipenv.exceptions.InstallError]: creating build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: copying cysystemd/__init__.py -> build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: copying cysystemd/async_reader.py -> build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: copying cysystemd/daemon.py -> build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: copying cysystemd/journal.py -> build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: copying cysystemd/py.typed -> build/lib.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: warning: build_py: byte-compiling is disabled, skipping.
[pipenv.exceptions.InstallError]:
[pipenv.exceptions.InstallError]: running build_ext
[pipenv.exceptions.InstallError]: building 'cysystemd._daemon' extension
[pipenv.exceptions.InstallError]: creating build/temp.linux-x86_64-3.6
[pipenv.exceptions.InstallError]: creating build/temp.linux-x86_64-3.6/cysystemd
[pipenv.exceptions.InstallError]: gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/include -I/home/jcormier/.pyenv/versions/3.6.9/include/python3.6m -c cysystemd/_daemon.c -o build/temp.linux-x86_64-3.6/cysystemd/_daemon.o
[pipenv.exceptions.InstallError]: cysystemd/_daemon.c:634:10: fatal error: systemd/sd-daemon.h: No such file or directory
[pipenv.exceptions.InstallError]: 634 | #include <systemd/sd-daemon.h>
[pipenv.exceptions.InstallError]: | ^~~~~~~~~~~~~~~~~~~~~
[pipenv.exceptions.InstallError]: compilation terminated.
[pipenv.exceptions.InstallError]: error: command 'gcc' failed with exit status 1
[pipenv.exceptions.InstallError]: ----------------------------------------
[pipenv.exceptions.InstallError]: Rolling back uninstall of cysystemd
[pipenv.exceptions.InstallError]: Moving to /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/lib/python3.6/site-packages/cysystemd-1.4.8.dist-info/
[pipenv.exceptions.InstallError]: from /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/lib/python3.6/site-packages/~ysystemd-1.4.8.dist-info
[pipenv.exceptions.InstallError]: Moving to /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/lib/python3.6/site-packages/cysystemd.libs/
[pipenv.exceptions.InstallError]: from /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/lib/python3.6/site-packages/~ysystemd.libs
[pipenv.exceptions.InstallError]: Moving to /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/lib/python3.6/site-packages/cysystemd/
[pipenv.exceptions.InstallError]: from /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/lib/python3.6/site-packages/~ysystemd
[pipenv.exceptions.InstallError]: ERROR: Command errored out with exit status 1: /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-i0nd1nkt/cysystemd_784bfb2d3df54afcbd7ffa7975a21b69/setup.py'"'"'; __file__='"'"'/tmp/pip-install-i0nd1nkt/cysystemd_784bfb2d3df54afcbd7ffa7975a21b69/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-04q573_0/install-record.txt --single-version-externally-managed --compile --install-headers /home/jcormier/.local/share/virtualenvs/django_media_server-vqKUXq1I/include/site/python3.6/cysystemd Check the logs for full command output.
ERROR: Couldn't install package: cysystemd
In #39, the project now builds wheels for arm64 (aarch64) platform, which is great 🎉
However, PyPI only contains the amd64 (x86_64) variants: would it be possible to also provide all the wheels from the latest releases directly through PyPI?
I had a look both at the Travis and GitHub Actions workflow, but I couldn't find if the upload to PyPI was automated or not.
Let me know if I can help!
pip install systemd==0.16.1
on Python 3.11 explodes with tons of C warnings and errors. Apparently Python ABI changed and none of those changes are yet compensated to this library.
Partial list includes:
cython_utility: In function ‘__Pyx_ParseOptionalKeywords’:
652 | static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
| ^~~~~~~~~~~~~~~~~~
cython_utility:524:21: warning: ‘PyUnicode_GET_SIZE’ is deprecated [-Wdeprecated-dec
larations]
cython_utility: In function ‘__Pyx_CreateCodeObjectForTraceback’:
cython_utility:786:9: warning: passing argument 14 of ‘PyCode_New’ makes pointer fro
m integer without a cast [-Wint-conversion]
systemd/_daemon.c:215:72: note: in definition of macro ‘__Pyx_PyCode_New’
215 | PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline
, lnos)
/usr/include/python3.11/cpython/code.h:151:45: note: expected ‘int’ but argument is
of type ‘PyObject *’ {aka ‘struct _object *’}
151 | PyObject *, PyObject *, PyObject *, int, PyObject *,
| ^~~
systemd/_daemon.c:215:11: error: too few arguments to function ‘PyCode_New’
215 | PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline
, lnos)
cython_utility: In function ‘__Pyx_AddTraceback’:
systemd/_daemon.c:322:62: error: invalid use of incomplete typedef ‘PyFrameObject’ {aka ‘struct _frame’}
322 | #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
journal.send(....,priority=journal.priority.DEBUG)
produces a journal record with PRIORITY=7
.
The journal record has PRIORITY=Priority.DEBUG
.
The README offers this example of using send()
journal.send(
message="Hello Lennart",
priority=journal.Priority.INFO,
some_field='some value',
)
However, the priority is not serialised as an integer. I'm unsure if just the example should be changed, or if this behaviour is a bug to be fixed in the library.
Instead one would need to use priority=journal.Priority.INFO.value
, or priority=int(journal.Priority.INFO)
.
:~/tmp$ uname -a
Linux martha 5.8.0-53-generic #60~20.04.1-Ubuntu SMP Thu May 6 09:52:46 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
:~/tmp$ journalctl --version
systemd 245 (245.4-4ubuntu3.6)
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid
:~/tmp$ ./systemd/bin/python
>>> import cysystemd
>>> cysystemd.version_info
(1, 4, 8)
>>> from cysystemd import journal
>>> journal.send(message="Just a flesh wound", priority=journal.Priority.DEBUG, syslog_identifier='black knight')
0
>>>
:~/tmp$ journalctl --no-pager --full --identifier='black knight' -o verbose
-- Logs begin at Fri 2020-05-15 13:14:09 BST, end at Tue 2021-06-15 21:20:19 BST. --
Tue 2021-06-15 21:19:43.802228 BST [s=8c9c9f6a3b7d4f3fb0d9f33edecfc3db;i=3dfd;b=774f5fb5dec74c8d830aa399e305e89e;m=3d186d25fd;t=5c4d3b1ce93be;x=b47a586399ed977d]
_TRANSPORT=journal
_UID=1000
_GID=1000
_CAP_EFFECTIVE=0
_SELINUX_CONTEXT=unconfined
_AUDIT_SESSION=5
_AUDIT_LOGINUID=1000
_SYSTEMD_OWNER_UID=1000
[email protected]
_SYSTEMD_SLICE=user-1000.slice
_SYSTEMD_USER_SLICE=-.slice
_BOOT_ID=774f5fb5dec74c8d830aa399e305e89e
_MACHINE_ID=760cf559aeae419e87c1f63c1b40b5e2
_HOSTNAME=martha
_EXE=/usr/bin/python3.8
_COMM=python
_SYSTEMD_CGROUP=/user.slice/user-1000.slice/[email protected]/gnome-launched-code.desktop-205908.scope
_SYSTEMD_USER_UNIT=gnome-launched-code.desktop-205908.scope
_SYSTEMD_INVOCATION_ID=85fc4b98b79145599e1803c600674d3b
PRIORITY=Priority.DEBUG
CODE_FILE=cysystemd/_journal.pyx
CODE_LINE=62
CODE_FUNC=__pyx_f_9cysystemd_8_journal__send
MESSAGE=Just a flesh wound
SYSLOG_IDENTIFIER=black knight
_PID=233760
_CMDLINE=./systemd/bin/python
_SOURCE_REALTIME_TIMESTAMP=1623788383802228
On a system that previously used 0.16.1, scripts now fail to work, as:
ModuleNotFoundError: No module named 'systemd.daemon'; 'systemd' is not a package
Hi!
install ok
alex@orangepipcplus:~$ sudo -H pip3.7 install cysystemd
Collecting cysystemd
Downloading https://files.pythonhosted.org/packages/b7/64/9ab14a4682c39a5be35d99743f86a9d1b0c8955217bb7957d6af910e880a/cysystemd-1.1.0.tar.gz (193kB)
100% |████████████████████████████████| 194kB 1.5MB/s
Installing collected packages: cysystemd
Running setup.py install for cysystemd ... done
Successfully installed cysystemd-1.1.0
Example "Polling records" works fine.
"Read only cron logs" with errors:
Traceback (most recent call last):
File "/home/alex/CSH/tests/journal.py", line 10, in <module>
cron_reader.add_filter(rules)
File "cysystemd/reader.pyx", line 489, in cysystemd.reader.JournalReader.add_filter
File "cysystemd/reader.pyx", line 122, in __iter__
File "cysystemd/reader.pyx", line 134, in cysystemd.reader.check_error_code
SystemError: ('Invalid argument', 'EINVAL')
Process finished with exit code 1
I have a script which reads logs from journal in a loop: https://github.com/PaulAnnekov/log-trigger/blob/d7e55fb29584286d7cdb4170caad5c422bfda334/log_trigger.py#L189. It was working fine, until I was using ubuntu 18.04 (systemd 237). But when I upgraded to ubuntu 22.04 (systemd 249), it can't read the fresh logs generated after the upgrade.
I started to dig around and found that the problem is probably in pre-built wheels of the package. I was using them instead of building from sources. Looks like it was built on older version of the systemd library which just can't read the newer format of the logs. E.g. systemd 246 introduced the incompatible change:
systemd-journald gained support for zstd compression of large fields
in journal files. The hash tables in journal files have been hardened
against hash collisions. This is an incompatible change and means
that journal files created with new systemd versions are not readable
with old versions. If the $SYSTEMD_JOURNAL_KEYED_HASH boolean
environment variable for systemd-journald.service is set to 0 this
new hardening functionality may be turned off, so that generated
journal files remain compatible with older journalctl
implementations.
I started to build the package from sources and it works. Probably, you need to upgrade the CI to build using newer version of the systemd.
I saw you store wheels on GitHub releases pages, and only the source is uploaded to PyPi.
Would you be interested in a GitHub workflow to do the whole work of compiling + publishing everything to PyPi? It would ease the life of all users :)
I have an application that uses cysystemd.JournalReader to read and report systemd log entries. I noticed that the timestamps were off by 4 hours (I am GMT-4).
After looking into the issue we concluded that changing our usage from
entry.date.timestamp()
to
entry.date.replace(tzinfo=timezone.utc).timestamp()
resolved the issue.
I did some reading into the cysystemd code and noticed that you attempt to correct for this here https://github.com/mosquito/cysystemd/blob/master/cysystemd/reader.pyx#L248-L249
But do so unsuccessfully because datetime.replace
returns a new object that you do not capture.
The line in question could be updated to date = datetime.fromtimestamp(self.get_realtime_sec(), timezone.utc)
to resolve the issue.
Or the two liner version would be
date = datetime.utcfromtimestamp(self.get_realtime_sec())
date = date.replace(tzinfo=timezone.utc)
STATUS message never appears in journal...
May 17 02:26:46 [redacted] python[1748]: [41B blob data]
May 17 02:26:46 [redacted] python[1748]: [42B blob data]
May 17 02:26:47 [redacted] python[1748]: [42B blob data]
Just get these blob data things. The READY/start STOPPING states appear in the logs as expected. Unit is set to Type=notify of course.
Thanks for the release, however it seems that the NOR ~> OR didn't make it.
>>> cysystemd.__version__
'1.4.3'
>>> dir(cysystemd.reader.MatchOperation)
['AND', 'NOR', '__class__', '__doc__', '__members__', '__module__']
file = "cysystemd-1.4.3-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:5c246ecd2a262e18aa49146a52221c44941a87998962348b6446fc908fbd8f7f"
Log
$ uv pip install cysystemd
Resolved 1 package in 1.67s
error: Failed to download distributions
Caused by: Failed to fetch wheel: cysystemd==1.6.0
Caused by: Failed to build: `cysystemd==1.6.0`
Caused by: Build backend failed to build wheel through `build_wheel()` with exit status: 1
--- stdout:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-311
creating build/lib.linux-x86_64-cpython-311/cysystemd
copying cysystemd/__init__.py -> build/lib.linux-x86_64-cpython-311/cysystemd
copying cysystemd/journal.py -> build/lib.linux-x86_64-cpython-311/cysystemd
copying cysystemd/daemon.py -> build/lib.linux-x86_64-cpython-311/cysystemd
copying cysystemd/async_reader.py -> build/lib.linux-x86_64-cpython-311/cysystemd
copying cysystemd/py.typed -> build/lib.linux-x86_64-cpython-311/cysystemd
running build_ext
building 'cysystemd._daemon' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/cysystemd
gcc -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/home/vda/.cache/yay/python311/src=/usr/src/debug/python311 -flto=auto -fno-semantic-interposition -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/home/vda/.cache/yay/python311/src=/usr/src/debug/python311 -flto=auto -fno-semantic-interposition -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/home/vda/.cache/yay/python311/src=/usr/src/debug/python311 -flto=auto -fno-semantic-interposition -fPIC -I/home/vda/.cache/uv/.tmpesd9E5/.venv/include -I/usr/include/python3.11 -c cysystemd/_daemon.c -o build/temp.linux-x86_64-cpython-311/cysystemd/_daemon.o
gcc -shared -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto build/temp.linux-x86_64-cpython-311/cysystemd/_daemon.o -L/usr/lib -lsystemd -o build/lib.linux-x86_64-cpython-311/cysystemd/_daemon.cpython-311-x86_64-linux-gnu.so
building 'cysystemd._journal' extension
gcc -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/home/vda/.cache/yay/python311/src=/usr/src/debug/python311 -flto=auto -fno-semantic-interposition -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/home/vda/.cache/yay/python311/src=/usr/src/debug/python311 -flto=auto -fno-semantic-interposition -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/home/vda/.cache/yay/python311/src=/usr/src/debug/python311 -flto=auto -fno-semantic-interposition -fPIC -I/home/vda/.cache/uv/.tmpesd9E5/.venv/include -I/usr/include/python3.11 -c cysystemd/_journal.c -o build/temp.linux-x86_64-cpython-311/cysystemd/_journal.o -DSYSLOG_NAMES=1
gcc -shared -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto build/temp.linux-x86_64-cpython-311/cysystemd/_journal.o -L/usr/lib -lsystemd -o build/lib.linux-x86_64-cpython-311/cysystemd/_journal.cpython-311-x86_64-linux-gnu.so
building 'cysystemd.reader' extension
gcc -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/home/vda/.cache/yay/python311/src=/usr/src/debug/python311 -flto=auto -fno-semantic-interposition -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/home/vda/.cache/yay/python311/src=/usr/src/debug/python311 -flto=auto -fno-semantic-interposition -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/home/vda/.cache/yay/python311/src=/usr/src/debug/python311 -flto=auto -fno-semantic-interposition -fPIC -I/home/vda/.cache/uv/.tmpesd9E5/.venv/include -I/usr/include/python3.11 -c cysystemd/reader.c -o build/temp.linux-x86_64-cpython-311/cysystemd/reader.o -DSYSLOG_NAMES=1
--- stderr:
/home/vda/.cache/uv/.tmpesd9E5/.venv/lib/python3.11/site-packages/setuptools/_distutils/dist.py:266: UserWarning: Unknown distribution option: 'build_requires'
warnings.warn(msg)
cysystemd/reader.pyx: В функции «__pyx_pf_9cysystemd_6reader_13JournalReader_6open_files»:
cysystemd/reader.pyx:325:94: ошибка: в передаче аргумента 2 «sd_journal_open_files»: несовместимый тип указателя [-Wincompatible-pointer-types]
325 | check_error_code(sd_journal_open_files(&self.context, paths, 0))
| ^
| |
| char **
In file included from cysystemd/reader.c:1230:
/usr/include/systemd/sd-journal.h:90:58: замечание: ожидался тип «const char **», но аргумент имеет тип «char **»
90 | int sd_journal_open_files(sd_journal **ret, const char **paths, int flags);
| ~~~~~~~~~~~~~^~~~~
cysystemd/reader.pyx: В функции «__pyx_pymod_exec_reader»:
cysystemd/reader.pyx:143:3: предупреждение: «SD_JOURNAL_SYSTEM_ONLY» устарело [-Wdeprecated-declarations]
143 | SYSTEM_ONLY = SD_JOURNAL_SYSTEM_ONLY
| ^ ~~~~~~~
/usr/include/systemd/sd-journal.h:76:9: замечание: объявлено здесь
76 | SD_JOURNAL_SYSTEM_ONLY _sd_deprecated_ = SD_JOURNAL_SYSTEM /* old name */
| ^~~~~~~~~~~~~~~~~~~~~~
error: command '/usr/bin/gcc' failed with exit code 1
---
Enviroment
$ systemctl --version
systemd 255 (255.6-1-arch)
+PAM +AUDIT -SELINUX -APPARMOR -IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified
$ yay -Ss systemd-libs
core/systemd-libs 255.6-1 (1.1 MiB 2.7 MiB) (установлено)
systemd client libraries
$ gcc --version
gcc (GCC) 14.1.1 20240507
Python 3.11/3.12
When i'm using the JournaldLogHandler
, i'm getting this warning
cysystemd/journal.py:163: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
if isinstance(args, collections.Mapping):
The set of filter expressions you can build using the Rule class and its & and | operations is a strict subset of what sd_journal_add_{match,disjunction,conjunction}() provide. IMHO it would be better (and also simpler) to just expose those, the way the official SystemD binding does it.
It seems like a file is missing in [email protected]
:
(awslogs-sd) [root@a0d03d]# AWS_DEFAULT_REGION=us-east-1 /opt/awslogs-sd/bin/awslogs-sd /etc/awslogs-sd.conf
Traceback (most recent call last):
File "/opt/awslogs-sd/bin/awslogs-sd", line 7, in <module>
from awslogs_sd.awslogs_sd import main
File "/opt/awslogs-sd/lib64/python3.6/site-packages/awslogs_sd/awslogs_sd.py", line 22, in <module>
from systemd import journal
File "/opt/awslogs-sd/lib64/python3.6/site-packages/systemd/journal.py", line 6, in <module>
from ._journal import syslog_priorities, send
ImportError: cannot import name 'syslog_priorities'
When I look at the contents of that installed module I don't see a _journal.py(x)
file:
(awslogs-sd) [root@a0d03d]# ll /opt/awslogs-sd/lib64/python3.6/site-packages/systemd/
total 1496
-rwxr-xr-x 1 root root 60464 Jun 14 19:27 _daemon.cpython-36m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 2059 Dec 15 2017 daemon.py
-rwxr-xr-x 1 root root 42512 Jun 14 19:27 id128.cpython-36m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 471 Mar 1 2018 __init__.py
-rwxr-xr-x 1 root root 34144 Jun 14 19:27 _journal.cpython-36m-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 4522 Dec 15 2017 journal.py
-rwxr-xr-x 1 root root 52848 Jun 14 19:27 login.cpython-36m-x86_64-linux-gnu.so
drwxr-xr-x 2 root root 96 Jun 14 19:27 __pycache__
-rwxr-xr-x 1 root root 112064 Jun 14 19:27 _reader.cpython-36m-x86_64-linux-gnu.so
-rwxr-xr-x 1 root root 1203496 Jun 14 19:27 reader.cpython-36m-x86_64-linux-gnu.so
drwxr-xr-x 3 root root 91 Jun 14 19:27 test
Am I missing something here?
Thanks for the work on this, it has been super useful!
It seems that the values of .get_realtime_sec()
is getting returned as a float, when it needs to be a double. As a result the .date
value is incorrect as well.
Here is some sample output where I would expect get_realtime_sec()
to return 1599083674.346608
, but instead:
>>> cysystemd.__version__
'1.3.3'
...
>>> journal_entry.get_realtime_usec()
1599083674346608
>>> journal_entry.get_realtime_sec()
1599083648.0
>>> journal_entry.date
datetime.datetime(2020, 9, 2, 21, 54, 8)
I'm not familiar with cython but I'm hoping all that needs to happen is changing the return types for get_realtime_sec()
and get_monotonic_sec()
to double
?
Hi,
I'm not able to install it on Alpine Linux 3.10.
Package elogind-dev
has been installed which contains the systemd/sd-daemon.h
file but then I got this error:
Collecting cysystemd
Using cached https://files.pythonhosted.org/packages/e2/1e/f11e985e99ed3a6ce1804663aac84205c72c287d4070ee55ee02f470da3d/cysystemd-1.1.1.tar.gz
Installing collected packages: cysystemd
Running setup.py install for cysystemd ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ts8gqph3/cysystemd/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ts8gqph3/cysystemd/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-_83mbxq9/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-ts8gqph3/cysystemd/
Complete output (21 lines):
/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'build_requires'
warnings.warn(msg)
Warning: 'keywords' should be a list, got type 'tuple'
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/cysystemd
copying cysystemd/journal.py -> build/lib.linux-x86_64-3.7/cysystemd
copying cysystemd/__init__.py -> build/lib.linux-x86_64-3.7/cysystemd
copying cysystemd/daemon.py -> build/lib.linux-x86_64-3.7/cysystemd
running build_ext
building 'cysystemd._daemon' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/cysystemd
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/python3.7m -c cysystemd/_daemon.c -o build/temp.linux-x86_64-3.7/cysystemd/_daemon.o
gcc -shared -Wl,--as-needed -Wl,--as-needed build/temp.linux-x86_64-3.7/cysystemd/_daemon.o -L/usr/lib -lsystemd -lpython3.7m -o build/lib.linux-x86_64-3.7/cysystemd/_daemon.cpython-37m-x86_64-linux-gnu.so
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lsystemd
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ts8gqph3/cysystemd/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ts8gqph3/cysystemd/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-_83mbxq9/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
Have you been able to make it works with elogind
on Alpine Linux ?
Thanks :)
$ pip3 install systemd
error in systemd setup command: Invalid environment marker: python_version < "3.3"
$ pip3 --version
pip 1.5.6 from /usr/lib/python3/dist-packages (python 3.4)
ERROR: Failed building wheel for systemd
Running setup.py clean for systemd
Failed to build systemd
Installing collected packages: systemd
Running setup.py install for systemd ... error
ERROR: Command errored out with exit status 1:
command: 'd:\cc\pypy\test\scripts\pypy3.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Alex_PC\\AppData\\Local\\Temp\\pip-install-nrdbdggc\\systemd_3a9a9648dd584c87a765e9b827db3048\\setup.py'"'"'; __file__='"'"'C:\\Users\\Alex_PC\\AppData\\Local\\Temp\\pip-install-nrdbdggc\\systemd_3a9a9648dd584c87a765e9b827db3048\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Alex_PC\AppData\Local\Temp\pip-record-35u426md\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\cc\pypy\test\include\site\python3.7\systemd'
cwd: C:\Users\Alex_PC\AppData\Local\Temp\pip-install-nrdbdggc\systemd_3a9a9648dd584c87a765e9b827db3048\
Complete output (29 lines):
[1/3] Cythonizing systemd/_daemon.pyx
d:\cc\pypy\test\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\Alex_PC\AppData\Local\Temp\pip-install-nrdbdggc\systemd_3a9a9648dd584c87a765e9b827db3048\systemd\_daemon.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
[2/3] Cythonizing systemd/_journal.pyx
d:\cc\pypy\test\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\Alex_PC\AppData\Local\Temp\pip-install-nrdbdggc\systemd_3a9a9648dd584c87a765e9b827db3048\systemd\_journal.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
[3/3] Cythonizing systemd/reader.pyx
d:\cc\pypy\test\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\Alex_PC\AppData\Local\Temp\pip-install-nrdbdggc\systemd_3a9a9648dd584c87a765e9b827db3048\systemd\reader.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
D:\cc\pypy\lib-python\3\distutils\dist.py:274: UserWarning: Unknown distribution option: 'build_requires'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\systemd
copying systemd\daemon.py -> build\lib.win-amd64-3.7\systemd
copying systemd\journal.py -> build\lib.win-amd64-3.7\systemd
copying systemd\__init__.py -> build\lib.win-amd64-3.7\systemd
running build_ext
building 'systemd._daemon' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\systemd
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Id:\cc\pypy\test\include -ID:\cc\pypy\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\ATLMFC\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\cppwinrt /Tcsystemd/_daemon.c /Fobuild\temp.win-amd64-3.7\Release\systemd/_daemon.obj
_daemon.c
systemd/_daemon.c(626): fatal error C1083: \u040c\u0490 г¤ \u0490вбп \xaeвЄалвм д \xa9\xab ўЄ\xabоз\u0490\xadЁ\u0490: systemd/sd-daemon.h: No such file or directory,
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'd:\cc\pypy\test\scripts\pypy3.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Alex_PC\\AppData\\Local\\Temp\\pip-install-nrdbdggc\\systemd_3a9a9648dd584c87a765e9b827db3048\\setup.py'"'"'; __file__='"'"'C:\\Users\\Alex_PC\\AppData\\Local\\Temp\\pip-install-nrdbdggc\\systemd_3a9a9648dd584c87a765e9b827db3048\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Alex_PC\AppData\Local\Temp\pip-record-35u426md\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\cc\pypy\test\include\site\python3.7\systemd' Check the logs for full command output.
The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.
This code make this issue :
reader = AsyncJournalReader()
await reader.open(JournalOpenMode.SYSTEM)
await reader.seek_tail()
await reader.add_filter((
Rule("_SYSTEMD_UNIT", "some-service.service")
))
RuntimeWarning: coroutine 'Base._exec' was never awaited
Rule("_SYSTEMD_UNIT", "some-service.service")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Solution:
an await
has to be added to the add_filter
method from AsynJournalReader
class.
from:
async def add_filter(self, rule):
return self._exec(self.__reader.add_filter, rule)
to:
async def add_filter(self, rule):
return await self._exec(self.__reader.add_filter, rule)
Sorry this isn't really an issue but wasn't sure where else to ask... I am wondering if there is a way to send messages to systemd without having them written to syslog as well? I see there is the 'facility' var in the JournaldLogHandler that seems like it would allow me to write to the auth log or something else but I'd prefer not to log to any of them. Is that possible?
Thanks!
Hello,
I'm using version 1.1.1 on Ubuntu 16.04. There is a difference in timestamps when reading via JournalReader
and journalctl
. Some of my log messages contain time info, that is identical with journalctl
timestamps. Timezone difference doesn't matter, please look to seconds.
Thank you!
reader = JournalReader()
reader.open(JournalOpenMode.SYSTEM)
reader.seek_head()
for record in reader:
print(record.date, record.data['MESSAGE'])
results in:
2019-05-21 08:53:20 2019-05-21T11:52:40+03:00
2019-05-21 08:53:20 2019-05-21T11:52:40+03:00
2019-05-21 08:53:20 [system] Successfully activated service 'org.freedesktop.timedate1'
2019-05-21 08:53:20 Started Time & Date Service.
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/state/time 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/settings/time/local 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/settings/servers/sntp 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /time 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /static/http.js 304 NOT MODIFIED
2019-05-21 08:53:20 2019-05-21T11:53:43+03:00
2019-05-21 08:53:20 [system] Activating via systemd: service name='org.freedesktop.timedate1' unit='dbus-org.freedesktop.timedate1.service'
2019-05-21 08:53:20 2019-05-21T11:53:43+03:00
2019-05-21 08:53:20 Starting Time & Date Service...
2019-05-21 08:53:20 2019-05-21T11:53:43+03:00
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/settings/actions/sntp 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/settings/events/schdl 200 OK
2019-05-21 08:53:20 [system] Successfully activated service 'org.freedesktop.timedate1'
2019-05-21 08:53:20 Started Time & Date Service.
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/settings/time/local 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/settings/servers/sntp 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/state/time 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /time 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /static/http.js 304 NOT MODIFIED
2019-05-21 08:53:20 2019-05-21T11:53:53+03:00
2019-05-21 08:53:20 2019-05-21T11:53:53+03:00
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/state/time 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/settings/time/local 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/settings/actions/sntp 200 OK
2019-05-21 08:53:20 2019-05-21T11:53:53+03:00
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/settings/servers/sntp 200 OK
2019-05-21 08:53:20 [email protected] 127.0.0.1 GET /api/v0.10/settings/events/schdl 200 OK
2019-05-21 08:55:28 [email protected] 127.0.0.1 GET /time 200 OK
2019-05-21 08:55:28 [email protected] 127.0.0.1 GET /static/http.js 304 NOT MODIFIED
2019-05-21 08:55:28 2019-05-21T11:55:53+03:00
2019-05-21 08:55:28 [system] Activating via systemd: service name='org.freedesktop.timedate1' unit='dbus-org.freedesktop.timedate1.service'
2019-05-21 08:55:28 2019-05-21T11:55:53+03:00
2019-05-21 08:55:28 Starting Time & Date Service...
2019-05-21 08:55:28 2019-05-21T11:55:53+03:00
2019-05-21 08:55:28 [email protected] 127.0.0.1 GET /api/v0.10/settings/actions/sntp 200 OK
2019-05-21 08:55:28 [email protected] 127.0.0.1 GET /api/v0.10/settings/events/schdl 200 OK
2019-05-21 08:55:28 [system] Successfully activated service 'org.freedesktop.timedate1'
2019-05-21 08:55:28 Started Time & Date Service.
2019-05-21 08:55:28 [email protected] 127.0.0.1 GET /api/v0.10/settings/time/local 200 OK
2019-05-21 08:55:28 [email protected] 127.0.0.1 GET /api/v0.10/settings/servers/sntp 200 OK
2019-05-21 08:55:28 [email protected] 127.0.0.1 GET /api/v0.10/state/time 200 OK
2019-05-21 08:57:36 [email protected] 127.0.0.1 GET /time 200 OK
2019-05-21 08:57:36 [email protected] 127.0.0.1 GET /static/http.js 304 NOT MODIFIED
2019-05-21 08:57:36 2019-05-21T11:58:27+03:00
2019-05-21 08:57:36 [system] Activating via systemd: service name='org.freedesktop.timedate1' unit='dbus-org.freedesktop.timedate1.service'
2019-05-21 08:57:36 Starting Time & Date Service...
2019-05-21 08:57:36 2019-05-21T11:58:27+03:00
2019-05-21 08:57:36 [email protected] 127.0.0.1 GET /api/v0.10/settings/actions/sntp 200 OK
2019-05-21 08:57:36 2019-05-21T11:58:27+03:00
2019-05-21 08:57:36 [email protected] 127.0.0.1 GET /api/v0.10/settings/events/schdl 200 OK
2019-05-21 08:57:36 [system] Successfully activated service 'org.freedesktop.timedate1'
2019-05-21 08:57:36 Started Time & Date Service.
2019-05-21 08:57:36 [email protected] 127.0.0.1 GET /api/v0.10/settings/servers/sntp 200 OK
2019-05-21 08:57:36 [email protected] 127.0.0.1 GET /api/v0.10/state/time 200 OK
2019-05-21 08:57:36 [email protected] 127.0.0.1 GET /api/v0.10/settings/time/local 200 OK
journalctl
output:
май 21 11:52:40 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:52:40+03:00
май 21 11:52:40 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:52:40+03:00
май 21 11:52:40 mitya-VirtualBox dbus[620]: [system] Successfully activated service 'org.freedesktop.timedate1'
май 21 11:52:40 mitya-VirtualBox systemd[1]: Started Time & Date Service.
май 21 11:52:40 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/state/time 200 OK
май 21 11:52:40 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/time/local 200 OK
май 21 11:52:40 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/servers/sntp 200 OK
май 21 11:53:43 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /time 200 OK
май 21 11:53:43 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /static/http.js 304 NOT MODIFIED
май 21 11:53:43 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:53:43+03:00
май 21 11:53:43 mitya-VirtualBox dbus[620]: [system] Activating via systemd: service name='org.freedesktop.timedate1' unit='dbus-org.freedesktop.timedate1.service'
май 21 11:53:43 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:53:43+03:00
май 21 11:53:43 mitya-VirtualBox systemd[1]: Starting Time & Date Service...
май 21 11:53:43 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:53:43+03:00
май 21 11:53:43 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/actions/sntp 200 OK
май 21 11:53:43 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/events/schdl 200 OK
май 21 11:53:43 mitya-VirtualBox dbus[620]: [system] Successfully activated service 'org.freedesktop.timedate1'
май 21 11:53:43 mitya-VirtualBox systemd[1]: Started Time & Date Service.
май 21 11:53:43 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/time/local 200 OK
май 21 11:53:43 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/servers/sntp 200 OK
май 21 11:53:43 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/state/time 200 OK
май 21 11:53:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /time 200 OK
май 21 11:53:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /static/http.js 304 NOT MODIFIED
май 21 11:53:53 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:53:53+03:00
май 21 11:53:53 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:53:53+03:00
май 21 11:53:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/state/time 200 OK
май 21 11:53:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/time/local 200 OK
май 21 11:53:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/actions/sntp 200 OK
май 21 11:53:53 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:53:53+03:00
май 21 11:53:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/servers/sntp 200 OK
май 21 11:53:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/events/schdl 200 OK
май 21 11:55:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /time 200 OK
май 21 11:55:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /static/http.js 304 NOT MODIFIED
май 21 11:55:53 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:55:53+03:00
май 21 11:55:53 mitya-VirtualBox dbus[620]: [system] Activating via systemd: service name='org.freedesktop.timedate1' unit='dbus-org.freedesktop.timedate1.service'
май 21 11:55:53 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:55:53+03:00
май 21 11:55:53 mitya-VirtualBox systemd[1]: Starting Time & Date Service...
май 21 11:55:53 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:55:53+03:00
май 21 11:55:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/actions/sntp 200 OK
май 21 11:55:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/events/schdl 200 OK
май 21 11:55:53 mitya-VirtualBox dbus[620]: [system] Successfully activated service 'org.freedesktop.timedate1'
май 21 11:55:53 mitya-VirtualBox systemd[1]: Started Time & Date Service.
май 21 11:55:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/time/local 200 OK
май 21 11:55:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/servers/sntp 200 OK
май 21 11:55:53 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/state/time 200 OK
май 21 11:58:27 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /time 200 OK
май 21 11:58:27 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /static/http.js 304 NOT MODIFIED
май 21 11:58:27 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:58:27+03:00
май 21 11:58:27 mitya-VirtualBox dbus[620]: [system] Activating via systemd: service name='org.freedesktop.timedate1' unit='dbus-org.freedesktop.timedate1.service'
май 21 11:58:27 mitya-VirtualBox systemd[1]: Starting Time & Date Service...
май 21 11:58:27 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:58:27+03:00
май 21 11:58:27 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/actions/sntp 200 OK
май 21 11:58:27 mitya-VirtualBox uspd.cfg_datetime[32024]: 2019-05-21T11:58:27+03:00
май 21 11:58:27 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/events/schdl 200 OK
май 21 11:58:27 mitya-VirtualBox dbus[620]: [system] Successfully activated service 'org.freedesktop.timedate1'
май 21 11:58:27 mitya-VirtualBox systemd[1]: Started Time & Date Service.
май 21 11:58:27 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/servers/sntp 200 OK
май 21 11:58:27 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/state/time 200 OK
май 21 11:58:27 mitya-VirtualBox uspd.debug[32024]: [email protected] 127.0.0.1 GET /api/v0.10/settings/time/local 200 OK
OS : Centos7
Py : 3.6.5
pip : 18.0
yum install gcc systemd-devel : Done
pip install systemd
Collecting systemd
Using cached https://files.pythonhosted.org/packages/d4/c2/2195b049effd866b5d26926e672be83fc6f3263aa71ea0639e8eab44851e/systemd-0.16.1.tar.gz
Installing collected packages: systemd
Running setup.py install for systemd ... error
Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-xdzfevai/systemd/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-uelffbjb/install-record.txt --single-version-externally-managed --compile:
/usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'build_requires'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/systemd
copying systemd/daemon.py -> build/lib.linux-x86_64-3.6/systemd
copying systemd/__init__.py -> build/lib.linux-x86_64-3.6/systemd
copying systemd/journal.py -> build/lib.linux-x86_64-3.6/systemd
running build_ext
building 'systemd._daemon' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/systemd
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.6m -c systemd/_daemon.c -o build/temp.linux-x86_64-3.6/systemd/_daemon.o
systemd/_daemon.c:20:20: schwerwiegender Fehler: Python.h: Datei oder Verzeichnis nicht gefunden
#include "Python.h"
^
Kompilierung beendet.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-xdzfevai/systemd/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-uelffbjb/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-xdzfevai/systemd/
sorry for german traceback
Working on https://github.com/AstraLuma/mycelium/tree/eb820fa910cd5cc995a12ca5e53040b5a19219c1 and I get this back trace:
Dec 22 04:16:42 plants daemon.py[8163]: Traceback (most recent call last):
Dec 22 04:16:42 plants daemon.py[8163]: File "/home/pi/mycelium/daemon.py", line 53, in <module>
Dec 22 04:16:42 plants daemon.py[8163]: LOG.debug("config: %r", config)
Dec 22 04:16:42 plants daemon.py[8163]: File "/usr/lib/python3.7/logging/__init__.py", line 1371, in debug
Dec 22 04:16:42 plants daemon.py[8163]: self._log(DEBUG, msg, args, **kwargs)
Dec 22 04:16:42 plants daemon.py[8163]: File "/usr/lib/python3.7/logging/__init__.py", line 1519, in _log
Dec 22 04:16:42 plants daemon.py[8163]: self.handle(record)
Dec 22 04:16:42 plants daemon.py[8163]: File "/usr/lib/python3.7/logging/__init__.py", line 1529, in handle
Dec 22 04:16:42 plants daemon.py[8163]: self.callHandlers(record)
Dec 22 04:16:42 plants daemon.py[8163]: File "/usr/lib/python3.7/logging/__init__.py", line 1591, in callHandlers
Dec 22 04:16:42 plants daemon.py[8163]: hdlr.handle(record)
Dec 22 04:16:42 plants daemon.py[8163]: File "/usr/lib/python3.7/logging/__init__.py", line 905, in handle
Dec 22 04:16:42 plants daemon.py[8163]: self.emit(record)
Dec 22 04:16:42 plants daemon.py[8163]: File "/usr/local/lib/python3.7/dist-packages/cysystemd/journal.py", line 178, in emit
Dec 22 04:16:42 plants daemon.py[8163]: send(**data)
Dec 22 04:16:42 plants daemon.py[8163]: File "cysystemd/_journal.pyx", line 73, in cysystemd._journal.send
Dec 22 04:16:42 plants daemon.py[8163]: File "cysystemd/_journal.pyx", line 36, in cysystemd._journal._send
Dec 22 04:16:42 plants daemon.py[8163]: ValueError: Key name must be consist only of characters, numbers and underscores
cysystemd 1.4.5
When used cysystemd.reader.JournalReader
a problem occurs.
get_monotonic_sec()
works correctly and time updated at every line.
But get_realtime_sec()
freeze for 128 seconds.
Test script:
#!/usr/bin/env python3
from cysystemd.reader import JournalOpenMode, JournalReader, Rule
import time
if __name__ == '__main__':
j = JournalReader()
j.open(JournalOpenMode.SYSTEM)
j.seek_realtime_usec(time.time() * 1000000)
while True:
j.wait(1)
for entry in j:
print("date = {}, monotonic = {}, realtime = {}".format(
entry.date, entry.get_monotonic_sec(), entry.get_realtime_sec()
))
and output:
date = 2019-02-22 05:26:24, monotonic = 1909098.0, realtime = 1550813184.0. Diff = 1548904086.0
date = 2019-02-22 05:26:24, monotonic = 1909099.0, realtime = 1550813184.0. Diff = 1548904085.0
date = 2019-02-22 05:26:24, monotonic = 1909099.0, realtime = 1550813184.0. Diff = 1548904085.0
date = 2019-02-22 05:26:24, monotonic = 1909099.0, realtime = 1550813184.0. Diff = 1548904085.0
date = 2019-02-22 05:26:24, monotonic = 1909099.0, realtime = 1550813184.0. Diff = 1548904085.0
date = 2019-02-22 05:26:24, monotonic = 1909102.0, realtime = 1550813184.0. Diff = 1548904082.0
date = 2019-02-22 05:26:24, monotonic = 1909103.0, realtime = 1550813184.0. Diff = 1548904081.0
date = 2019-02-22 05:26:24, monotonic = 1909104.0, realtime = 1550813184.0. Diff = 1548904080.0
date = 2019-02-22 05:26:24, monotonic = 1909104.0, realtime = 1550813184.0. Diff = 1548904080.0
date = 2019-02-22 05:26:24, monotonic = 1909105.0, realtime = 1550813184.0. Diff = 1548904079.0
date = 2019-02-22 05:28:32, monotonic = 1909106.0, realtime = 1550813312.0. Diff = 1548904206.0
date = 2019-02-22 05:28:32, monotonic = 1909107.0, realtime = 1550813312.0. Diff = 1548904205.0
date = 2019-02-22 05:28:32, monotonic = 1909107.0, realtime = 1550813312.0. Diff = 1548904205.0
date = 2019-02-22 05:28:32, monotonic = 1909107.0, realtime = 1550813312.0. Diff = 1548904205.0
date = 2019-02-22 05:28:32, monotonic = 1909108.0, realtime = 1550813312.0. Diff = 1548904204.0
I tested this script with Debian 9 (Python 3.5) and Ubuntu 18.04 (Python 3.6)
i am running raspbian buster on a raspberry pi 3 model b+
i have python 2.7.16 as well as python 3.7.3 installed side by side
i also have pip and pip3
pip3 installs the package just fine, but pip fails every time
i'm not sure if this is an issue of my environment, or if it's an issue with the package.
anyway, any help would be greatly appreciated.
$ pip install systemd
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting systemd
Using cached https://files.pythonhosted.org/packages/d4/c2/2195b049effd866b5d26926e672be83fc6f3263aa71ea0639e8eab44851e/systemd-0.16.1.tar.gz
Requirement already satisfied: enum34 in /usr/lib/python2.7/dist-packages (from systemd) (1.1.6)
Requirement already satisfied: dictproxyhack in ./.local/lib/python2.7/site-packages (from systemd) (1.1)
Building wheels for collected packages: systemd
Running setup.py bdist_wheel for systemd ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-D8R1oV/systemd/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-_yx6ne --python-tag cp27:
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'build_requires'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/systemd
copying systemd/__init__.py -> build/lib.linux-armv7l-2.7/systemd
copying systemd/daemon.py -> build/lib.linux-armv7l-2.7/systemd
copying systemd/journal.py -> build/lib.linux-armv7l-2.7/systemd
running build_ext
building 'systemd._daemon' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/systemd
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-9NJ3qw/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c systemd/_daemon.c -o build/temp.linux-armv7l-2.7/systemd/_daemon.o
systemd/_daemon.c:539:10: fatal error: systemd/sd-daemon.h: No such file or directory
#include <systemd/sd-daemon.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for systemd
Running setup.py clean for systemd
Failed to build systemd
Installing collected packages: systemd
Running setup.py install for systemd ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-D8R1oV/systemd/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-CCRKkP/install-record.txt --single-version-externally-managed --compile --user --prefix=:
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'build_requires'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/systemd
copying systemd/__init__.py -> build/lib.linux-armv7l-2.7/systemd
copying systemd/daemon.py -> build/lib.linux-armv7l-2.7/systemd
copying systemd/journal.py -> build/lib.linux-armv7l-2.7/systemd
running build_ext
building 'systemd._daemon' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/systemd
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-9NJ3qw/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c systemd/_daemon.c -o build/temp.linux-armv7l-2.7/systemd/_daemon.o
systemd/_daemon.c:539:10: fatal error: systemd/sd-daemon.h: No such file or directory
#include <systemd/sd-daemon.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-D8R1oV/systemd/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-CCRKkP/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-D8R1oV/systemd/
the a gcc command exits with error code 1 while trying to install with python3.9 and gcc10. the error log is attached
Thanks for these excellent bindings; they are certainly much more pythonic than the ones that systemd ships.
I'm trying to package this library as I have my own software depending on it. This is quite hard, because at least in debian, import systemd
is already taken by the official bindings.
In general, the naming conventions have become a bit unfortunate:
place | official systemd | mosquito |
---|---|---|
github | python-systemd |
python-systemd |
pypi | systemd-python |
systemd |
debian | python{,3}-systemd |
? |
import statement |
import systemd |
import systemd |
What's your preferred way of handling this? A possible suggestion would be to rename to pysystemd
, but I'm just thinking out loud here.
It would be highly appreciable if you name few advantages over followed competitors https://github.com/systemd/python-systemd, https://github.com/facebookincubator/pystemd or add it to the readme file as a motivation section.
I'm considering a lib to deal with collecting the journald logs and your code and doc look more comprehensive than others.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.