2 Copyright (c) 2010 Brookhaven National Laboratory
3 All rights reserved. Use is subject to license terms and conditions.
5 Created on Jan 10, 2013
12 A LogEntry consists of some Text description, an owner and an associated logbook
13 It can optionally be associated with one or more logbooks and contain one or more tags, properties and attachments
16 def __init__(self, text, owner, logbooks, tags=[], attachments=[], properties=[], id=None, createTime=None, modifyTime=None):
18 Constructor for log Entry
20 >> LogEntry('test log entry', 'controls', logbooks=[Logbook('commissioning', owner='controls')])
22 Comprehensive logEntry
23 >> LogEntry('test log entry', 'controls',
24 logbooks=[Logbook('commissioning', owner='controls')],
25 tags=[Tag('TimingSystem')]
26 properties=[Property('Ticket', attributes={'Id':'1234','URL':'http://trac.nsls2.bnl.gov/trac/1234'}]
27 attachments=[Attachment(open('databrowser.plt'))]
30 self.
Text = str(text).strip();
31 self.
Owner = str(owner).strip();
43 def getCreateTime(self):
46 def getModifyTime(self):
55 def getLogbooks(self):
61 def getAttachments(self):
64 def getProperties(self):
67 def __cmp__(self, *arg, **kwargs):
71 return cmp((self.
__id),(arg[0].__id))
73 raise Exception,
'Invalid LogEntry: id cannot be None'
78 A Logbook consist of an unique name and an owner,
79 logentries can be added to a logbook so long as the user either the owner
80 or a member of the owner group
86 >> Logbook('commissioning', 'controls')
88 self.
__Name = str(name).strip();
89 self.
__Owner = str(owner).strip();
97 def __cmp__(self, *arg, **kwargs):
100 return cmp((self.
__Name, self.
__Owner), (arg[0].__Name, arg[0].__Owner))
104 A Tag consists of a unique name, it is used to tag logEntries to enable querying and organizing log Entries
110 >> Tag('TimingSystem')
112 self.
__Name = str(name).strip()
113 self.
__State = str(state).strip()
121 def __cmp__(self, *arg, **kwargs):
124 return cmp((self.
__Name, self.
__State), (arg[0].__Name, arg[0].__State))
128 A Attachment, a file associated with the log entry
129 TODO this is not thread safe
135 >> Attachment(file=open('/home/usr/databrowser.plt')
136 >> Attachment(file=open('test.jpg','rb')
145 A property consists of a unique name and a set of attributes consisting of key value pairs
150 Create a property with a unique name and attributes
151 >> Property('Ticket', attributes={'Id':'1234','URL':'http://trac.nsls2.bnl.gov/trac/1234'}
152 >> Property('Scan', attributes={'Number':'run-1234', 'script':'scan_20130117.py'}
154 self.
__Name = str(name).strip()
160 def getAttributes(self):
163 def getAttributeNames(self):
164 return self.Attributes.keys()
166 def getAttributeValue(self, attributeName):
167 return self.Attributes.get(attributeName)
169 def __cmp__(self, *arg, **kwargs):
172 return cmp((self.
__Name, set(self.
Attributes)), (arg[0].__Name, set(arg[0].Attributes)))