-
Notifications
You must be signed in to change notification settings - Fork 122
/
CheckForSampleLogs.py
50 lines (42 loc) · 1.62 KB
/
CheckForSampleLogs.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from mantid.api import PythonAlgorithm, AlgorithmFactory, WorkspaceProperty
import mantid.simpleapi
from mantid.kernel import Direction, logger
from string import *
class CheckForSampleLogs(PythonAlgorithm):
""" Check if certain sample logs exists on a workspace
"""
def category(self):
""" Return category
"""
return "PythonAlgorithms;Utility\\Workspaces"
def name(self):
""" Return name
"""
return "CheckForSampleLogs"
def summary(self):
return "Check if the workspace has some given sample logs"
def PyInit(self):
""" Declare properties
"""
self.declareProperty(WorkspaceProperty("Workspace", "",Direction.Input), "The workspace to check.")
self.declareProperty("LogNames","","Names of the logs to look for")
self.declareProperty("Result","A string that will be empty if all the logs are found, otherwise will contain an error message",Direction.Output)
return
def PyExec(self):
""" Main execution body
"""
#get parameters
w = self.getProperty("Workspace").value
logNames = self.getProperty("LogNames").value
resultString=''
#check for parameters and build the result string
for value in logNames.split(','):
value=value.strip()
if len(value)>0:
if not w.run().hasProperty(value):
resultString+='Property '+value+' not found\n'
#return the result
logger.notice(resultString)
self.setProperty("Result",resultString)
return
AlgorithmFactory.subscribe(CheckForSampleLogs)