forked from ReactionMechanismGenerator/RMG-Py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabaseTester.py
36 lines (31 loc) · 1.27 KB
/
databaseTester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
This scripts runs tests on the database
"""
import os.path
import logging
from rmgpy import settings
from rmgpy.data.rmg import RMGDatabase
def checkFamilies(FullDatabase):
databaseLog=logging.getLogger('databaseLog')
familyStatus={}
for family in FullDatabase.kinetics.families:
databaseLog.error('\nChecking ' + family + "...")
print 'Checking ' + family + "..."
familyStatus[family]=FullDatabase.kinetics.families[family].checkWellFormed()
if __name__ == '__main__':
# Set up paths for database and logger
databaseDirectory = settings['database.directory'] # RMG-database/input
logPath = os.path.join(databaseDirectory, '..', 'database.log')
#clear logger if it exists
if os.path.exists(logPath):
with open(logPath, 'w'):
pass
databaseLog=logging.getLogger('databaseLog')
fh=logging.FileHandler(logPath)
fh.setLevel(logging.DEBUG)
databaseLog.addHandler(fh)
databaseLog.propagate=False #prevents these logging messages to being sent to ancestors (so that it doesn't print on console)
# logging.basicConfig(filename=logpath, level=logging.ERROR)
FullDatabase=RMGDatabase()
FullDatabase.load(databaseDirectory, kineticsFamilies='all')
checkFamilies(FullDatabase)