Add basic win32 support for dev bootstrap
This commit is contained in:
parent
4980e5784b
commit
f6cf02bcaf
4 changed files with 73 additions and 21 deletions
54
dev/tasks.py
54
dev/tasks.py
|
@ -47,7 +47,10 @@ def bootstrap(c):
|
|||
print("start your development web app with this command:")
|
||||
print()
|
||||
print(" cd {}".format(envdir))
|
||||
print(" bin/pserve --reload file+ini:app/web.conf")
|
||||
if sys.platform == 'win32':
|
||||
print(r" Scripts\pserve --reload file+ini:app\web.conf")
|
||||
else:
|
||||
print(" bin/pserve --reload file+ini:app/web.conf")
|
||||
print()
|
||||
print("then check out your development web app at:")
|
||||
print()
|
||||
|
@ -100,7 +103,10 @@ def upgrade_pip(c):
|
|||
"""
|
||||
Upgrade pip and friends
|
||||
"""
|
||||
c.run('pip install -U pip')
|
||||
if sys.platform == 'win32':
|
||||
c.run('python -m pip install -U pip')
|
||||
else:
|
||||
c.run('pip install -U pip')
|
||||
c.run('pip install -U setuptools wheel')
|
||||
|
||||
|
||||
|
@ -119,7 +125,13 @@ def make_appdir(c, envdir):
|
|||
"""
|
||||
appdir = os.path.join(envdir, 'app')
|
||||
if not os.path.exists(appdir):
|
||||
c.run('{} make-appdir'.format(os.path.join(envdir, 'bin', 'rattail')))
|
||||
if sys.platform == 'win32':
|
||||
c.run('{} make-appdir --path {}'.format(
|
||||
os.path.join(envdir, 'Scripts', 'rattail'),
|
||||
appdir))
|
||||
else:
|
||||
c.run('{}/bin/rattail make-appdir --path {}'.format(
|
||||
envdir, appdir))
|
||||
return appdir
|
||||
|
||||
|
||||
|
@ -132,6 +144,7 @@ def make_configs(c, envdir, appdir, info):
|
|||
with open('rattail.conf') as f:
|
||||
contents = f.read()
|
||||
contents = contents.replace('<ENVDIR>', envdir)
|
||||
contents = contents.replace('<SEP>', os.sep)
|
||||
contents = contents.replace('<DBHOST>', info['dbhost'])
|
||||
contents = contents.replace('<DBNAME>', info['dbname'])
|
||||
contents = contents.replace('<DBUSER>', info['dbuser'])
|
||||
|
@ -141,13 +154,20 @@ def make_configs(c, envdir, appdir, info):
|
|||
|
||||
# quiet.conf
|
||||
if not os.path.exists(os.path.join(appdir, 'quiet.conf')):
|
||||
c.run('{}/bin/rattail make-config -T quiet -O {}'.format(envdir, appdir))
|
||||
if sys.platform == 'win32':
|
||||
c.run('{} make-config -T quiet -O {}'.format(
|
||||
os.path.join(envdir, 'Scripts', 'rattail'),
|
||||
appdir))
|
||||
else:
|
||||
c.run('{}/bin/rattail make-config -T quiet -O {}'.format(
|
||||
envdir, appdir))
|
||||
|
||||
# web.conf
|
||||
if not os.path.exists(os.path.join(appdir, 'web.conf')):
|
||||
with open('web.conf') as f:
|
||||
contents = f.read()
|
||||
contents = contents.replace('<ENVDIR>', envdir)
|
||||
contents = contents.replace('<SEP>', os.sep)
|
||||
with open(os.path.join(appdir, 'web.conf'), 'w') as f:
|
||||
f.write(contents)
|
||||
|
||||
|
@ -156,19 +176,37 @@ def check_db(c, envdir, appdir):
|
|||
"""
|
||||
Do basic sanity checks for Theo database
|
||||
"""
|
||||
c.run('{}/bin/rattail -c {}/quiet.conf --no-versioning checkdb'.format(envdir, appdir))
|
||||
if sys.platform == 'win32':
|
||||
c.run('{} -c {} --no-versioning checkdb'.format(
|
||||
os.path.join(envdir, 'Scripts', 'rattail'),
|
||||
os.path.join(appdir, 'quiet.conf')))
|
||||
else:
|
||||
c.run('{}/bin/rattail -c {}/quiet.conf --no-versioning checkdb'.format(
|
||||
envdir, appdir))
|
||||
|
||||
|
||||
def install_db_schema(c, envdir, appdir):
|
||||
"""
|
||||
Install the schema for Theo database
|
||||
"""
|
||||
c.run('{}/bin/alembic -c {}/rattail.conf upgrade heads'.format(envdir, appdir))
|
||||
if sys.platform == 'win32':
|
||||
c.run('{} -c {} upgrade heads'.format(
|
||||
os.path.join(envdir, 'Scripts', 'alembic'),
|
||||
os.path.join(appdir, 'rattail.conf')))
|
||||
else:
|
||||
c.run('{}/bin/alembic -c {}/rattail.conf upgrade heads'.format(
|
||||
envdir, appdir))
|
||||
|
||||
|
||||
def make_admin_user(c, envdir, appdir, info):
|
||||
"""
|
||||
Make an admin user in the Theo database
|
||||
"""
|
||||
c.run('{}/bin/rattail -c {}/quiet.conf make-user --admin {} --password {}'.format(
|
||||
envdir, appdir, info['theouser'], info['theopass']))
|
||||
if sys.platform == 'win32':
|
||||
c.run('{} -c {} make-user --admin {} --password {}'.format(
|
||||
os.path.join(envdir, 'Scripts', 'rattail'),
|
||||
os.path.join(appdir, 'quiet.conf'),
|
||||
info['theouser'], info['theopass']))
|
||||
else:
|
||||
c.run('{}/bin/rattail -c {}/quiet.conf make-user --admin {} --password {}'.format(
|
||||
envdir, appdir, info['theouser'], info['theopass']))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue