I'm trying to fix this issue:
Код: Выделить всё
crawl_oled.service - test OLED SSD1306 Loaded: loaded (/lib/systemd/system/crawl_oled.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2024-03-06 08:30:14 EST; 2min 33s ago Process: 200235 ExecStartPre=/bin/sleep 30 (code=exited, status=0/SUCCESS) Process: 200600 ExecStart=/usr/bin/python3 /home/pi/luma-env/luma.examples/examples/OLED_INFO.py (code=exited, status=1/FAILURE) Main PID: 200600 (code=exited, status=1/FAILURE) CPU: 609ms Mar 06 08:30:14 raspberrypi python3[200600]: Traceback (most recent call last): Mar 06 08:30:14 raspberrypi python3[200600]: File "/home/pi/luma-env/luma.examples/examples/OLED_INFO.py", line 299, in Mar 06 08:30:14 raspberrypi python3[200600]: run_ext() Mar 06 08:30:14 raspberrypi python3[200600]: File "/home/pi/luma-env/luma.examples/examples/OLED_INFO.py", line 59, in run_ext Mar 06 08:30:14 raspberrypi python3[200600]: random_py = random.choice(Local_List) Mar 06 08:30:14 raspberrypi python3[200600]: File "/usr/lib/python3.9/random.py", line 347, in choice Mar 06 08:30:14 raspberrypi python3[200600]: return seq[self._randbelow(len(seq))] Mar 06 08:30:14 raspberrypi python3[200600]: IndexError: list index out of range Mar 06 08:30:14 raspberrypi systemd[1]: crawl_oled.service: Main process exited, code=exited, status=1/FAILURE` Mar 06 08:30:14 raspberrypi systemd[1]: crawl_oled.service: Failed with result 'exit-code'.
Код: Выделить всё
pi@raspberrypi:~ $ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
Код: Выделить всё
random
Here's the part from the script that is failing
Код: Выделить всё
def run_ext(): i = 0 while True: try: # Command to run "OTHER".py ####random_file=random.choice(os.listdir()) Local_List = [each for i, each in enumerate(os.listdir(current_working_directory)) if each.endswith('1.py')] random_py = random.choice(Local_List) random_py = current_working_directory + '/' + str(random_py) print(random_py) sp.run(random_py, timeout=10) except sp.TimeoutExpired: break
Код: Выделить всё
random_py = random.choice(Local_List[i])
Код: Выделить всё
crawl_oled.service - test OLED SSD1306 Loaded: loaded (/lib/systemd/system/crawl_oled.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2024-03-06 08:52:57 EST; 2s ago Process: 216809 ExecStartPre=/bin/sleep 30 (code=exited, status=0/SUCCESS) Process: 217172 ExecStart=/usr/bin/python3 /home/pi/luma-env/luma.examples/examples/OLED_INFO.py (code=exited, status=1/FAILURE) Main PID: 217172 (code=exited, status=1/FAILURE) CPU: 545ms Mar 06 08:52:56 raspberrypi systemd[1]: Started test OLED SSD1306. Mar 06 08:52:57 raspberrypi python3[217172]: / Mar 06 08:52:57 raspberrypi python3[217172]: Traceback (most recent call last): Mar 06 08:52:57 raspberrypi python3[217172]: File "/home/pi/luma-env/luma.examples/examples/OLED_INFO.py", line 299, in Mar 06 08:52:57 raspberrypi python3[217172]: run_ext() Mar 06 08:52:57 raspberrypi python3[217172]: File "/home/pi/luma-env/luma.examples/examples/OLED_INFO.py", line 59, in run_ext Mar 06 08:52:57 raspberrypi python3[217172]: random_py = random.choice(Local_List[i]) Mar 06 08:52:57 raspberrypi python3[217172]: IndexError: list index out of range Mar 06 08:52:57 raspberrypi systemd[1]: crawl_oled.service: Main process exited, code=exited, status=1/FAILURE Mar 06 08:52:57 raspberrypi systemd[1]: crawl_oled.service: Failed with result 'exit-code'.
Источник: https://stackoverflow.com/questions/781 ... by-systemd