Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • DM/dm-docs
  • hammonds/dm-docs
  • hparraga/dm-docs
3 results
Show changes
#!/usr/bin/env python
#
# Route mapper for DM DAQ web service.
#
import sys
import os
import cherrypy
from dm.common.utility.loggingManager import LoggingManager
from dm.common.utility.configurationManager import ConfigurationManager
from dm.common.service.loginRouteDescriptor import LoginRouteDescriptor
from workflowRouteDescriptor import WorkflowRouteDescriptor
class ProcWebServiceRouteMapper:
@classmethod
def setupRoutes(cls):
""" Setup RESTFul routes. """
logger = LoggingManager.getInstance().getLogger(cls.__name__)
contextRoot = ConfigurationManager.getInstance().getContextRoot()
logger.debug('Using context root: %s' % contextRoot)
# Get routes.
routes = LoginRouteDescriptor.getRoutes()
routes += WorkflowRouteDescriptor.getRoutes()
# Add routes to dispatcher.
d = cherrypy.dispatch.RoutesDispatcher()
for route in routes:
logger.debug('Connecting route: %s' % route)
d.connect(route['name'], route['path'], action=route['action'], controller=route['controller'], conditions=dict(method=route['method']))
return d
#!/usr/bin/env python
#
# User route descriptor.
#
from dm.common.utility.configurationManager import ConfigurationManager
from workflowSessionController import WorkflowSessionController
class WorkflowRouteDescriptor:
@classmethod
def getRoutes(cls):
contextRoot = ConfigurationManager.getInstance().getContextRoot()
# Static instances shared between different routes
workflowSessionController = WorkflowSessionController()
# Define routes.
routes = [
# Get workflow
{
'name' : 'getWorkflowByName',
'path' : '%s/workflowsByOwner/:(owner)/:(encodedName)' % contextRoot,
'controller' : workflowSessionController,
'action' : 'getWorkflowByName',
'method' : ['GET']
},
]
return routes
#!/usr/bin/env python
import cherrypy
import json
from dm.common.utility.encoder import Encoder
from dm.common.service.dmSessionController import DmSessionController
from dm.proc_web_service.service.impl.workflowSessionControllerImpl import WorkflowSessionControllerImpl
class WorkflowSessionController(DmSessionController):
def __init__(self):
DmSessionController.__init__(self)
self.workflowSessionControllerImpl = WorkflowSessionControllerImpl()
@cherrypy.expose
@DmSessionController.require(DmSessionController.canManageStation())
@DmSessionController.execute
def getWorkflowByName(self, owner, encodedName, **kwargs):
if not owner:
raise InvalidRequest('Invalid owner provided.')
name = Encoder.decode(encodedName)
if not name:
raise InvalidRequest('Invalid workflow name provided.')
response = self.workflowSessionControllerImpl.getWorkflowByName(owner, name).getFullJsonRep()
return response
all:
for d in $(SUBDIRS); do $(MAKE) -C $$d $(ARCH); done
dist:
for d in $(SUBDIRS); do $(MAKE) -C $$d $(ARCH); done
clean:
for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done
distclean:
for d in $(SUBDIRS); do $(MAKE) -C $$d distclean; done
for d in $(SUBDIRS); do rm -f `find $$d -name 'RELEASE.local'`; done
tidy: distclean