GNU bug report logs - #18118
Support for Python3 in TRAMP's `tramp-get-remote-uid-with-python'

Previous Next

Package: emacs;

Reported by: eclig <at> gmx.net

Date: Sun, 27 Jul 2014 14:29:02 UTC

Severity: normal

Tags: patch

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18118 in the body.
You can then email your comments to 18118 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18118; Package emacs. (Sun, 27 Jul 2014 14:29:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to eclig <at> gmx.net:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 27 Jul 2014 14:29:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: eclig <at> gmx.net
To: bug-gnu-emacs <at> gnu.org
Subject: 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: eclig <at> 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 <at> 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 <at> 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 <at> 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-rem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0nIua/FUfvDqHPx95CXqEYeK6LbSsG3+ZitzuMII6zbsPgB2BqIqJxop+jwdn
VPicaDYeGu01FjgtlfMeoCbchxp38qVACcxdy5ujApO883k1hSufALBgyngTcY01l7gkW4Biprz6
unpm52Z5TlwnekET5xqIubYBPJh0ouvH4oQgCVsUCPxhtksuUPWUNJZO0JtyTTJdIXEddcx24Yut
pxOBRjmYNhmGI40YCuJ0wn8j1hHO4J75QmwfZBkXbZcFmEO5kfk0yLzWYiSK1Q0PYtRfPl0YJmrD
XjKkEiTEwUaOq8caIcC3LSmeDcwarT0DSqHT3KAee9YgMnA3nmOovWEFmOCwCQiqhoZkS3i3FIbs
SUWkcqjFlmHdd8MCHE3zY4pzAZIwSZiBmNdk49tmPWMbefwQ8mtcRyiMoqjGg6QwIF1RRMj44rao
HGZE3JDzuwTft+NixDMyYt+k2VWIr9aRuQVIlAKN5oBg6hEDU4qLV+2B3S15QMeK9VKWqwfyNOFy
WRCgRVATHdWkTRbBbAGrFRXECfPzgUMnoXsKcNQRRck2jptCYObfvmIFLy1Bo/uo7S1bl0CrGhrs
dJSW6Oi5HEE67ETKJMGMksbNMAnZpZMmDUpIomCzjoHbUmQXZWAwwDkXENLqdukZjBEU5kSEuaM9
SUALea1Zg3ynbw1Cor4idSYUYGCjgan2S7brozlxCe82IZJdT7eWMikWnAM8dYTUIGwJ2QPSGcM/
lSmotzhbJVxTVXOkTSZZcSVViKVVuW5i9+LcSpgSEQ1u8GhTjHq7tGSXFgHfvDIJ9Ro6RWkDlJeH
kCO1IkGlbgIIvpZbw8ZJNmZSZ6E5aF/xdyRThQkPkFh8UA==





Reply sent to Michael Albinus <michael.albinus <at> gmx.de>:
You have taken responsibility. (Mon, 28 Jul 2014 19:12:02 GMT) Full text and rfc822 format available.

Notification sent to eclig <at> gmx.net:
bug acknowledged by developer. (Mon, 28 Jul 2014 19:12:03 GMT) Full text and rfc822 format available.

Message #10 received at 18118-done <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: eclig <at> gmx.net
Cc: 18118-done <at> debbugs.gnu.org
Subject: Re: bug#18118: Support for Python3 in TRAMP's
 `tramp-get-remote-uid-with-python'
Date: Mon, 28 Jul 2014 21:11:36 +0200
eclig <at> 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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 26 Aug 2014 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 271 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.