2019-12-14 18:16:31 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import runpy
|
|
|
|
from os import scandir
|
2021-02-08 11:59:33 +01:00
|
|
|
from os.path import abspath, dirname
|
2019-12-14 18:16:31 +01:00
|
|
|
|
|
|
|
this_dir = dirname(abspath(__file__))
|
|
|
|
|
2021-02-08 11:59:33 +01:00
|
|
|
|
2019-12-14 18:16:31 +01:00
|
|
|
def filename(f):
|
2021-02-08 11:59:33 +01:00
|
|
|
return f.name
|
|
|
|
|
2019-12-14 18:16:31 +01:00
|
|
|
|
2020-10-17 23:09:26 +02:00
|
|
|
with scandir(this_dir) as it:
|
2021-02-08 11:59:33 +01:00
|
|
|
for f in sorted(it, key=filename):
|
|
|
|
if not f.is_file():
|
|
|
|
continue
|
|
|
|
|
|
|
|
if f.name.startswith("__"):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if not f.name.endswith(".py"):
|
|
|
|
continue
|
|
|
|
|
|
|
|
print(f"▶️ Running the startup script {f.path}")
|
|
|
|
try:
|
|
|
|
runpy.run_path(f.path)
|
|
|
|
except SystemExit as e:
|
|
|
|
if e.code is not None and e.code != 0:
|
|
|
|
print(f"‼️ The startup script {f.path} returned with code {e.code}, exiting.")
|
|
|
|
raise
|