def heroku(self, config, env, output, clear_workers): from dallinger.heroku.tools import HerokuLocalWrapper wrapper = HerokuLocalWrapper(config, output, env=env) yield wrapper try: print("Calling stop() on {}".format(wrapper)) print(wrapper._record[-1]) wrapper.stop(signal.SIGKILL) except IndexError: pass
def run(self): """Set up the environment, get a HerokuLocalWrapper instance, and pass it to the concrete class's execute() method. """ self.configure() self.setup() self.update_dir() db.init_db(drop_all=True) config = get_config() environ = None if self.environ: environ = os.environ.copy() environ.update(self.environ) self.out.log("Starting up the Heroku Local server...") with HerokuLocalWrapper(config, self.out, verbose=self.verbose, env=environ) as wrapper: try: self.execute(wrapper) except KeyboardInterrupt: pass finally: os.chdir(self.original_dir) self.cleanup()
def test_as_context_manager(self, config, env, output, clear_workers): from dallinger.heroku.tools import HerokuLocalWrapper with HerokuLocalWrapper(config, output, env=env) as heroku: assert heroku.is_running assert not heroku.is_running