Skip to content

Commit

Permalink
added some exceptions to help users deal with failed magnetocosmics r…
Browse files Browse the repository at this point in the history
…unning
  • Loading branch information
ChrisSWDavis committed Nov 15, 2023
1 parent 5fb2e96 commit d94fe40
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions AsympDirsCalculator/AsympDirsTools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import numpy as np
import pandas as pd
import datetime as dt
import shutil

try:
assert not (shutil.which("magnetocosmics") is None)
except AssertionError:
raise Exception("ERROR: AsympDirsCalculator currently requires magnetocosmics to be installed, such that the command 'magnetocosmics' can be run in terminal. If you have installed a copy of magnetocosmics, please check to see ensure that your paths have been set correctly, and that magneto-env.sh has been sourced correctly. If you are having issues or suspect there might be a bug, please feel free to report it at https://github.com/ssc-maire/AsymptoticDirectionsCalculator-public/issues , and I will try to respond to your issue as soon as I'm able to.")

from .MAGNETOCOSMICSrunManager import MAGNETOCOSMICSrunManager

Expand Down
6 changes: 5 additions & 1 deletion AsympDirsCalculator/MAGNETOCOSMICSrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ def __init__(self,

macroFileGenerator.generateMacro(array_of_lats_and_longs, array_of_zeniths_and_azimuths)

subprocess.run(_magnetocosmicsShellScriptPath)
try:
magnetocosmics_subprocess_run = subprocess.run(_magnetocosmicsShellScriptPath)
assert magnetocosmics_subprocess_run.returncode == 0
except:
raise Exception("ERROR: running magnetocosmics and processing output files failed, please check the above error messages to debug what might have gone wrong.")

os.chdir(originalDirectory)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

time magnetocosmics runningAsymptoticDirection.g4mac

mv AsymptoticDirection*.out outputFiles
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
package_data={"AsympDirsCalculator":["magcos_running_scripts/runNoRewriteMAGCOSsimulation.sh",
"magcos_running_scripts/AsymptoticDirection.g4mac",
]},
version='1.0.4',
version='1.0.5',
description='Python library containing tools for calculating asymptotic directions and vertical cut-off rigidities.',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit d94fe40

Please sign in to comment.