From c3f680d3c9159c29fa6cf498c466863eb7d8fb27 Mon Sep 17 00:00:00 2001 From: ronny abraham Date: Thu, 10 Aug 2023 22:46:14 +0300 Subject: [PATCH] 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 --- modules/django.py | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/modules/django.py b/modules/django.py index 7166447..334140b 100644 --- a/modules/django.py +++ b/modules/django.py @@ -126,7 +126,9 @@ def manage(args="help", workingdir=None, prefix="", suffix=""): from fabric.context_managers import cd with virtualenv(): + if workingdir: + with cd(workingdir): fabcommand = "{prefix} {djangoroot}/manage.py {args} " \ "--pythonpath='{djangoroot}' " \ @@ -147,29 +149,33 @@ def manage(args="help", workingdir=None, prefix="", suffix=""): # MAKE SURE THIS IS ALWAYS HERE! shell='/bin/bash') - with cd(configuration.paths.django.root): - cmd = "{prefix} {djangoroot}/manage.py {args} " \ - " --pythonpath='{djangoroot}' " \ - "--settings={djangosettings} {suffix}".format( - prefix=prefix, - djangoroot=configuration.paths.django.root, - args=args, - djangosettings=configuration.imports.settings, - suffix=suffix) + else: + with cd(configuration.paths.django.root): + cmd = "{prefix} {djangoroot}/manage.py {args} " \ + " --pythonpath='{djangoroot}' " \ + "--settings={djangosettings} {suffix}".format( + prefix=prefix, + djangoroot=configuration.paths.django.root, + args=args, + djangosettings=configuration.imports.settings, + suffix=suffix) - if env.debug: - print("command: with cd(%s)" % configuration.paths.django.root) - print("command: fabric_ops.run(%s)" % cmd) - else: + if env.debug: + print("command: with cd(%s)" % + configuration.paths.django.root) - output = fabric_ops.run( - cmd, - # MAKE SURE THIS IS ALWAYS HERE! - shell='/bin/bash' - ) + print("command: fabric_ops.run(%s)" % cmd) - # fabric.run has the ability to give me back the output - return output + else: + + 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: # there was a major problem using fabric commands of "local" or "prefix"