From 362dc830c2fd5b59ced7dfcf50f64b7134fc0ccc Mon Sep 17 00:00:00 2001 From: Martijn Vermaat <martijn@vermaat.name> Date: Tue, 12 Jul 2011 14:27:26 +0000 Subject: [PATCH] New SOAP method: info(). git-svn-id: https://humgenprojects.lumc.nl/svn/mutalyzer/branches/refactor-mutalyzer-branch@295 eb6bd6ab-9ccd-42b9-aceb-e2899b4a52f1 --- extras/soap-tools/info.py | 32 ++++++++++++++++++++++++++++++ mutalyzer/models.py | 16 +++++++++++++++ mutalyzer/webservice.py | 41 ++++++++++++++++++++++++++++++++++++++- tests/test_webservice.py | 9 +++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100755 extras/soap-tools/info.py diff --git a/extras/soap-tools/info.py b/extras/soap-tools/info.py new file mode 100755 index 00000000..3a48b7b6 --- /dev/null +++ b/extras/soap-tools/info.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +# Get Mutalyzer static version information from SOAP service. +# +# See http://www.mutalyzer.nl/2.0/webservices +# +# Usage: +# python info.py +# +# This code is in the public domain; it can be used for whatever purpose +# with absolutely no restrictions. + +import sys +from suds.client import Client # https://fedorahosted.org/suds/ + +URL = 'http://localhost/mutalyzer/services/?wsdl' + +c = Client(URL, cache=None) +o = c.service + +print 'Getting version information...' +print + +r = o.info() + +print 'Version: %s' % r.version +print 'Version parts: %s' % ', '.join(p for p in r.versionParts.string) +print 'Release date: %s' % r.releaseDate +print 'Nomenclature version: %s' % r.nomenclatureVersion +print 'Nomenclature version parts: %s' % ', '.join(p for p in r.nomenclatureVersionParts.string) +print 'Server name: %s' % r.serverName +print 'Contact e-mail: %s' % r.contactEmail diff --git a/mutalyzer/models.py b/mutalyzer/models.py index 2e66fc47..94c6934d 100644 --- a/mutalyzer/models.py +++ b/mutalyzer/models.py @@ -199,3 +199,19 @@ class CheckSyntaxOutput(ClassModel): valid = Mandatory.Boolean messages = Array(SoapMessage) #CheckSyntaxOutput + + +class InfoOutput(ClassModel): + """ + Return type of SOAP method info. + """ + __namespace__ = SOAP_NAMESPACE + + version = String + versionParts = Array(String) + releaseDate = String + nomenclatureVersion = String + nomenclatureVersionParts = Array(String) + serverName = String + contactEmail = String +#MutalyzerOutput diff --git a/mutalyzer/webservice.py b/mutalyzer/webservice.py index 2b58f062..52866e54 100644 --- a/mutalyzer/webservice.py +++ b/mutalyzer/webservice.py @@ -28,6 +28,7 @@ from soaplib.core.model.clazz import Array from soaplib.core.model.exception import Fault from soaplib.core.server import wsgi import os +import socket from operator import itemgetter, attrgetter import mutalyzer @@ -841,6 +842,44 @@ class MutalyzerService(DefinitionBase): return UD #sliceChromosome + + @soap(_returns = InfoOutput) + def info(self): + """ + Gives some static application information, such as the current running + version. + + @return: Object with fields: + - version: A string of the current running version. + - versionParts: The parts of the current running version as a list + of strings. + - releaseDate: The release date for the running version as a + string, or the empty string in case of a development version. + - nomenclatureVersion: Version of the HGVS nomenclature used. + - nomenclatureVersionParts: The parts of the HGVS nomenclature + version as a list of strings. + - serverName: The name of the server that is being queried. + - contactEmail: The email address to contact for more information. + @rtype: object + """ + output = Output(__file__, self._config.Output) + output.addMessage(__file__, -1, 'INFO', 'Received request info') + + result = InfoOutput() + result.version = mutalyzer.__version__ + result.versionParts = mutalyzer.__version_info__ + if mutalyzer.RELEASE: + result.releaseDate = mutalyzer.__date__ + else: + result.releaseDate = '' + result.nomenclatureVersion = mutalyzer.NOMENCLATURE_VERSION + result.nomenclatureVersionParts = mutalyzer.NOMENCLATURE_VERSION_INFO + result.serverName = socket.gethostname() + result.contactEmail = mutalyzer.__contact__ + + output.addMessage(__file__, -1, 'INFO', 'Finished processing info') + return result + #info #MutalyzerService @@ -848,7 +887,7 @@ class MutalyzerService(DefinitionBase): soap_application = Application([MutalyzerService], mutalyzer.SOAP_NAMESPACE, 'Mutalyzer') # Note: We would like to create the wsgi.Application instance only in the -# bin/mutalyer-webservice.wsgi script, but unfortunately this breaks the +# bin/mutalyzer-webservice.wsgi script, but unfortunately this breaks the # get_wsdl method of soap_application which we use to generate API # documentation in website.py. application = wsgi.Application(soap_application) diff --git a/tests/test_webservice.py b/tests/test_webservice.py index 5d9e08ff..16019a5b 100644 --- a/tests/test_webservice.py +++ b/tests/test_webservice.py @@ -17,6 +17,7 @@ Import.open = _import_open_patched import os +import mutalyzer import logging; logging.raiseExceptions = 0 import urllib2 from suds.client import Client @@ -160,3 +161,11 @@ class TestWebservice(): 'MTAP_v005', 'C9orf53_v001']: assert_false(t in names) + + def test_info(self): + """ + Running the info method should give us some version information. + """ + r = self.client.service.info() + assert_equal(type(r.versionParts.string), list) + assert_equal(r.version, mutalyzer.__version__) -- GitLab