Skip to content

Commit dd9d853

Browse files
committed
Allow people without MOPAC to run RMG.
The 'check that you can find Mopac' test was being run on importing rmgpy.qm.mopac which apparently is done whether or not QM is being used. Now it is postponed until you are about to run a job. I did the same for Gaussian while I was at it.
1 parent a1fc8f6 commit dd9d853

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

rmgpy/qm/gaussian.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ class Gaussian:
3333
successKeys = [
3434
'Normal termination of Gaussian'
3535
]
36-
36+
37+
def testReady(self):
38+
if not os.path.exists(self.executablePath):
39+
raise Exception("Couldn't find Gaussian executable at {0}. Try setting your GAUSS_EXEDIR environment variable.".format(self.executablePath))
40+
41+
3742
def run(self):
43+
self.testReady()
3844
# submits the input file to Gaussian
3945
process = Popen([self.executablePath, self.inputFilePath, self.outputFilePath])
4046
process.communicate()# necessary to wait for executable termination!

rmgpy/qm/mopac.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Mopac:
1818
inputFileExtension = '.mop'
1919
outputFileExtension = '.out'
2020
executablePath = os.path.join(os.getenv('MOPAC_DIR', default="/opt/mopac") , 'MOPAC2012.exe')
21-
assert os.path.exists(executablePath), "Couldn't find MOPAC 2009 executable at {0}. Try setting your MOPAC_DIR environment variable.".format(executablePath)
2221

2322
usePolar = False #use polar keyword in MOPAC
2423

@@ -48,8 +47,13 @@ class Mopac:
4847
'DESCRIPTION OF VIBRATIONS',
4948
]
5049

50+
def testReady(self):
51+
if not os.path.exists(self.executablePath):
52+
raise Exception("Couldn't find MOPAC 2012 executable at {0}. Try setting your MOPAC_DIR environment variable.".format(self.executablePath))
53+
5154

5255
def run(self):
56+
self.testReady()
5357
# submits the input file to mopac
5458
process = Popen([self.executablePath, self.inputFilePath])
5559
process.communicate()# necessary to wait for executable termination!

0 commit comments

Comments
 (0)