Control: tag -1 patch

Andrei POPESCU <andreimpope...@gmail.com> (2012-02-16):
> I'm trying to use editmoin with a ~/.moin_users that looks like this:
> 
> http://AndreiPopescu:<my_password>@wiki.debian.org
> 
> but I get:
> 
> $ editmoin debian/DebianWebsiteSubmissions
> error: body information not found
> 
> If I append the user name I can edit pages, but I'm asked for the 
> password:
> 
> ~/.moin_users:
> http://AndreiPopescu:<my_password>@wiki.debian.org AndreiPopescu
> 
> $ editmoin wiki.debian.org/DebianWebsiteSubmissions
> Password for AndreiPopescu:

Hoping that people aren't using ':' in their usernames too much, I've
patched editmoin to support using this in ~/.moin_users (keep it 600!):

  http://wiki.debian.org MyLogin:MyPassword

The patch tweaks get_session_cookie to detect a password after a
semi-colon, adjusting user and skipping password prompt in that case.
Fetching a page and submitting an update worked fine.

The two print lines could probably disappear.

Mraw,
KiBi.
commit 1af9bb170e86c2d85b559f7f636f04a93381288c
Author: Cyril Brulebois <k...@debian.org>
Date:   Mon Nov 11 04:17:01 2013 +0100

    Add support for user:password in ~/.moin_users

diff --git a/editmoin b/editmoin
index 262c825..437cc97 100755
--- a/editmoin
+++ b/editmoin
@@ -433,7 +433,15 @@ def sendcancel(urlopener, url, moinfile):
         print message
 
 def get_session_cookie(user, url):
-    password = getpass.getpass("Password for %s: " % user)
+    # Support user:password, adjusting as needed
+    password = None
+    if user.find(':') != -1:
+        password = user[user.find(':')+1:]
+        user = user[:user.find(':')]
+        print 'user: ', user
+        print 'pass: ', password
+    else:
+        password = getpass.getpass("Password for %s: " % user)
     params = urllib.urlencode(dict(login='Login', action='login',
                                    name=user, password=password))
     opener = get_urlopener(url)

Attachment: signature.asc
Description: Digital signature

Reply via email to