This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
tabellioOOo/win32legiopen/win32legiopen.py

32 lines
736 B
Python

#! /usr/bin/env python
import os
import sys
import httplib
import tempfile
import random
filename = sys.argv[1]
conn = httplib.HTTPConnection("ootest.pcf.be")
body = file(filename, 'rb').read()
conn.request("POST", "/preview/odt", body=body)
response = conn.getresponse()
data = response.read()
conn.close()
output_filename = os.path.splitext(os.path.basename(filename))[0]
output_filename = os.path.join(tempfile.gettempdir(), output_filename)
if os.path.exists(output_filename + '.odt'):
i = 1
while os.path.exists(output_filename + '-%s.odt'%i):
i += 1
output_filename += '-%s' % i
output_filename += '.odt'
fd = file(output_filename, 'wb')
fd.write(data)
fd.close()
os.system('start %s' % output_filename)