diff --git a/python_transport/wirepas_gateway/transport_service.py b/python_transport/wirepas_gateway/transport_service.py index 71936893..a056eb51 100644 --- a/python_transport/wirepas_gateway/transport_service.py +++ b/python_transport/wirepas_gateway/transport_service.py @@ -20,6 +20,8 @@ GatewayAPIParsingException, ) +from wirepas_gateway import __version__ as transport_version + # This constant is the actual API level implemented by this transport module (cf WP-RM-128) IMPLEMENTED_API_VERSION = 1 @@ -36,6 +38,8 @@ class TransportService(BusClient): MAX_HOP_LIMIT = 15 def __init__(self, settings, logger=None, **kwargs): + self.logger = logger or logging.getLogger(__name__) + self.logger.info("Version is: {}".format(transport_version)) super(TransportService, self).__init__( logger=logger, @@ -66,8 +70,6 @@ def __init__(self, settings, logger=None, **kwargs): self.mqtt_wrapper.start() - self.logger = logger or logging.getLogger(__name__) - self.logger.info("Gateway started with id: {}".format(self.gw_id)) def _on_mqtt_wrapper_termination_cb(self): @@ -613,7 +615,8 @@ def main(): """ ParserHelper() - parse = ParserHelper(description="Default arguments") + parse = ParserHelper(description="Default arguments", + version=transport_version) parse.add_file_settings() parse.add_mqtt() diff --git a/python_transport/wirepas_gateway/utils/argument_tools.py b/python_transport/wirepas_gateway/utils/argument_tools.py index 2f675ad4..0f3207f6 100644 --- a/python_transport/wirepas_gateway/utils/argument_tools.py +++ b/python_transport/wirepas_gateway/utils/argument_tools.py @@ -61,6 +61,7 @@ def __init__( self, description="argument parser", formatter_class=argparse.ArgumentDefaultsHelpFormatter, + version=None ): super(ParserHelper, self).__init__() self._parser = argparse.ArgumentParser( @@ -71,6 +72,12 @@ def __init__( self._unknown_arguments = None self._arguments = None + if version is not None: + self.main.add_argument( + "--version", + action="version", + version=version) + @property def parser(self): """ Returns the parser object """