NathanIngram2 / SolarViewer

Central repo to hold the solar imaging related code
GNU General Public License v3.0
1 stars 1 forks source link

Improve measPower() error handeling #10

Open bng919 opened 1 year ago

bng919 commented 1 year ago

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

jessica-guetre commented 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

bng919 commented 1 year ago

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.

NathanIngram2 commented 1 year ago

Nice spelling @bng919

bng919 commented 1 year ago

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.