openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
978 B

#!/usr/bin/env python
import os
import shutil
import threading
from selfdrive.swaglog import cloudlog
from selfdrive.loggerd.config import ROOT, get_available_percent
from selfdrive.loggerd.uploader import listdir_by_creation_date
def deleter_thread(exit_event):
while not exit_event.is_set():
available_percent = get_available_percent()
if available_percent < 10.0:
# remove the earliest directory we can
dirs = listdir_by_creation_date(ROOT)
for delete_dir in dirs:
delete_path = os.path.join(ROOT, delete_dir)
if any(name.endswith(".lock") for name in os.listdir(delete_path)):
continue
try:
cloudlog.info("deleting %s" % delete_path)
shutil.rmtree(delete_path)
break
except OSError:
cloudlog.exception("issue deleting %s" % delete_path)
exit_event.wait(30)
def main(gctx=None):
deleter_thread(threading.Event())
if __name__ == "__main__":
main()