On 08Feb2017 18:56, Andreas Paeffgen <oege...@gmail.com> wrote:
The Problem with the subprocess code is: Using the sourcecode functioning as normal.
The frozen app with cx_freeze on every platform just returns an empty result

I don't know what the sentence above above cx_freeze means.

Here is the code in short:
def get_path_pandoc():
  settings = QSettings('Pandoc', 'PanConvert')
  path_pandoc = settings.value('path_pandoc','')
  if not os.path.isfile(path_pandoc):
      if platform.system() == 'Darwin' or os.name == 'posix':
          args = ['which', 'pandoc']
          p = subprocess.Popen(
              args,
              stdin=subprocess.PIPE,

"which" doesn't read any input. You probably want "subprocess.DEVNULL" instead of "subprocess.PIPE" for stdin.

              stdout=subprocess.PIPE)
path_pandoc = str.rstrip(p.communicate(path_pandoc.encode('utf-8'))[0].decode('utf-8'))

The whole problematic code can be checked on http://github.com/apaeffgen/panconvert
in source/converters/interface_pandoc.py

I debugged it with some QMessage-Boxes. I just know, that the returnd result is empty.
I tried some stderr on this code also. But also the error message is empty.

What does "which pandoc" say to you at a terminal prompt? The code above relies on that returning you the path to the pandoc executable. If it is not in your path then you will get an empty result.

Also, the "which" programme should have a zero exit status if it finds and prints the path to pandoc, and a nonzero exit status otherwise? Find out what exit status it returns. This is available from the "p" object after communicate() returns. See the subprocess doco for details. The easy thing to do is probably to call "p.check_returncode()" after communicate() returns.

Any hints what could be changed in the code, so it also works in the frozen app?

What's a frozen app?

Maybe that is your problem: when you run the programme by hand it works, but in this "forzen" state it doesn't.

The "which" command isn't magic. It searchs for commands by looking for executables in the directories listed in the $PATH environment variable. Get your program to print or display the value of "os.environ['PATH']" before invoking "which". The difference may tell you something useful.

At the moment i use python3.4 to 3.5 depending on the platform (Mac, Win, Linux)

Thank you for this information; many people forget to supply it.

P.S. Tried also some code with invoking the bash and afterwords the which pandoc code. To know avail also

From a shell prompt (such as bash's prompt) issuing the command:

 which pandoc

should print the executable path, _if_ your $PATH includes the right directory. You can look at $PATH from the shell with the command:

 echo $PATH

Do you know where pandoc normally resides on your system?

Cheers,
Cameron Simpson <c...@zip.com.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to