Opened 13 years ago

Last modified 13 years ago

#298 closed defect (FIXED)

./bin/gmg adduser should take password, email as arguments, and prompt if not provided

Reported by: Christopher Allan Webber Owned by: Manolinux aka Mu
Priority: minor Milestone: 0.2.0
Component: programming Keywords:
Cc: Parent Tickets:

Description

Instead of being sequential arguments, email and password (or at
least password) should be --keyword arguments. If not provided, we
should prompt the user for them (and obscure the password as being
entered).

This is a fairly easy and entry level task.



Change History (5)

comment:1 by Manolinux aka Mu, 13 years ago

Owner: set to Manolinux aka Mu
Status: NewIn Progress
I pick this one, if you don't mind.

It was indeed, very instructive. I am also enabling short options,
like that:

::

    optional arguments:
      -h, --help            show this help message and exit
      --username USERNAME, -u USERNAME
                            Username used to login
      --password PASSWORD, -p PASSWORD
                            Your supersecret word to login, beware: it could be
                            stored in your bash history
      --email EMAIL, -e EMAIL
                            Email to recieve notifications

since writing full options is quite tedious.



comment:2 by Manolinux aka Mu, 13 years ago

Status: In ProgressFeedback
Done.

Repo:
[https://gitorious.org/\ :sub:`manolinux/mediagoblin/manolinuxs-mediagoblin](https://gitorious.org/`\ manolinux/mediagoblin/manolinuxs-mediagoblin)
Branch: 645\_gmg\_adduser\_prompt

Notes:


-  I created a function in ``utils.py`` '``prompt_if_not_set``' (I
   don't know if it would be the correct location).
-  I used ``raw_input`` for clear text and ``getpass.getpass`` for
   passwords.
-  Maybe, I could make more checks on input (empty username,
   lengths, and so).



comment:3 by Christopher Allan Webber, 13 years ago

Status: FeedbackClosed
Merged! Thanks so much :)

BTW, I made a few adjustments:
`https://gitorious.org/mediagoblin/mediagoblin/commit/bbac7663f4b05430592ac5d39f056029dc11db92 <https://gitorious.org/mediagoblin/mediagoblin/commit/bbac7663f4b05430592ac5d39f056029dc11db92>`_

FYI for in the future:


-  It would be helpful to make your code compliant to PEP-8. It
   really helps keep code consistent and thus more readable:
   `http://www.python.org/dev/peps/pep-0008/ <http://www.python.org/dev/peps/pep-0008/>`_
-  Also, not a big deal, but I saw you did None.. I generally find
   that if you're doing a comparison to None rather than to False,
   maybe you mean "is None"... "is None" will make sure it's None, "
   None" is the same basically as "== False" iirc. Could be wrong
   though.
-  Lastly, if you do string operations, best to do stuff like

   foo + u"bleh"


instead of

::

    foo + "bleh" 

This just helps us avoid some unicode decoding issues :)

Thanks much! Great work :)



comment:4 by Manolinux aka Mu, 13 years ago

Great, thanks.

I'm new to python, so I will take your advices in much
consideration :)



comment:5 by Will Kahn-Greene, 13 years ago

The original url for this bug was http://bugs.foocorp.net/issues/645 .

Note: See TracTickets for help on using tickets.