fixed the startapp and manage so that startapp does not create a directory (leads to an error) and instead added arg to manage to specify working directory where the manage command would be run in
This commit is contained in:
parent
e270402ac9
commit
2dffeaa1b9
1 changed files with 37 additions and 17 deletions
|
|
@ -37,29 +37,56 @@ def test(args=None):
|
|||
|
||||
|
||||
@task
|
||||
def commandline(args=""):
|
||||
def commandline(args="", workingdir=None):
|
||||
"""
|
||||
prints out what you need to run on the command line to invoke manage.py
|
||||
"""
|
||||
configuration = env.config
|
||||
|
||||
commandline = "{djangoroot}/manage.py {args} --pythonpath='{djangoroot}'" \
|
||||
" --settings={djangosettings}".format(
|
||||
djangoroot=configuration.paths.django.root,
|
||||
args=args,
|
||||
djangosettings=configuration.imports.settings,)
|
||||
if workingdir:
|
||||
commandline = "{djangoroot}/manage.py {args} " \
|
||||
"--pythonpath='{djangoroot}' " \
|
||||
"--settings={djangosettings}".format(
|
||||
djangoroot=configuration.paths.django.root,
|
||||
args=args,
|
||||
djangosettings=configuration.imports.settings,)
|
||||
else:
|
||||
commandline = "{djangoroot}/manage.py {args} --pythonpath='{djangoroot}'" \
|
||||
" --settings={djangosettings}".format(
|
||||
djangoroot=configuration.paths.django.root,
|
||||
args=args,
|
||||
djangosettings=configuration.imports.settings,)
|
||||
|
||||
print(commandline)
|
||||
|
||||
|
||||
@task
|
||||
def manage(args=""):
|
||||
def manage(args="", workingdir=None):
|
||||
configuration = env.config
|
||||
|
||||
# changes the working directory to the djangoroot
|
||||
from fabric.context_managers import cd
|
||||
|
||||
with virtualenv():
|
||||
if workingdir:
|
||||
with cd(workingdir):
|
||||
fabcommand = "{djangoroot}/manage.py {args} " \
|
||||
"--pythonpath='{djangoroot}' " \
|
||||
"--settings={djangosettings}".format(
|
||||
djangoroot=configuration.paths.django.root,
|
||||
args=args,
|
||||
djangosettings=configuration.imports.settings,
|
||||
)
|
||||
|
||||
if env.debug:
|
||||
print("fabcommand: %s" % fabcommand)
|
||||
print("workingdir: %s" % workingdir)
|
||||
else:
|
||||
output = fabric_ops.run(
|
||||
fabcommand,
|
||||
# MAKE SURE THIS IS ALWAYS HERE!
|
||||
shell='/bin/bash')
|
||||
|
||||
with cd(configuration.paths.django.root):
|
||||
output = fabric_ops.run(
|
||||
"{djangoroot}/manage.py {args} --pythonpath='{djangoroot}' "
|
||||
|
|
@ -151,18 +178,11 @@ def startapp(appname='help'):
|
|||
if handle_help(appname, msg_help, 'help'):
|
||||
sys.exit()
|
||||
|
||||
destination = os.path.join(configuration.paths.django.apps, appname)
|
||||
command = "startapp {appname}".format(
|
||||
appname=appname)
|
||||
|
||||
cmd_mkdir = "mkdir {destination}".format(
|
||||
destination=destination)
|
||||
manage(command, workingdir=configuration.paths.django.apps)
|
||||
|
||||
command = "startapp {appname} {destination}".format(
|
||||
appname=appname,
|
||||
destination=destination)
|
||||
|
||||
fabric_ops.run(cmd_mkdir)
|
||||
|
||||
manage(command)
|
||||
# with lcd(configuration.paths.django.apps):
|
||||
# manage(command)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue