~mapclient.devs/mapclient/stable

« back to all changes in this revision

Viewing changes to mapclient/core/workflow.py

  • Committer: musculoskeletal
  • Date: 2014-06-25 05:38:05 UTC
  • mfrom: (1.6.35 testing)
  • Revision ID: musculoskeletal@bioeng1033-20140625053805-jkqhi5oq74vmlntl
Merging testing into stable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from PySide import QtCore
23
23
 
24
 
from settings import info
25
 
from core.workflowscene import WorkflowScene
26
 
 
27
 
class WorkflowError(Exception):
28
 
    pass
 
24
from mapclient.settings import info
 
25
from mapclient.core.workflowscene import WorkflowScene
 
26
from mapclient.core.workflowerror import WorkflowError
29
27
 
30
28
_PREVIOUS_LOCATION_STRING = 'previousLocation'
31
29
 
35
33
def _getWorkflowConfigurationAbsoluteFilename(location):
36
34
    return os.path.join(location, info.DEFAULT_WORKFLOW_PROJECT_FILENAME)
37
35
 
38
 
class WorkflowManager():
 
36
class WorkflowManager(object):
39
37
    '''
40
 
    This class managers the workflow.
 
38
    This class manages (models?) the workflow.
41
39
    '''
42
40
 
43
41
    def __init__(self):
66
64
 
67
65
        return self._title
68
66
 
 
67
    # Why set/get? all _prefix are public anyway, just use attributes...
 
68
    # if they need to be modified they can be turned into properties
69
69
    def setLocation(self, location):
70
70
        self._location = location
71
71
 
130
130
 
131
131
    def load(self, location):
132
132
        '''
133
 
        Open a workflow from the given _location.
134
 
        :param _location:
 
133
        Open a workflow from the given location.
 
134
        :param location:
135
135
        '''
136
136
        if location is None:
137
137
            raise WorkflowError('No location given to open Workflow.')
145
145
 
146
146
        workflow_version = versionTuple(wf.value('version'))
147
147
        software_version = versionTuple(info.VERSION_STRING)
148
 
        if not (workflow_version[0] == software_version[0] and workflow_version[1] == software_version[1] and workflow_version[2] <= software_version[2]):
149
 
            raise WorkflowError('Version mismatch in Workflow expected: %s got: %s' % (info.VERSION_STRING, wf.value('version')))
 
148
        if not workflow_version[0:2] == software_version[0:2]:
 
149
            # compare first two elements of version (major, minor)
 
150
            raise WorkflowError(
 
151
                'Major/Minor version number mismatch - '
 
152
                'application version: %s; workflow version: %s.' %
 
153
                    (info.VERSION_STRING, wf.value('version'))
 
154
            )
 
155
        if not workflow_version[2] <= software_version[2]:
 
156
            raise WorkflowError(
 
157
                'Patch version number of the workflow cannot be newer than '
 
158
                'application - '
 
159
                'application version: %s; workflow version: %s' %
 
160
                    (info.VERSION_STRING, wf.value('version'))
 
161
            )
150
162
 
151
163
        self._location = location
152
164
#        wf = _getWorkflowConfiguration()
183
195
 
184
196
def versionTuple(v):
185
197
    return tuple(map(int, (v.split("."))))
186
 
 
187
 
 
188
 
 
189
 
 
190
 
 
191
 
 
192
 
 
193
 
 
194
 
 
195
 
 
196
 
 
197
 
 
198
 
 
199
 
 
200