Commits

Benoît Allard  committed 2034c29

net: Add support for the server-state

  • Participants
  • Parent commits 117c489

Comments (0)

Files changed (1)

File galileo/net.py

         self.host = host
         self.path = path
         self._port = port
+        self.server_state = None
 
     @property
     def port(self):
                 {'major': str(dongle.major),
                  'minor': str(dongle.minor)}))
         client.append(info)
+        if self.server_state is not None:
+            client.append(toXML('server_state', body=self.server_state))
         if data is not None:
             for XMLElem in tuplesToXML(data):
                 client.append(XMLElem)
 
         logger.debug('HTTP response=%s', answer)
 
-        tag, attrib, childs, body = XMLToTuple(ET.fromstring(answer.encode('utf-8')))
+        tag, attrib, childs, body = XMLToTuple(ET.fromstring(
+            answer.encode('utf-8')))
 
         if tag != 'galileo-server':
             logger.error("Unexpected root element: %s", tag)
 
         if attrib['version'] != "2.0":
-            logger.error("Unexpected server version: %s",
-                         attrib['version'])
+            logger.warning("Unexpected server version: %s", attrib['version'])
 
         for child in childs:
             stag, _, schilds, sbody = child
                     if sstag == 'min': minD = int(ssbody)
                     if sstag == 'max': maxD = int(ssbody)
                 raise BackOffException(minD, maxD)
+            elif stag == 'server-state':
+                self.server_state = sbody
 
         return childs