# HG changeset patch # User Goffi # Date 1426794074 -3600 # Node ID e6bb64bd6b4d971f02482b79044c8ab8b7da1b6d # Parent 3b185ccb70b4c84d2049b86113ae93e2eceb1ca7 server side: implemented methods to get SàT and Libervia versions diff -r 3b185ccb70b4 -r e6bb64bd6b4d src/server/server.py --- a/src/server/server.py Thu Mar 19 17:27:22 2015 +0100 +++ b/src/server/server.py Thu Mar 19 20:41:14 2015 +0100 @@ -36,6 +36,7 @@ from sat.core.i18n import _, D_ from sat.core import exceptions from sat.tools.xml_tools import paramsXML2XMLUI +from sat.tools import utils import re import glob @@ -47,6 +48,7 @@ from zope.interface import Interface, Attribute, implements from xml.dom import minidom from httplib import HTTPS_PORT +import libervia try: import OpenSSL @@ -58,8 +60,11 @@ from libervia.server.constants import Const as C from libervia.server.blog import MicroBlog + # following value are set from twisted.plugins.libervia_server initialise (see the comment there) DATA_DIR_DEFAULT = OPT_PARAMETERS_BOTH = OPT_PARAMETERS_CFG = coerceDataDir = None +__version__ = C.APP_VERSION + class ISATSession(Interface): profile = Attribute("Sat profile") @@ -185,6 +190,18 @@ return jsonrpc.JSONRPC._cbRender(self, fault, request, parsed.get('id'), parsed.get('jsonrpc')) # pylint: disable=E1103 return jsonrpc.JSONRPC.render(self, request) + def jsonrpc_getVersion(self): + """Return SàT version""" + try: + return self._version_cache + except AttributeError: + self._version_cache = self.sat_host.bridge.getVersion() + return self._version_cache + + def jsonrpc_getLiberviaVersion(self): + """Return Libervia version""" + return self.sat_host.full_version + def jsonrpc_disconnect(self): """Disconnect the profile""" sat_session = ISATSession(self.session) @@ -1119,6 +1136,25 @@ self.initialised.addCallback(backendReady) self.initialised.addErrback(lambda failure: log.error("Init error: %s" % failure)) + @property + def version(self): + """Return the short version of Libervia""" + return C.APP_VERSION + + @property + def full_version(self): + """Return the full version of Libervia (with extra data when in development mode)""" + version = self.version + if version[-1] == 'D': + # we are in debug version, we add extra data + try: + return self._version_cache + except AttributeError: + self._version_cache = u"{} ({})".format(version, utils.getRepositoryData(libervia)) + return self._version_cache + else: + return version + def addCleanup(self, callback, *args, **kwargs): """Add cleaning method to call when service is stopped cleaning method will be called in reverse order of they insertion