From c258a7ab7414993d0c62c10f5db28aa2b5fe6318 Mon Sep 17 00:00:00 2001 From: Sinisa Veseli <sveseli@aps.anl.gov> Date: Thu, 9 Apr 2015 17:06:01 +0000 Subject: [PATCH] added experiment/experiment type classes that match db entities --- src/python/dm/common/objects/experiment.py | 17 ++++++++++ .../dm/common/objects/experimentType.py | 17 ++++++++++ src/python/dm/common/objects/observedFile.py | 31 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100755 src/python/dm/common/objects/experiment.py create mode 100755 src/python/dm/common/objects/experimentType.py create mode 100755 src/python/dm/common/objects/observedFile.py diff --git a/src/python/dm/common/objects/experiment.py b/src/python/dm/common/objects/experiment.py new file mode 100755 index 00000000..7c357862 --- /dev/null +++ b/src/python/dm/common/objects/experiment.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +import time +from dmObject import DmObject + +class Experiment(DmObject): + + DEFAULT_KEY_LIST = [ 'id', 'name', 'dataDirectory', 'startTime', 'stopTime' ] + + def __init__(self, dict={}): + DmObject.__init__(self, dict) + +#################################################################### +# Testing +if __name__ == '__main__': + pass + diff --git a/src/python/dm/common/objects/experimentType.py b/src/python/dm/common/objects/experimentType.py new file mode 100755 index 00000000..20369b17 --- /dev/null +++ b/src/python/dm/common/objects/experimentType.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +import time +from dmObject import DmObject + +class ExperimentType(DmObject): + + DEFAULT_KEY_LIST = [ 'id', 'name', 'description`', 'rootDataPath' ] + + def __init__(self, dict={}): + DmObject.__init__(self, dict) + +#################################################################### +# Testing +if __name__ == '__main__': + pass + diff --git a/src/python/dm/common/objects/observedFile.py b/src/python/dm/common/objects/observedFile.py new file mode 100755 index 00000000..2ffee284 --- /dev/null +++ b/src/python/dm/common/objects/observedFile.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +import time +from dmObject import DmObject + +class ObservedFile(DmObject): + + DEFAULT_KEY_LIST = [ 'path', 'lastUpdatedTimestamp' ] + + def __init__(self, path=None, dict={}): + DmObject.__init__(self, dict) + if path: + self['path'] = path + + def setLastUpdatedTimestampToNow(self): + self['lastUpdateTimestamp'] = time.time() + + def getLastUpdatedTimestamp(self): + self.get('lastUpdateTimestamp') + + def getPath(self): + return self.get('path') + +#################################################################### +# Testing +if __name__ == '__main__': + of = ObservedFile(path='tmp/xyz') + print of + of.setLastUpdatedTimestampToNow() + print of + -- GitLab