Skip to content

Commit

Permalink
mapd: better exceptions handling when loading dependencies (commaai#150)
Browse files Browse the repository at this point in the history
* mapd: better exceptions handling for loading dependencies

* handle the last

* clean them up
  • Loading branch information
sunnyhaibin authored Jun 13, 2023
1 parent c9e7ca0 commit 1647175
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions selfdrive/manager/custom_dep.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,35 @@ def install_dep(spinner):
print(f"SP_LOG: Preloaded dependencies extracted to {THIRD_PARTY_DIR}")
except Exception as e:
preload_fault = True
command = f'rm -rf {THIRD_PARTY_DIR}'
process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
print(f"SP_LOG: An error occurred while extracting preloaded dependencies: {e}")
print(f"SP_LOG: Cleanup directory {e}")
if not os.path.exists(PRELOADED_DEP_FILE) or preload_fault:
if os.path.exists(THIRD_PARTY_DIR_SP):
spinner.update("Loading dependencies")
command = f'rm -rf {THIRD_PARTY_DIR}; cp -rf {THIRD_PARTY_DIR_SP} {THIRD_PARTY_DIR}'
process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
print(f"SP_LOG: Removed directory {THIRD_PARTY_DIR}")
print(f"SP_LOG: Copied {THIRD_PARTY_DIR_SP} to {THIRD_PARTY_DIR}")
try:
spinner.update("Loading cached dependencies")
command = f'rm -rf {THIRD_PARTY_DIR}; cp -rf {THIRD_PARTY_DIR_SP} {THIRD_PARTY_DIR}'
process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
print(f"SP_LOG: Removed directory {THIRD_PARTY_DIR}")
print(f"SP_LOG: Copied {THIRD_PARTY_DIR_SP} to {THIRD_PARTY_DIR}")
except Exception as e:
command = f'rm -rf {THIRD_PARTY_DIR}'
process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
print(f"SP_LOG: An error occurred while loading cached dependencies: {e}")
print(f"SP_LOG: Cleanup directory {e}")
else:
spinner.update("Waiting for internet")
install_dep(spinner)
try:
install_dep(spinner)
except Exception as e:
command = f'rm -rf {THIRD_PARTY_DIR}'
process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
print(f"SP_LOG: An error occurred while downloading dependencies: {e}")
print(f"SP_LOG: Cleanup directory {e}")
except Exception:
command = f'rm -rf {THIRD_PARTY_DIR}'
process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
import selfdrive.sentry as sentry
sentry.init(sentry.SentryProject.SELFDRIVE)
traceback.print_exc()
Expand Down

0 comments on commit 1647175

Please sign in to comment.