From be4f431ab636256b5b9c364b873a5b1096361c6b Mon Sep 17 00:00:00 2001 From: ahrenholz Date: Mon, 27 Oct 2014 20:52:01 +0000 Subject: [PATCH] revise EMANE 0.9.2 detection due to protobuf file under Ubuntu 12.04 make Emane.detectversionfromcmd() a classmethod (Boeing r1890,1891) --- daemon/core/emane/emane.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/daemon/core/emane/emane.py b/daemon/core/emane/emane.py index 9dd04a9c..13d1f111 100644 --- a/daemon/core/emane/emane.py +++ b/daemon/core/emane/emane.py @@ -32,15 +32,6 @@ try: from emanesh.events import LocationEvent except Exception, e: pass -# EMANE 0.9.2 -try: - from emanesh import remotecontrolportapi_pb2 - HAVE092 = ('TYPE_COMPONENT_TRANSPORT' in - dir(remotecontrolportapi_pb2.Response.Query.Manifest.NEM.Component)) - del remotecontrolportapi_pb2 -except Exception, e: - HAVE092 = False - class Emane(ConfigurableManager): ''' EMANE controller object. Lives in a Session instance and is used for @@ -85,7 +76,8 @@ class Emane(ConfigurableManager): if self.verbose: self.info("detected EMANE version: %s" % self.versionstr) - def detectversionfromcmd(self): + @classmethod + def detectversionfromcmd(cls): ''' Runs 'emane --version' locally to determine version number. ''' # for further study: different EMANE versions on distributed machines @@ -95,16 +87,16 @@ class Emane(ConfigurableManager): except OSError: status = -1 result = "" - v = self.EMANEUNK + v = cls.EMANEUNK if status == 0: if result[:5] == "0.7.4": - v = self.EMANE074 + v = cls.EMANE074 elif result[:5] == "0.8.1": - v = self.EMANE081 + v = cls.EMANE081 elif result[:5] == "0.9.1": - v = self.EMANE091 + v = cls.EMANE091 elif result[:5] == "0.9.2": - v = self.EMANE092 + v = cls.EMANE092 return v, result.strip() def initeventservice(self, filename=None, shutdown=False): @@ -1246,6 +1238,11 @@ class EmaneModel(WirelessModel): return None return addparamlisttoparent(dom, parent=None, name=name, values=values) +# EMANE 0.9.2 detected upon module load to support class vars +try: + HAVE092 = (Emane.detectversionfromcmd()[0] >= Emane.EMANE092) +except Exception, e: + HAVE092 = False class EmaneGlobalModel(EmaneModel): ''' Global EMANE configuration options.