[apycotlib] replace the use of create_subentity controller by rqlio draft
authorDavid Douard <david.douard@logilab.fr>
Thu, 13 Nov 2014 14:41:15 +0100
changeset 1744 aa2677d6b9dc
parent 1743 a9b471081580
child 1745 6d0c307e3868
[apycotlib] replace the use of create_subentity controller by rqlio
_apycotlib/writer.py
--- a/_apycotlib/writer.py	Thu Nov 13 14:34:08 2014 +0100
+++ b/_apycotlib/writer.py	Thu Nov 13 14:41:15 2014 +0100
@@ -110,7 +110,6 @@
 
     <severity>TAB<path>TAB<line>TAB<logging message>
     """
-
     def __init__(self, cnxh, target_eid):
         self.cnxh = cnxh
         # eid of the execution entity
@@ -213,6 +212,8 @@
     A test consist in a setup procedure (the install step) followed by
     one or more checkers, each one executed in the environment set up
     during the install step
+
+    self.target_eid is the eid of the TestExecution
     """
 
     def make_check_writer(self):
@@ -235,7 +236,7 @@
         self.cnxh.rqlio([('SET CR status %(status)s WHERE CR eid %(eid)s',
                           {'status': self._unicode(status),
                            'eid': self.target_eid})])
-        
+
         if archivedir:
             self.cnxh.debug('Archive the apycot temp directory')
             archive = make_archive_name(self.cnxh.instance_id, self.target_eid)
@@ -247,14 +248,12 @@
                 tarball.add(archivedir, arcname=os.path.basename(archivedir))
                 tarball.close()
                 self.cnxh.debug('** archive file size: %s' % (os.stat(archivefpath).st_size))
-                data = self.cnxh.http_post(self._url, vid='create_subentity',
-                                    __cwetype__='File',
-                                    __cwrel__='reverse_execution_archive',
-                                    data_name=archive,
-                                    data_format=ARCHIVE_MIME_TYPE)[0]
-                url = self.cnxh.instance_url + 'narval-file-append'
-                files = {'data': ('dummy', open(archivefpath, 'rb'))}
-                self.cnxh.http_post(url=url, files=files, eid=data['eid'])
+                self.cnxh.rqlio([('INSERT File F: F data %(content)s, '
+                                  'F data_name %(fname)s, F data_format %(fmt)s, '
+                                  'TE execution_archive F WHERE TE eid %(eid)s',
+                                  {'content': open(archivefpath, 'rb'),
+                                   'fname':archive, 'fmt': ARCHIVE_MIME_TYPE,
+                                   'eid': self.target_eid})])
                 self.cnxh.debug('** archive file %s uploaded' % archive)
             except:
                 self.cnxh.error('while archiving execution directory', tb=True)