[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with call-process (= identifying run-python issues)

From: Juan José García-Ripoll
Subject: Problems with call-process (= identifying run-python issues)
Date: Tue, 18 Aug 2020 15:36:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (windows-nt)


I am running into a weird issue in Windows 10, both with Emacs 27 and
Emacs 26.3. It all boils down to whether Emacs is invoked from the
command line or not. In one case, subprocesses get their input properly
redirected, in other cases not. All tests are done with plain vanilla
Emacs, using core libraries (no programming mode).

My test files are below. Essentially, the file test.el is trying to
imitate what python.el uses to call a python process, but instead of
that, it uses a simple copycat script that copies the input stream to
the output stream.

- If I launch the program from the command line, as in
      C:\Users\juanj\scoop\apps\emacs-27.1\bin\runemacs.exe -Q --load 
  everything goes fine. In the *Messages* buffer I see this output
\"import sys
ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]
ps_json = '\\\\\\\\n[\\\\\\\"%s\\\\\\\", \\\\\\\"%s\\\\\\\", 
\\\\\\\"%s\\\\\\\"]\\\\\\\\n' % tuple(ps)
print (ps_json)

- If I create a shortcut for runemacs, adding "-Q --load test.el" as
  arguments, then process-file outputs nothing. The *Messages* buffer

- If I type #+R (Windows key + R) and enter directly the command line
"C:\Users\juanj\scoop\apps\emacs-27.1\bin\runemacs -Q --load
c:\Users\juanj\Downloads\test.el" the script also fails and produces the
wrong output.

There are no error messages. The script gets invoked (you may add a line
"echo foo" to chain.cmd and see that it is output), but it does not
get the redirected input.

---foo---(test file 1, saved as c:\Users\juanj\Downloads\foo)
import sys
ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]
ps_json = '\\n[\"%s\", \"%s\", \"%s\"]\\n' % tuple(ps)
print (ps_json)

--test.el---(test file 2, saved as c:\Users\juanj\Downloads\test.el)
(with-current-buffer "*Messages*"
    (call-process "c:/Users/juanj/Downloads/chain.cmd" ;conda_python.cmd"
                  '(t nil) nil "-i")
    (print (format "Output:\n%S" (buffer-string)))

---chain.cmd---(test file 2, saved as c:\Users\juanj\Downloads\chain.cmd)
@echo off
rem copies lines from the input until it is empty
set /p line= || goto :end
echo %line%
goto :begin

Juan José García Ripoll

reply via email to

[Prev in Thread] Current Thread [Next in Thread]