Open bng919 opened 1 year ago
Subprocess run() excpetions are CalledProcessError. https://docs.python.org/3/library/subprocess.html
From this stackoverflow post https://stackoverflow.com/questions/70509342/how-to-handle-subprocess-run-error-exception "If you do supply check=True, the exception you need to trap is CalledProcessError:"
try:
# pointless code as such; see explanation above
subprocess.run(['cd', UserInput], check=True)
except subprocess.CalledProcessError:
print('Directory name %s misspelled, or you lack the permissions' % UserInput)
Changes included in this commit: https://github.com/NathanIngram2/SolarViewer/commit/ce07d536afb55a2d2c204a556e8cf27b9eb99a4f Left the TODO in there in case there is more error checking to do
Thanks Jess. I think we should also manually check the output from rtl_power (rst, the return from sp.run). For example, if the SDR is disconnected, the rst string will contain something indicating SDR connection could not be established (I am not sure exactly what the output will look like, we can check in the lab tomorrow). If we don't check this the csv will be empty, which will cause an error later, but will be more ambiguous to the user what the actual problem is.
Nice spelling @bng919
check=True
in sp.run call caused issues in testing. rtl_power does not return a successful exit code even if it runs successfully. Temporarily removed: https://github.com/NathanIngram2/SolarViewer/blob/8d0370fd5379018bea56a3e6bb7cc0dca9d27dcf/Python/dataCollection.py#L34-L35
Will investigate further in next lab session.
Parse result from rtl_power for error message or nan and handel.
Requires access to pi to check format of error message from rtl_power