Opened 10 years ago
Last modified 9 years ago
#969 closed defect
gmg user commands don't fail gracefully for non existant users — at Version 4
Reported by: | ayleph | Owned by: | |
---|---|---|---|
Priority: | trivial | Milestone: | 0.9.0 |
Component: | programming | Keywords: | gmg, delete, user, deleteuser |
Cc: | berkerpeksag | Parent Tickets: |
Description (last modified by )
Attempt to delete a non-existent user using bin/gmg deleteuser
and you'll get a Traceback similar to below.
$ bin/gmg deleteuser idontexist Traceback (most recent call last): File "bin/gmg", line 9, in <module> load_entry_point('mediagoblin==0.7.1.dev', 'console_scripts', 'gmg')() File "/path/to/mediagoblin/mediagoblin/gmg_commands/__init__.py", line 124, in main_cli args.func(args) File "/path/to/mediagoblin/mediagoblin/gmg_commands/users.py", line 132, in deleteuser username=unicode(args.username.lower())).one() File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/query.py", line 2329, in one sqlalchemy.orm.exc.NoResultFound: No row was found for one()
Same problem exists for other commands in users.py.
Change History (4)
comment:1 by , 10 years ago
Owner: | set to |
---|---|
Status: | new → in_progress |
comment:2 by , 10 years ago
Owner: | removed |
---|---|
Status: | in_progress → review |
comment:3 by , 10 years ago
Milestone: | → 0.8.0 |
---|---|
Resolution: | → fixed |
Status: | review → closed |
comment:4 by , 10 years ago
Description: | modified (diff) |
---|---|
Resolution: | fixed |
Status: | closed → accepted |
Summary: | gmg deleteuser doesn't fail gracefully → gmg user commands don't fail gracefully for non existant users |
We just realized, that users.py is affected globally.
Notes:
- Wait until py3 merge is over!
- Instead of doing
unicode(...)
(orsix.text_type
) in the db query, try doing atype=six.text_type
in the.add_argument
of the parser setup, so that the parser already does the typing for us.
Note:
See TracTickets
for help on using tickets.
Elrond suggested the following change, which tested out fine for existing and non-existing users on my system.
mediagoblin/gmg_commands/users.py: