def remote(host='192.168.1.11', port=8000): """Run remove server.""" ifconfig = subprocess.check_output('ifconfig') if host not in ifconfig.decode('utf-8'): return print_msg(f'Host {host} not in "ifconfig"', error=True) return manage(f'runserver {host}:{port}')
def resetdb(): """Reset database to initial state.""" print_msg('Remove "scr/media" folder') local('rm -rf media/') print_msg('Reset database') manage('reset_db -c --noinput') migrate() createsuperuser() print_msg('Populate database?') answer = prompt('\n', default='yes') if answer.lower() in ('y', 'yes', 1): populate_db()
def populate_db(): """Populate database with dummy data.""" print_msg('Start populating DB') manage('populate_db')
def pep8(path='apps core'): """Check PEP8 errors.""" print_msg('Checking PEP8 errors') return local('flake8 --config=.flake8 {}'.format(path))
def isort(): """Fix imports formatting.""" print_msg('Running imports fix') local('isort apps core config')
def createsuperuser(email='*****@*****.**'): """Create superuser with default credentials.""" print_msg('Creating superuser') return manage('createsuperuser --username root --email {}'.format(email))
def migrate(): """Apply migrations to database.""" print_msg('Applying migrations') manage('migrate')