Problem converting a document with OO server

Asked by Arnaud Geslin

Hi

Here is my code :
fichiersortie = os.path.abspath(time.strftime('%Y-%m_')+'exemple_modele_contrat_travail_'+SOCIETE_pour_fichier+'_'+NOM_pour_fichier+'_'+PRENOM_pour_fichier+FORMAT_FICHIER)
renderer = appy.pod.renderer.Renderer('modeles/'+MODELE+'.odt',locals(),fichiersortie, ooPort=8100)
renderer.run()

and below the error I get at runtime. I can't figure out what's wrong, could someone help me ?
Thank you

----------------------------------------------------------------------------------------------------------
com.sun.star.task.ErrorCodeIOException Python 2.4.4: /usr/bin/python
Tue Mar 30 17:23:23 2010

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
 /usr/lib/cgi-bin/portail/rh/juridique/contrats_travail/rh_juridique_contrats_travail.py
  207 #renderer = appy.pod.renderer.Renderer('test_appy.odt',locals(),'test_appy_modif.doc',pythonWithUnoPath='C:\Progra~1\OpenOffice\program\python.bat', ooPort=8100)
  208 renderer = appy.pod.renderer.Renderer('modeles/'+MODELE+'.odt',locals(),fichiersortie, ooPort=8100)
  209 renderer.run()
  210
  211
renderer = <appy.pod.renderer.Renderer instance>, renderer.run = <bound method Renderer.run of <appy.pod.renderer.Renderer instance>>
 /netapp/mixte/python/portail/etchgfc_cgi-bin/rh/juridique/contrats_travail/appy/pod/renderer.py in run(self=<appy.pod.renderer.Renderer instance>)
  305 self.currentParser.parse(self.stylesXml)
  306 # Re-zip the result
  307 self.finalize()
  308
  309 def getStyles(self):
self = <appy.pod.renderer.Renderer instance>, self.finalize = <bound method Renderer.finalize of <appy.pod.renderer.Renderer instance>>
 /netapp/mixte/python/portail/etchgfc_cgi-bin/rh/juridique/contrats_travail/appy/pod/renderer.py in finalize(self=<appy.pod.renderer.Renderer instance>)
  415 self.result, FILE_TYPES.keys()))
  416 # Call OpenOffice to perform the conversion or document update
  417 self.callOpenOffice(resultOdtName, resultType)
  418 # I have the result. Move it to the correct name
  419 resPrefix = os.path.splitext(resultOdtName)[0] + '.'
self = <appy.pod.renderer.Renderer instance>, self.callOpenOffice = <bound method Renderer.callOpenOffice of <appy.pod.renderer.Renderer instance>>, resultOdtName = '/netapp/mixte/python/portail/etchgfc_cgi-bin/rh/...ntrat_travail_1_Geslin_Arnaud.pdf.temp/result.odt', resultType = 'pdf'
 /netapp/mixte/python/portail/etchgfc_cgi-bin/rh/juridique/contrats_travail/appy/pod/renderer.py in callOpenOffice(self=<appy.pod.renderer.Renderer instance>, resultOdtName='/netapp/mixte/python/portail/etchgfc_cgi-bin/rh/...ntrat_travail_1_Geslin_Arnaud.pdf.temp/result.odt', resultType='pdf')
  346 try:
  347 Converter(resultOdtName, resultType,
  348 self.ooPort).run()
  349 except ConverterError, ce:
  350 raise PodError(CONVERT_ERROR % str(ce))
self = <appy.pod.renderer.Renderer instance>, self.ooPort = 8100, ).run undefined
 /netapp/mixte/python/portail/etchgfc_cgi-bin/rh/juridique/contrats_travail/appy/pod/converter.py in run(self=<appy.pod.converter.Converter instance>)
  232 self.connect()
  233 self.loadDocument()
  234 self.convertDocument()
  235 self.doc.close(True)
  236
self = <appy.pod.converter.Converter instance>, self.convertDocument = <bound method Converter.convertDocument of <appy.pod.converter.Converter instance>>
 /netapp/mixte/python/portail/etchgfc_cgi-bin/rh/juridique/contrats_travail/appy/pod/converter.py in convertDocument(self=<appy.pod.converter.Converter instance>)
  226 optionsProp.Value = '59,34,76,1'
  227 properties.append(optionsProp)
  228 self.doc.storeToURL(self.resultUrl, tuple(properties))
  229
  230 def run(self):
self = <appy.pod.converter.Converter instance>, self.doc = pyuno object (com.sun.star.lang.XComponent)0x831...regation,com.sun.star.lang.XMultiServiceFactory}}, self.doc.storeToURL = <PyUNO_callable object>, self.resultUrl = u'file:///netapp/mixte/python/portail/etchgfc_cgi-...ntrat_travail_1_Geslin_Arnaud.pdf.temp/result.pdf', builtin tuple = <type 'tuple'>, properties = [(com.sun.star.beans.PropertyValue){ Name = (stri... (com.sun.star.beans.PropertyState)DIRECT_VALUE }]

com.sun.star.task.ErrorCodeIOException:
      Context = None
      ErrCode = 283
      Message = u''
      typeName = 'com.sun.star.task.ErrorCodeIOException'
      value =
code erreur : tmpA8t2z9.html

Question information

Language:
English Edit question
Status:
Solved
For:
Appy Edit question
Assignee:
No assignee Edit question
Solved by:
Arnaud Geslin
Solved:
Last query:
Last reply:
Revision history for this message
Gaëtan Delannay (gaetan-delannay) said :
#1

Hello,
1) When you call the appy.pod.renderer.Renderer, give him absolute paths for all file names, it is more secure.
2) It seems that the error occurs when OpenOffice tries to write the result on disk. Has the user running OpenOffice the permission to write in the folder of the generated result? If you try to write the resulting file at other places (ie, in /tmp), does it work?
3) What web framework do you use? Isn't it possible to produce standard Python stacktraces ? It would be more easy to give you the right answers.
Cheers !
Gaetan

Revision history for this message
Arnaud Geslin (lokoyahoo-launchpad) said :
#2

Hello Gaëtan

Yes I give absolute path to Renderer, see my code : fichiersortie = os.path.abspath(my_filename)

The result file is supposed to be written in the same directory than the python script. And this dir is 777. I see in the log that

self.resultUrl = u'file:///netapp/mixte/python/portail/...Ventilation.pdf.temp/result.pdf

Is it normal that the file name ends with "...pdf.temp/result.pdf" ? The slash means POD tries to create a subdir ?

Revision history for this message
Arnaud Geslin (lokoyahoo-launchpad) said :
#3

(PS : about the framwork : I'm launching the whole stuff with a web client that calls my python script as a cgi)

Revision history for this message
Gaëtan Delannay (gaetan-delannay) said :
#4

Yes it is normal. Pod creates a temp folder where the template ODT is unzippped and the result is created and then converted to PDF. Maybe the temp dir that is created by the POD user (=cgi user) is created in such a way that the OpenOffice user can't write in the temp folder ?

Revision history for this message
Arnaud Geslin (lokoyahoo-launchpad) said :
#5

That's right, as it works when I force dir to /tmp.

Thus I will look what's wrong with my dirs and users on Linux.

Thanks a lot for your help.
Arnaud