My Python application uses os. system(‘reboot’).
I connected the shutdown and power-control plugs.
I received [Python Controller ERROR]: sh: 1: reboot: Permission denied.
Time: May 10 08:10:30
Log: apparmor="DENIED" operation="exec" profile="snap.aps.daemon" name="/usr/bin/systemctl" pid=5442 comm="sh" requested_mask="x" denied_mask="x" fsuid=0 ouid=0
File: /usr/bin/systemctl (exec)
Suggestions:
* adjust snap to ship 'systemctl'
* adjust program to use relative paths if the snap already ships 'systemctl'
The shutdown interface gives you access to dbus to issue a shutdown or reboot command through a dbus call… there are plenty of posts here in the forum with example commands…
[32/32] Linking target test/test-import-repeatedly
FAILED: test/test-import-repeatedly
cc -o test/test-import-repeatedly test/test-import-repeatedly.p/import-repeatedly.c.o -L/root/parts/python/install/lib -L/root/parts/python/install/usr/lib -L/root/parts/python/install/lib/aarch64-linux-gnu -L/root/parts/python/install/usr/lib/aarch64-linux-gnu -L/root/stage/usr/lib -L/root/stage/usr/lib/aarch64-linux-gnu -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -isystem/root/parts/python/install/usr/include -isystem/root/parts/python/install/usr/include/aarch64-linux-gnu -Wl,--start-group -lpython3.11 -Wl,--end-group
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `init_condattr':
/root/parts/python/build/Python/thread_pthread.h:147: undefined reference to `pthread_condattr_setclock'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_tss_create':
/root/parts/python/build/Python/thread_pthread.h:893: undefined reference to `pthread_key_create'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_start_new_thread':
/root/parts/python/build/Python/thread_pthread.h:289: undefined reference to `pthread_create'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:306: undefined reference to `pthread_detach'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:270: undefined reference to `pthread_attr_setstacksize'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_tss_delete':
/root/parts/python/build/Python/thread_pthread.h:910: undefined reference to `pthread_key_delete'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_allocate_lock':
/root/parts/python/build/Python/thread_pthread.h:388: undefined reference to `sem_init'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:388: undefined reference to `sem_init'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_acquire_lock_timed':
/root/parts/python/build/Python/thread_pthread.h:497: undefined reference to `sem_wait'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:497: undefined reference to `sem_wait'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:494: undefined reference to `sem_trywait'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:483: undefined reference to `sem_clockwait'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:497: undefined reference to `sem_wait'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:483: undefined reference to `sem_clockwait'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:494: undefined reference to `sem_trywait'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:497: undefined reference to `sem_wait'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:494: undefined reference to `sem_trywait'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:483: undefined reference to `sem_clockwait'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_release_lock':
/root/parts/python/build/Python/thread_pthread.h:563: undefined reference to `sem_post'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_tss_get':
/root/parts/python/build/Python/thread_pthread.h:927: undefined reference to `pthread_getspecific'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_tss_set':
/root/parts/python/build/Python/thread_pthread.h:919: undefined reference to `pthread_setspecific'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_free_lock':
/root/parts/python/build/Python/thread_pthread.h:413: undefined reference to `sem_destroy'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_create_key':
/root/parts/python/build/Python/thread_pthread.h:820: undefined reference to `pthread_key_create'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Python/thread_pthread.h:825: undefined reference to `pthread_key_delete'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_delete_key':
/root/parts/python/build/Python/thread_pthread.h:839: undefined reference to `pthread_key_delete'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_delete_key_value':
/root/parts/python/build/Python/thread_pthread.h:847: undefined reference to `pthread_setspecific'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_set_key_value':
/root/parts/python/build/Python/thread_pthread.h:855: undefined reference to `pthread_setspecific'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_get_key_value':
/root/parts/python/build/Python/thread_pthread.h:866: undefined reference to `pthread_getspecific'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `_pythread_pthread_set_stacksize':
/root/parts/python/build/Python/thread_pthread.h:783: undefined reference to `pthread_attr_setstacksize'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(thread.o): in function `PyThread_tss_delete':
/root/parts/python/build/Python/thread_pthread.h:910: undefined reference to `pthread_key_delete'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(faulthandler.o): in function `faulthandler_thread':
/root/parts/python/build/./Modules/faulthandler.c:609: undefined reference to `pthread_sigmask'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(signalmodule.o): in function `signal_pthread_kill_impl':
/root/parts/python/build/./Modules/signalmodule.c:1326: undefined reference to `pthread_kill'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(signalmodule.o): in function `signal_pthread_sigmask_impl':
/root/parts/python/build/./Modules/signalmodule.c:1014: undefined reference to `pthread_sigmask'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(complexobject.o): in function `_Py_c_abs':
/root/parts/python/build/Objects/complexobject.c:208: undefined reference to `hypot'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(complexobject.o): in function `_Py_c_pow':
/root/parts/python/build/Objects/complexobject.c:144: undefined reference to `hypot'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Objects/complexobject.c:145: undefined reference to `pow'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Objects/complexobject.c:146: undefined reference to `atan2'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Objects/complexobject.c:149: undefined reference to `exp'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Objects/complexobject.c:150: undefined reference to `log'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Objects/complexobject.c:150: undefined reference to `sincos'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(floatobject.o): in function `float_rem':
/root/parts/python/build/Objects/floatobject.c:655: undefined reference to `fmod'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(floatobject.o): in function `_float_div_mod':
/root/parts/python/build/Objects/floatobject.c:675: undefined reference to `fmod'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(floatobject.o): in function `float_pow':
/root/parts/python/build/Objects/floatobject.c:847: undefined reference to `pow'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Objects/floatobject.c:824: undefined reference to `fmod'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Objects/floatobject.c:847: undefined reference to `pow'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Objects/floatobject.c:788: undefined reference to `fmod'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Objects/floatobject.c:798: undefined reference to `fmod'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(longobject.o): in function `PyLong_FromString':
/root/parts/python/build/Objects/longobject.c:2441: undefined reference to `log'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/Objects/longobject.c:2441: undefined reference to `log'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(posixmodule.o): in function `os_login_tty_impl':
/root/parts/python/build/./Modules/posixmodule.c:7425: undefined reference to `login_tty'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(posixmodule.o): in function `os_openpty_impl':
/root/parts/python/build/./Modules/posixmodule.c:7328: undefined reference to `openpty'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(posixmodule.o): in function `os_forkpty_impl':
/root/parts/python/build/./Modules/posixmodule.c:7479: undefined reference to `forkpty'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(timemodule.o): in function `time_pthread_getcpuclockid':
/root/parts/python/build/./Modules/timemodule.c:354: undefined reference to `pthread_getcpuclockid'
/root/parts/python/install/usr/bin/ld: /root/parts/python/install/usr/lib/libpython3.11.a(dynload_shlib.o): in function `_PyImport_FindSharedFuncptr':
/root/parts/python/build/./Python/dynload_shlib.c:80: undefined reference to `dlopen'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/./Python/dynload_shlib.c:109: undefined reference to `dlsym'
/root/parts/python/install/usr/bin/ld: /root/parts/python/build/./Python/dynload_shlib.c:86: undefined reference to `dlerror'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
I stopped receiving ModuleNotFoundError: No module named ‘dbus’ but now on import dbus I received
import dbus
File "/snap/aps/x1/usr/lib/python3/dist-packages/dbus/__init__.py", line 73, in <module>
import dbus.types as types
File "/snap/aps/x1/usr/lib/python3/dist-packages/dbus/types.py", line 8, in <module>
from _dbus_bindings import (
ModuleNotFoundError: No module named '_dbus_bindings'
well, you are mixing different python versions, that won’t work i guess … what is the reason to use 3.11 instead of the available 3.8 ? from an application POV it should not make much of a difference …
I resolved my issue with os.system('dbus-send --system --print-reply "--dest=org.freedesktop.login1" /org/freedesktop/login1 org.freedesktop.login1.Manager.Reboot boolean:true').
I found out that there is a problem with the dbus-python 1.3.2 library build on python 3.11.
This might be a solution but I haven’t tried it https://pypi.org/project/zymod/