2 # -*- coding: utf-8 -*-
4 # Copyright (c) 2008 by Hartmut Goebel <h.goebel@goebel-consult.de>
5 # Licenced under the GNU General Public License v3 (GPLv3)
6 # see file LICENSE-gpl-3.0.txt
9 __author__ = "Hartmut Goebel <h.goebel@goebel-consult.de>"
10 __copyright__ = "Copyright (c) 2008 by Hartmut Goebel <h.goebel@goebel-consult.de>"
11 __licence__ = "GPLv3 - GNU General Public License v3"
13 import openoffice.interact
15 def loadAsStream(odf_filename, opts=None):
16 desktop = openoffice.interact.Desktop(host=opts.host, port=opts.port)
18 stream = open(odf_filename)
20 # using a file-like object works, too
22 stream = StringIO.StringIO(stream.read())
24 doc = desktop.openStream(stream, hidden=True)
28 if __name__ == '__main__':
30 parser = optparse.OptionParser('%prog [options] ODF-Filename')
31 group = parser.add_option_group('To connect to already running server use:')
32 group.add_option('--host', #default='localhost',
33 help="hostname/ip of server (default: %default)")
34 group.add_option('--port', default=2002, type=int,
35 help="port the server is listening on (default: %default)")
37 opts, args = parser.parse_args()
39 parser.error('expects exactly one argument')
42 loadAsStream(*args, **{'opts': opts})