bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#18118: Support for Python3 in TRAMP's `tramp-get-remote-uid-with-pyt


From: eclig
Subject: bug#18118: Support for Python3 in TRAMP's `tramp-get-remote-uid-with-python'
Date: Sun, 27 Jul 2014 16:32:31 +0200

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: address@hidden
# target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk/
# testament_sha1: cbaad612600a8166a622e1019484b64d24afeae9
# timestamp: 2014-07-25 17:17:36 +0200
# base_revision_id: address@hidden
#
# 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  <address@hidden>
+
+    * 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  <address@hidden>
 
     * 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
nCKWRegyvm0Z3s7Pvr2xaaSKL5A4h8QhYLicxpchhUaGGTwIAxB8HBt9Rw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