#7423 closed New feature (fixed)
syncdb fails to read in password in eclipse when creating database
| Reported by: | Owned by: | AeroNotix | |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | dev |
| Severity: | Normal | Keywords: | post10 |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
(Version 0.97pre)
When I run manage.py syncdb to create a new database within eclipse, it fails when it tries to read in a password. Here is the output:
Creating table auth_message
Creating table auth_group
Creating table auth_user
Creating table auth_permission
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table lostitems_lostitem
Creating table django_admin_log
Creating table registration_registrationprofile
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'foo'): admin
E-mail address: foo@bar.baz
Traceback (most recent call last):
File "/workspace/laf/laf/manage.py", line 11, in <module>
execute_manager(settings)
File "/workspace/laf/django/core/management/__init__.py", line 272, in execute_manager
utility.execute()
File "/workspace/laf/django/core/management/__init__.py", line 219, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/workspace/laf/django/core/management/base.py", line 72, in run_from_argv
self.execute(*args, **options.__dict__)
File "/workspace/laf/django/core/management/base.py", line 86, in execute
output = self.handle(*args, **options)
File "/workspace/laf/django/core/management/base.py", line 168, in handle
return self.handle_noargs(**options)
File "/workspace/laf/django/core/management/commands/syncdb.py", line 97, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive)
File "//workspace/laf/django/core/management/sql.py", line 491, in emit_post_sync_signal
verbosity=verbosity, interactive=interactive)
File "/workspace/laf/django/dispatch/dispatcher.py", line 360, in send
**named
File "/workspace/laf/django/dispatch/robustapply.py", line 47, in robustApply
return receiver(*arguments, **named)
File "/workspace/laf/django/contrib/auth/management.py", line 45, in create_superuser
do_create()
File "/workspace/laf/django/contrib/auth/create_superuser.py", line 73, in createsuperuser
password = getpass.getpass()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/getpass.py", line 32, in unix_getpass
old = termios.tcgetattr(fd) # a copy to save
termios.error: (25, 'Inappropriate ioctl for device')
After I researched this problem, i found that it is because the input stream is not tty in eclipse, which the getpass() call is expecting. An easy workaround is to just read from stdin if it is not a tty stream.
This will look something like:
if os.isatty(sys.stdin.fileno()):
p = getpass.getpass('')
else:
print 'Password: '
p = sys.stdin.readline().rstrip()
However, this will cause the password to be echoed as the user is typing it in. The patch is fairly quick, and I can provide one if this is the way you want to go.
Change History (10)
comment:1 by , 18 years ago
| Component: | Uncategorized → django-admin.py |
|---|---|
| Keywords: | feature added |
| Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 18 years ago
| Keywords: | post10 added; feature removed |
|---|
But would allow people to script syncdb :))
Anyway, could you provide a patch (as yes, it's the way to go).
And then bring this to django-developers as having the password echoed is not something than can be accepted without a bit deliberation :) (*after* 1.0 if you don't mind).
comment:3 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → New feature |
comment:4 by , 14 years ago
| Easy pickings: | unset |
|---|---|
| Triage Stage: | Design decision needed → Accepted |
| UI/UX: | unset |
Discussion with carl: marking as accepted, because it should be possible to use syncdb on a non-tty. however printing passwords on screen is not acceptable, a more appropriate behavior would be to skip user creation entirely, and give them a pointer to the createsuperuser command.
comment:5 by , 12 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:7 by , 12 years ago
| Has patch: | set |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
comment:8 by , 12 years ago
| Triage Stage: | Ready for checkin → Accepted |
|---|
The "ready for checkin" flag is for when someone else has reviewed your patch and deemed it ready.
comment:9 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
comment:10 by , 12 years ago
For reference, this commit makes two tests fail when you run the test suite this way (caught by our CI server):
./runtests.py django.contrib.auth < /dev/null
I'm looking into it.
I vote +0 on this one