[apycotlib] only send the difference between actual logs and total logs (closes #3241602)
authorPaul Tonelli <paul.tonelli@logilab.fr>
Wed, 04 Sep 2013 16:48:47 +0200
changeset 1436 75d64b47ddf7
parent 1435 e46aceaf338c
child 1437 852ed74b3cf4
[apycotlib] only send the difference between actual logs and total logs (closes #3241602) in refreshlog, used by narval. This enables other connexions to send logs in between
_apycotlib/writer.py
test/unittest_apycot.py
--- a/_apycotlib/writer.py	Tue Aug 20 18:36:05 2013 +0200
+++ b/_apycotlib/writer.py	Wed Sep 04 16:48:47 2013 +0200
@@ -150,14 +150,14 @@
     def refresh_log(self):
         log = self._logs
         if self._logs_sent < len(log):
-            files = {'log': ('file', u'\n'.join(log))}
+            files = {'log': ('file', u'\n'.join(log[self._logs_sent:]) + '\n' )}
             self._cnxh.http_post(self.instance_url() +
                     'file-upload',
                     files=files,
                     eid=self.target_eid(),
                     is_execution_log='',
                     _cw_fields='eid,is_execution_log,log')
-            self._log_sent = len(log)
+            self._logs_sent = len(log)
 
 
 class CheckDataWriter(BaseDataWriter):
@@ -182,14 +182,7 @@
 
     def end(self, status):
         """Register the given checker as closed with status <status>"""
-        if self._logs:
-            files = {'log': ('file', u'\n'.join(self._logs))}
-            self._cnxh.http_post(self.instance_url() +
-                    'file-upload',
-                    files=files,
-                    eid=self.target_eid(),
-                    is_execution_log='',
-                    _cw_fields='eid,is_execution_log,log')
+        self.refresh_log()
         self._cnxh.http_post(self._url, vid='set_attributes',
                              status=self._unicode(status),
                              endtime=datetime.now(),)
--- a/test/unittest_apycot.py	Tue Aug 20 18:36:05 2013 +0200
+++ b/test/unittest_apycot.py	Wed Sep 04 16:48:47 2013 +0200
@@ -48,13 +48,15 @@
         self.assertMultiLineEqual(checks.get_entity(0, 0).log, '''\
 20\t\t\toption=value<br/>
 40\t\t\tbouh<br/>
-50\t\t\tdi&amp;d<br/>''')
+50\t\t\tdi&amp;d<br/>
+''')
         self.assertMultiLineEqual(checks.get_entity(1, 0).log, '''\
 10\t/tmp/something\t12\thip<br/>
 20\t/tmp/something\t\thop<br/>
 30\t\t\tmomo
 
-&lt;br/&gt;<br/>''')
+&lt;br/&gt;<br/>
+''')
 
     def test_log_formatting_first_check(self):
         stream = []