I have an issue when using python-mode remotely through tramp. I'm trying to use the repl and pass a test function
using C-c C-c
, however this seems to create a local file at my own computer or remotely using a c:
prefix instead of usr/
Alongside this the terminal that I create with run-python seems to create a bunch of gibberish (as can be visible below) although it does run. if I test it directly (not by sending C-c C-c
)
I would appreciate any ideas in order to fix this.
Sent: def test():...
Tramp: Encoding local file ‘c:/Users//Local/Temp/tramp.12516UhC’ using ‘base64-encode-region’...done
Tramp: Decoding remote file ‘/plink:.net:/tmp/py12516iXz’ using ‘base64 -d -i >%s’...done
Tramp: Encoding local file ‘c:/Users//Temp/tramp.12516hrI’ using ‘base64-encode-region’...done
Tramp: Decoding remote file ‘/plink::/tmp/py12516iXz’ using ‘base64 -d -i >%s’...done
Tramp: Inserting ‘/plink:.net:/tmp/py12516iXz’...
Tramp: Encoding remote file ‘/plink:.net:/tmp/py12516iXz’ with ‘base64 <%s’...done
Tramp: Decoding local file ‘c://Temp/tramp.12516u1O’ with ‘base64-decode-region’...done
Tramp: Inserting ‘/plink:.net:/tmp/py12516iXz’...done
error in process filter: ansi-color-filter-apply: Args out of range: "[0;38;5;28;1mimport[0m [0;38;5;32;1mcodecs[0m,[0m [0;38;5;32;1mos[0m;[0m__pyfile[0m [0m=[0m [0mcodecs[0m.[0mopen[0m([0;38;5;130m'''c:/tmp/py12516iXz'''[0m,[0m [0mencod
[79Ci[0m
[0;38;5;28m ...: [0mng[0m=[0;38;5;130m'''utf-8'''[0m);[0m__code[0m [0m=[0m [0m__pyfile[0m.[0mread[0m()[0m.[0mencode[0m([0;38;5;130m'''utf-8'''[0m);[0m__pyfile[0m.[0mc
[79Cl[0m
[0;38;5;28m ...: [0mose[0m();[0mos[0m.[0mremove[0m([0;38;5;130m'''c:/tmp/py12516iXz'''[0m);[0mexec[0m([0;38;5;28mcompile[0m([0m__code[0m,[0m [0;38;5;130m'''c:/hom
[79Ce[0m
[0;38;5;28m ...: [0;38;5;130m/_Recorder/test.py'''[0m,[0m [0;38;5;130m'exec'[0m));[69D[69C[0m[3A[69D[0m[J[0;38;5;28mIn [[0;38;5;10;1m1[0;38;5;28m]: [0;38;5;28;1mimport[0m [0;38;5;32;1mcodecs[0m,[0m [0;38;5;32;1mos[0m;[0m__pyfile[0m [0m=[0m [0mcodecs[0m.[0mopen[0m([0;38;5;130m'''c:/tmp/py12516iXz'''[0m,[0m [0mencod
[79Ci[0m
[0;38;5;28m ...: [0mng[0m=[0;38;5;130m'''utf-8'''[0m);[0m__code[0m [0m=[0m [0m__pyfile[0m.[0mread[0m()[0m.[0mencode[0m([0;38;5;130m'''utf-8'''[0m);[0m__pyfile[0m.[0mc
[79Cl[0m
[0;38;5;28m ...: [0mose[0m();[0mos[0m.[0mremove[0m([0;38;5;130m'''c:/tmp/py12516iXz'''[0m);[0mexec[0m([0;38;5;28mcompile[0m([0m__code[0m,[0m [0;38;5;130m'''c:/hom
[79Ce[0m
[0;38;5;28m ...: [0;38;5;130m/_Recorder/test.py'''[0m,[0m [0;38;5;130m'exec'[0m));[69D[0m
[J[0m", 1551
error in process filter: Args out of range: "[0;38;5;28;1mimport[0m [0;38;5;32;1mcodecs[0m,[0m [0;38;5;32;1mos[0m;[0m__pyfile[0m [0m=[0m [0mcodecs[0m.[0mopen[0m([0;38;5;130m'''c:/tmp/py12516iXz'''[0m,[0m [0mencod
[79Ci[0m
[0;38;5;28m ...: [0mng[0m=[0;38;5;130m'''utf-8'''[0m);[0m__code[0m [0m=[0m [0m__pyfile[0m.[0mread[0m()[0m.[0mencode[0m([0;38;5;130m'''utf-8'''[0m);[0m__pyfile[0m.[0mc
[79Cl[0m
[0;38;5;28m ...: [0mose[0m();[0mos[0m.[0mremove[0m([0;38;5;130m'''c:/tmp/py12516iXz'''[0m);[0mexec[0m([0;38;5;28mcompile[0m([0m__code[0m,[0m [0;38;5;130m'''c:/hom
[79Ce[0m
[0;38;5;28m ...: [0;38;5;130m/_Recorder/test.py'''[0m,[0m [0;38;5;130m'exec'[0m));[69D[69C[0m[3A[69D[0m[J[0;38;5;28mIn [[0;38;5;10;1m1[0;38;5;28m]: [0;38;5;28;1mimport[0m [0;38;5;32;1mcodecs[0m,[0m [0;38;5;32;1mos[0m;[0m__pyfile[0m [0m=[0m [0mcodecs[0m.[0mopen[0m([0;38;5;130m'''c:/tmp/py12516iXz'''[0m,[0m [0mencod
[79Ci[0m
[0;38;5;28m ...: [0mng[0m=[0;38;5;130m'''utf-8'''[0m);[0m__code[0m [0m=[0m [0m__pyfile[0m.[0mread[0m()[0m.[0mencode[0m([0;38;5;130m'''utf-8'''[0m);[0m__pyfile[0m.[0mc
[79Cl[0m
[0;38;5;28m ...: [0mose[0m();[0mos[0m.[0mremove[0m([0;38;5;130m'''c:/tmp/py12516iXz'''[0m);[0mexec[0m([0;38;5;28mcompile[0m([0m__code[0m,[0m [0;38;5;130m'''c:/hom
[79Ce[0m
[0;38;5;28m ...: [0;38;5;130m//test.py'''[0m,[0m [0;38;5;130m'exec'[0m));[69D[0m
[J[0m", 1551
error in process filter: ansi-color-filter-apply: Args out of range: "[0;31m---------------------------------------------------------------------------[0m
[0;31mFileNotFoundError[0m Traceback (most recent call last)
[0;32m<ipython-input-1-05c5f2e548bf>[0m in [0;36m<module>[0;34m()[0m
[0;32m----> 1[0;31m [0;32mimport[0m [0mcodecs[0m[0;34m,[0m [0mos[0m[0;34m;[0m[0m__pyfile[0m [0;34m=[0m [0mcodecs[0m[0;34m.[0m[0mopen[0m[0;34m([0m[0;34m'''c:/tmp/py12516iXz'''[0m[0;34m,[0m [0mencoding[0m[0;34m=[0m[0;34m'''utf-8'''[0m[0;34m)[0m[0;34m;[0m[0m__code[0m [0;34m=[0m [0m__pyfile[0m[0;34m.[0m[0mread[0m[0;34m([0m[0;34m)[0m[0;34m.[0m[0mencode[0m[0;34m([0m[0;34m'''utf-8'''[0m[0;34m)[0m[0;34m;[0m[0m__pyfile[0m[0;34m.[0m[0mclose[0m[0;34m([0m[0;34m)[0m[0;34m;[0m[0mos[0m[0;34m.[0m[0mremove[0m[0;34m([0m[0;34m'''c:/tmp/py12516iXz'''[0m[0;34m)[0m[0;34m;[0m[0mexec[0m[0;34m([0m[0mcompile[0m[0;34m([0m[0m__code[0m[0;34m,[0m [0;34m'''c:/home//Cerberus_Recorder/test.py'''[0m[0;34m,[0m [0;34m'exec'[0m[0;34m)[0m[0;34m)[0m[0;34m;[0m[0;34m[0m[0m
[0m
[0;32m/usr/lib/python3.4/codecs.py[0m in [0;36mopen[0;34m(filename, mode, encoding, errors, buffering)[0m
[1;32m 894[0m [0;31m# Force opening of the file in binary mode[0m[0;34m[0m[0;34m[0m[0m
[1;32m 895[0m [0mmode[0m [0;34m=[0m [0mmode[0m [0;34m+[0m [0;34m'b'[0m[0;34m[0m[0m
[0;32m--> 896[0;31m [0mfile[0m [0;34m=[0m [0mbuiltins[0m[0;34m.[0m[0mopen[0m[0;34m([0m[0mfilename[0m[0;34m,[0m [0mmode[0m[0;34m,[0m [0mbuffering[0m[0;34m)[0m[0;34m[0m[0m
[0m[1;32m 897[0m [0;32mif[0m [0mencoding[0m [0;32mis[0m [0;32mNone[0m[0;34m:[0m[0;34m[0m[0m
[1;32m 898[0m [0;32mreturn[0m [0mfile[0m[0;34m[0m[0m
I have also attempted using this defun:
(defun python-send-region (start end)
"Send the region to the inferior Python process."
(interactive "r")
(let* ((loc_name)
(f (if (file-remote-p default-directory)
(let* ((con (tramp-dissect-file-name default-directory)))
(setq loc_name (tramp-make-tramp-temp-file con))
(concat "/"
(tramp-file-name-method con) ":"
(tramp-file-name-user con) "@"
(tramp-file-name-host con) ":"
loc_name
))
(setq loc_name (make-temp-file "py"))))
(command (format "emacs.eexecfile(%S)" loc_name))
(orig-start (copy-marker start)))
(save-excursion
(let ((curbuf (current-buffer))
(tempbuf (get-buffer-create "*python_temp*")))
(set-buffer tempbuf)
(delete-region (point-min) (point-max))
(insert-buffer-substring curbuf start end)
(python-mode)
(when (save-excursion
(goto-char (point-min))
(/= 0 (current-indentation)))
(python-shift-left (point-min) (point-max)))
(write-region nil nil f nil 'nomsg))
(python-send-command command)
(with-current-buffer (process-buffer (python-proc))
;; Tell compile.el to redirect error locations in file `f' to
;; positions past marker `orig-start'. It has to be done *after*
;; `python-send-command''s call to `compilation-forget-errors'.
(compilation-fake-loc orig-start f)))))