From c09eb68d9142eab98d2815fa73435bdf1c45aedc Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 14 Dec 2012 15:07:37 +0100 Subject: [PATCH] =?utf8?q?Python-Interpreter=20und=20-Modulpfad=20=C3=BCbe?= =?utf8?q?r=20Konfigurationsoptionen=20in=20kivitendo.conf=20konfigurierba?= =?utf8?q?r=20gemacht?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Behebt #671. --- SL/Template/OpenDocument.pm | 31 +++++++++++++++++-------------- config/kivitendo.conf.default | 9 +++++++++ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index b4ea1f2a5..e0523d346 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -416,11 +416,21 @@ sub spawn_xvfb { return $display; } +sub _run_python_uno { + my ($self, @args) = @_; + + local $ENV{PYTHONPATH}; + $ENV{PYTHONPATH} = $::lx_office_conf{environment}->{python_uno_path} . ':' . $ENV{PYTHONPATH} if $::lx_office_conf{environment}->{python_uno_path}; + my $cmd = $::lx_office_conf{applications}->{python_uno} . ' ' . join(' ', @args); + return `$cmd`; +} + sub is_openoffice_running { + my ($self) = @_; + $main::lxdebug->enter_sub(); - my $cmd = "./scripts/oo-uno-test-conn.py " . $::lx_office_conf{print_templates}->{openofficeorg_daemon_port} . " 2> /dev/null"; - my $output = `$cmd`; + my $output = $self->_run_python_uno('./scripts/oo-uno-test-conn.py', $::lx_office_conf{print_templates}->{openofficeorg_daemon_port}, ' 2> /dev/null'); chomp $output; my $res = ($? == 0) || $output; @@ -508,27 +518,20 @@ sub convert_to_pdf { return 0; } - my @cmdline; if (!$::lx_office_conf{print_templates}->{openofficeorg_daemon}) { - @cmdline = ($::lx_office_conf{applications}->{openofficeorg_writer}, - "-minimized", "-norestore", "-nologo", "-nolockcheck", - "-headless", - "file:${filename}.odt", - "macro://" . (split('/', $filename))[-1] . - "/Standard.Conversion.ConvertSelfToPDF()"); + system($::lx_office_conf{applications}->{openofficeorg_writer}, + "-minimized", "-norestore", "-nologo", "-nolockcheck", "-headless", + "file:${filename}.odt", + "macro://" . (split('/', $filename))[-1] . "/Standard.Conversion.ConvertSelfToPDF()"); } else { if (!$self->spawn_openoffice()) { $main::lxdebug->leave_sub(); return 0; } - @cmdline = ("./scripts/oo-uno-convert-pdf.py", - $::lx_office_conf{print_templates}->{openofficeorg_daemon_port}, - "${filename}.odt"); + $self->_run_python_uno('./scripts/oo-uno-convert-pdf.py', $::lx_office_conf{print_templates}->{openofficeorg_daemon_port}, "${filename}.odt"); } - system(@cmdline); - my $res = $?; if ((0 == $?) || (-f "${filename}.pdf" && -s "${filename}.pdf")) { $form->{"tmpfile"} =~ s/odt$/pdf/; diff --git a/config/kivitendo.conf.default b/config/kivitendo.conf.default index 7d83d6c33..1391239f8 100644 --- a/config/kivitendo.conf.default +++ b/config/kivitendo.conf.default @@ -127,6 +127,11 @@ html2ps = html2ps ghostscript = gs # Location of the pdflatex (or compatible, e.g. xetex) binary latex = pdflatex +# Location of the Python interpreter to use when converting from +# OpenDocument to PDF. Some distributions compile UNO support only +# into binaries located in different locations than the main Python +# binary. +python_uno = python # Location of the two executables "pg_dump" and "pg_restore" used for # database backup and restoration from the admin section. If # "pg_dump" or "pg_restore" is set to "DISABLED" then the @@ -141,6 +146,10 @@ path = /usr/local/bin:/usr/X11R6/bin:/usr/X11/bin # Add the following paths to the PERL5LIB environment variable. # "/sw/lib/perl5" is for Mac OS X with Fink's Perl. lib = /sw/lib/perl5 +# Add the following paths to the PYTHONPATH environment variable for +# locating Python modules. Python is used when converting OpenDocument +# files into PDF files. +python_uno_path = [print_templates] # If you have LaTeX installed set to 1 -- 2.20.1