Invoke not right worked

84 views
Skip to first unread message

setivo...@gmail.com

unread,
Feb 21, 2016, 3:25:24 PM2/21/16
to Django users

my file with invoke-task (tasks.py)
.........................................................
from invoke import run, task

separeted_line = eval('\'*\'*50')
sample = "\n{0}\n*** Finished: {1} ***\n{0}\n"


@task
def run_stadalone_configure():
    command = './manage.py collectstatic --noinput'
    print(sample.format(separeted_line, command.upper()))
    run(command)
    command = './manage.py compilemessages'
    run(command)
    print(sample.format(separeted_line, command.upper()))
    command = './manage.py migrate'
    run(command)
    print(sample.format(separeted_line, command.upper()))
    # command = './manage.py createsuperuser --username=wlysenko --email=setivo...@gmail.com'
    # run(command)
    # print(sample.format(separeted_line, command.upper()))

RESULT command: invoke run_stadalone_configure
----------------------------------------------------
(heroku_project_brat) wlysenko@wlysenko-Aspire ~/.virtualenvs/heroku_project_brat/project_brat $ invoke run_stadalone_configure

**************************************************
*** Finished: ./MANAGE.PY COLLECTSTATIC --NOINPUT ***
**************************************************


0 static files copied to '/home/wlysenko/.virtualenvs/heroku_project_brat/project_brat/staticfiles', 251 unmodified.
processing file django.po in /home/wlysenko/.virtualenvs/heroku_project_brat/project_brat/locale/ru/LC_MESSAGES
processing file django.po in /home/wlysenko/.virtualenvs/heroku_project_brat/project_brat/apps/app_files/locale/ru/LC_MESSAGES
processing file django.po in /home/wlysenko/.virtualenvs/heroku_project_brat/project_brat/apps/app_contact_me/locale/ru/LC_MESSAGES

**************************************************
*** Finished: ./MANAGE.PY COMPILEMESSAGES ***
**************************************************

Operations to perform:
  Apply all migrations: contenttypes, auth, app_files, sites, admin, sessions
Running migrations:
  No migrations to apply.

**************************************************
*** Finished: ./MANAGE.PY MIGRATE ***
**************************************************

Superuser creation skipped due to not running in a TTY. You can run `manage.py createsuperuser` in your project to create one manually.
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 52, in execute
    return super(Command, self).execute(*args, **options)
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 173, in handle
    self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
TypeError: create_superuser() missing 1 required positional argument: 'email'

James Schneider

unread,
Feb 21, 2016, 3:55:35 PM2/21/16
to django...@googlegroups.com
On Sun, Feb 21, 2016 at 12:25 PM, <setivo...@gmail.com> wrote:

my file with invoke-task (tasks.py)
.........................................................
from invoke import run, task

separeted_line = eval('\'*\'*50')
sample = "\n{0}\n*** Finished: {1} ***\n{0}\n"


@task
def run_stadalone_configure():
    command = './manage.py collectstatic --noinput'
    print(sample.format(separeted_line, command.upper()))
    run(command)
    command = './manage.py compilemessages'
    run(command)
    print(sample.format(separeted_line, command.upper()))
    command = './manage.py migrate'
    run(command)
    print(sample.format(separeted_line, command.upper()))
    # command = './manage.py createsuperuser --username=wlysenko --email=setivo...@gmail.com'
    # run(command)
    # print(sample.format(separeted_line, command.upper()))


I'm not familiar with Heroku specifically, perhaps they support doing this, but you should probably run your Django management commands using the guide here rather than trying to coerce command line arguments (which can lead to shell escaping issues, and might be what is causing the error below).


 
Superuser creation skipped due to not running in a TTY. You can run `manage.py createsuperuser` in your project to create one manually.
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 52, in execute
    return super(Command, self).execute(*args, **options)
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/home/wlysenko/.virtualenvs/heroku_project_brat/lib/python3.4/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 173, in handle
    self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
TypeError: create_superuser() missing 1 required positional argument: 'email'

I suspect a shell escape issue here with the @ symbol in the email, but it would be hard to tell. You'd be better off rewriting your management commands per the link I sent so that the escaping is handled correctly. 

On a side note, creating a superuser this way is probably not ideal. Even if it did succeed, the superuser wouldn't have a password and you'd have to give it one manually anyway.


In cases like this where the initial user is being created via a script, I import the Django environment and use the ORM to create the user manually (with a password) and set is_super = True. 

-James

Seti Volkylany

unread,
Feb 22, 2016, 8:40:47 AM2/22/16
to django...@googlegroups.com

Almost all worked 

http://eugenelysenko.pythonanywhere.com/

Thank you very much

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/IYBFDy1Tiaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciW%3DMK9Ea-B97SGYqg8GpoDo1g2ievfj9poX26%3D2CyfnOA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages