unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#18118: Support for Python3 in TRAMP's `tramp-get-remote-uid-with-python'
@ 2014-07-27 14:32 eclig
  2014-07-28 19:11 ` Michael Albinus
  0 siblings, 1 reply; 2+ messages in thread
From: eclig @ 2014-07-27 14:32 UTC (permalink / raw)
  To: 18118

Dear Emacs maintainers,

the following patch makes possible to use TRAMP to connect to systems
where both `perl' and `id' are missing and where the Python program is
called `python3'.  Note that the syntax `print foo' is invalid in
Python3 since there `print' is a function, whereas in Python2 it is/was
a statement.  The syntax `print(foo)' works in both cases and it's what
I used bellow.

Regards

 Emílio

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: eclig@gmx.net-20140725151222-n88affhi3m98xkqr
# target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk/
# testament_sha1: cbaad612600a8166a622e1019484b64d24afeae9
# timestamp: 2014-07-25 17:17:36 +0200
# base_revision_id: eliz@gnu.org-20140725115836-axkqeojeljgzzef1
#
# Begin patch
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog    2014-07-25 09:37:07 +0000
+++ lisp/ChangeLog    2014-07-25 15:12:22 +0000
@@ -1,3 +1,11 @@
+2014-07-25  Emilio C. Lopes  <eclig@gmx.net>
+
+    * net/tramp-sh.el (tramp-get-remote-python): Also search for
+    executables named "python2" or "python3".
+    (tramp-get-remote-uid-with-python): Use parentheses around arguments to
+    `print' to make it compatible with Python 3.
+    (tramp-get-remote-gid-with-python): Ditto.
+
 2014-07-25  Glenn Morris  <rgm@gnu.org>
 
     * vc/ediff-init.el (ediff-toggle-read-only-function):

=== modified file 'lisp/net/tramp-sh.el'
--- lisp/net/tramp-sh.el    2014-07-03 09:27:02 +0000
+++ lisp/net/tramp-sh.el    2014-07-25 15:12:22 +0000
@@ -5256,7 +5256,9 @@
 (defun tramp-get-remote-python (vec)
   (with-tramp-connection-property vec "python"
     (tramp-message vec 5 "Finding a suitable `python' command")
-    (tramp-find-executable vec "python" (tramp-get-remote-path vec))))
+    (or (tramp-find-executable vec "python" (tramp-get-remote-path vec))
+        (tramp-find-executable vec "python2" (tramp-get-remote-path vec))
+        (tramp-find-executable vec "python3" (tramp-get-remote-path vec)))))
 
 (defun tramp-get-remote-uid-with-python (vec id-format)
   (tramp-send-command-and-read
@@ -5264,8 +5266,8 @@
    (format "%s -c \"%s\""
        (tramp-get-remote-python vec)
        (if (equal id-format 'integer)
-           "import os; print os.getuid()"
-         "import os, pwd; print '\\\"' + pwd.getpwuid(os.getuid())[0] + '\\\"'"))))
+           "import os; print (os.getuid())"
+         "import os, pwd; print ('\\\"' + pwd.getpwuid(os.getuid())[0] + '\\\"')"))))
 
 (defun tramp-get-remote-uid (vec id-format)
   (with-tramp-connection-property vec (format "uid-%s" id-format)
@@ -5305,8 +5307,8 @@
    (format "%s -c \"%s\""
        (tramp-get-remote-python vec)
        (if (equal id-format 'integer)
-           "import os; print os.getgid()"
-         "import os, grp; print '\\\"' + grp.getgrgid(os.getgid())[0] + '\\\"'"))))
+           "import os; print (os.getgid())"
+         "import os, grp; print ('\\\"' + grp.getgrgid(os.getgid())[0] + '\\\"')"))))
 
 (defun tramp-get-remote-gid (vec id-format)
   (with-tramp-connection-property vec (format "gid-%s" id-format)

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWfkFh8UAAqlfgGwwUP///34E
Qk7////wUAWWW8u7ptYW4C1oapoSUQJG9AmmEGjIaAk9J6gADQDQSiCYmTIKntU2NSPU0DQAAAaA
ASQgphE8gKG9KDJtQAGgDIxA0OaMmJgAmIwI0wIMRgmTAIwSKRpNoEp5T9J6A1CekyPRGEAaABkv
IKokECJoYjfp9u07V7UnMhGJDjv3lTZ6cVbdggtEra1nvrKN9HppQh9gMdcvgfFscjsOJiO4vxzm
8gzcrAzJurpVkW6mcbXMlJ6OtrTZ6Tg16eGQ0d06ZSnugtfkQ6v7zdMOUKak+llA4sLvEE5uSShK
nCKWR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ZE3JDzuwTft+NixDMyYt+k2VWIr9aRuQVIlAKN5oBg6hEDU4qLV+2B3S15QMeK9VKWqwfyNOFy
WRCgRVATHdWkTRbBbAGrFRXECfPzgUMnoXsKcNQRRck2jptCYObfvmIFLy1Bo/uo7S1bl0CrGhrs
dJSW6Oi5HEE67ETKJMGMksbNMAnZpZMmDUpIomCzjoHbUmQXZWAwwDkXENLqdukZjBEU5kSEuaM9
SUALea1Zg3ynbw1Cor4idSYUYGCjgan2S7brozlxCe82IZJdT7eWMikWnAM8dYTUIGwJ2QPSGcM/
lSmotzhbJVxTVXOkTSZZcSVViKVVuW5i9+LcSpgSEQ1u8GhTjHq7tGSXFgHfvDIJ9Ro6RWkDlJeH
kCO1IkGlbgIIvpZbw8ZJNmZSZ6E5aF/xdyRThQkPkFh8UA==






^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#18118: Support for Python3 in TRAMP's `tramp-get-remote-uid-with-python'
  2014-07-27 14:32 bug#18118: Support for Python3 in TRAMP's `tramp-get-remote-uid-with-python' eclig
@ 2014-07-28 19:11 ` Michael Albinus
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Albinus @ 2014-07-28 19:11 UTC (permalink / raw)
  To: eclig; +Cc: 18118-done

eclig@gmx.net writes:

> Dear Emacs maintainers,

Hi Emílio,

> the following patch makes possible to use TRAMP to connect to systems
> where both `perl' and `id' are missing and where the Python program is
> called `python3'.  Note that the syntax `print foo' is invalid in
> Python3 since there `print' is a function, whereas in Python2 it is/was
> a statement.  The syntax `print(foo)' works in both cases and it's what
> I used bellow.

I don't use Python. However, your patch looks reasonable to me, so I've
applied it to the trunk. Closing the bug.

> Regards
>
>  Emílio

Thanks for your report, and best regards, Michael.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-28 19:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-27 14:32 bug#18118: Support for Python3 in TRAMP's `tramp-get-remote-uid-with-python' eclig
2014-07-28 19:11 ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).