1 | #!/usr/bin/python
|
---|
2 | # Python script to convert dpcuments via OpenOffice & Unoconv for Xapian-Omega
|
---|
3 | #
|
---|
4 | # Copyright 2009 Frank J Bruzzaniti
|
---|
5 | #
|
---|
6 | # This program is free software; you can redistribute it and/or
|
---|
7 | # modify it under the terms of the GNU General Public License as
|
---|
8 | # published by the Free Software Foundation; either version 2 of the
|
---|
9 | # License, or (at your option) any later version.
|
---|
10 | #
|
---|
11 | # This program is distributed in the hope that it will be useful,
|
---|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | # GNU General Public License for more details.
|
---|
15 | #
|
---|
16 | # You should have received a copy of the GNU General Public License
|
---|
17 | # along with this program; if not, write to the Free Software
|
---|
18 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
|
---|
19 | # USA
|
---|
20 |
|
---|
21 | import os, sys, time
|
---|
22 | from subprocess import *
|
---|
23 |
|
---|
24 | # Get pid of any running soffice processes
|
---|
25 | getpid = Popen(["ps -ef | grep -v grep | grep '/usr/lib/openoffice/program/soffice.bin -headless -accept=socket,host=127.0.0.1,port=2002;urp; -nofirststartwizard' | cut -f3 -d' '"], shell=True, stdout=PIPE).stdout
|
---|
26 |
|
---|
27 | # Save pid might be usefull
|
---|
28 | pid = getpid.read()
|
---|
29 | #print "PID=" + pid
|
---|
30 |
|
---|
31 | # If soffice not running start and wait 5 secs
|
---|
32 | if pid == "":
|
---|
33 | Popen(['soffice -headless -accept="socket,host=127.0.0.1,port=2002;urp;" -nofirststartwizard'], shell=True)
|
---|
34 | #print "I didn't find soffice running so I'm starting one now and waiting 5 secs"
|
---|
35 | time.sleep(5)
|
---|
36 |
|
---|
37 | # Run unoconv
|
---|
38 | os.system('unoconv --stdout -f text ' + sys.argv[1])
|
---|
39 |
|
---|
40 |
|
---|