Это сценарий до момента, когда он дает сбой. Мне это кажется простым, но я не понимаю, почему это не работает. Это распаковано из файла .deb.
rtc.py:
Код: Выделить всё
#!/usr/bin/python
import os;
def runCommand(command):
print (command);
r = os.popen(command);
info = r.readlines();
for line in info:
print (line);
def updateConfig():
filename = '/boot/config.txt';
key = 'dtoverlay';
value = 'i2c-rtc,pcf8563'
fr = open(filename,'rb');
try:
lines = fr.readlines();
update = 0;
newValue = '';
for line in lines :
if line and line.count(key) > 0:
Код: Выделить всё
Failed to enable unit: Unit file embest-shutdown.service does not exist.
Failed to enable unit: Unit file embest.service does not exist.
Traceback (most recent call last):
File "/usr/share/PiDesktop/python/rtc.py", line 81, in
updateConfig();
^^^^^^^^^^^^^^
File "/usr/share/PiDesktop/python/rtc.py", line 21, in updateConfig
if line and line.count(key) > 0:
^^^^^^^^^^^^^^^
TypeError: argument should be integer or bytes-like object, not 'str'
dpkg: error processing package pidesktop-base (--install):
installed pidesktop-base package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
pidesktop-base
Обратите внимание: я пытался установить утилиту 2to3, но pip жалуется, что это среда, управляемая извне
Это работает на Raspberry Pi под управлением ОС Raspberry Pi Bookworm.
Подробнее здесь: https://stackoverflow.com/questions/792 ... r-python-3
Мобильная версия