Python-Interpreter und -Modulpfad über Konfigurationsoptionen in kivitendo.conf konfi...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 14 Dec 2012 14:07:37 +0000 (15:07 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 14 Dec 2012 14:07:37 +0000 (15:07 +0100)
Behebt #671.

SL/Template/OpenDocument.pm
config/kivitendo.conf.default

index b4ea1f2..e0523d3 100644 (file)
@@ -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/;
index 7d83d6c..1391239 100644 (file)
@@ -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