def call_command(self, *args, **kwargs): """ Calls the given management command, but only if it's not a dry run. If it's a dry run, then a notice about the command will be printed. """ if self.dry_run: self.stdout.write(format_command("python manage.py", args, kwargs)) else: call_command(*args, **kwargs)
def __call__(self, *args, **kwargs): # Allow dry run to be overridden for selective (non-mutating) commands. force_live_run = kwargs.pop("_force_live_run", False) # Run the command. if self.dry_run and not force_live_run: # Allow a dry run to be processed. self._stdout.write(format_command("heroku", args, kwargs) + "\n") else: # Call a live command. try: return self._heroku(*args, **kwargs) except sh.ErrorReturnCode as ex: raise HerokuCommandError(str(ex))