updated django.manage so that if working dir is false, then the second section only gets executed under the elese, whereas if working dir was true, the second section got executed anyway

This commit is contained in:
ronny abraham 2023-08-10 22:46:14 +03:00
parent 4fbf259f69
commit c3f680d3c9

View file

@ -126,7 +126,9 @@ def manage(args="help", workingdir=None, prefix="", suffix=""):
from fabric.context_managers import cd from fabric.context_managers import cd
with virtualenv(): with virtualenv():
if workingdir: if workingdir:
with cd(workingdir): with cd(workingdir):
fabcommand = "{prefix} {djangoroot}/manage.py {args} " \ fabcommand = "{prefix} {djangoroot}/manage.py {args} " \
"--pythonpath='{djangoroot}' " \ "--pythonpath='{djangoroot}' " \
@ -147,29 +149,33 @@ def manage(args="help", workingdir=None, prefix="", suffix=""):
# MAKE SURE THIS IS ALWAYS HERE! # MAKE SURE THIS IS ALWAYS HERE!
shell='/bin/bash') shell='/bin/bash')
with cd(configuration.paths.django.root): else:
cmd = "{prefix} {djangoroot}/manage.py {args} " \ with cd(configuration.paths.django.root):
" --pythonpath='{djangoroot}' " \ cmd = "{prefix} {djangoroot}/manage.py {args} " \
"--settings={djangosettings} {suffix}".format( " --pythonpath='{djangoroot}' " \
prefix=prefix, "--settings={djangosettings} {suffix}".format(
djangoroot=configuration.paths.django.root, prefix=prefix,
args=args, djangoroot=configuration.paths.django.root,
djangosettings=configuration.imports.settings, args=args,
suffix=suffix) djangosettings=configuration.imports.settings,
suffix=suffix)
if env.debug: if env.debug:
print("command: with cd(%s)" % configuration.paths.django.root) print("command: with cd(%s)" %
print("command: fabric_ops.run(%s)" % cmd) configuration.paths.django.root)
else:
output = fabric_ops.run( print("command: fabric_ops.run(%s)" % cmd)
cmd,
# MAKE SURE THIS IS ALWAYS HERE!
shell='/bin/bash'
)
# fabric.run has the ability to give me back the output else:
return output
output = fabric_ops.run(
cmd,
# MAKE SURE THIS IS ALWAYS HERE!
shell='/bin/bash'
)
# fabric.run has the ability to give me back the output
return output
# NOTE: # NOTE:
# there was a major problem using fabric commands of "local" or "prefix" # there was a major problem using fabric commands of "local" or "prefix"