How to use the honcho.process.Process function in honcho

To help you get started, we’ve selected a few honcho examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nickstenning / honcho / tests / test_process.py View on Github external
def test_ctor_name(self):
        proc = Process('echo 123', name='foo')
        assert proc.name == 'foo'
github nickstenning / honcho / tests / test_process.py View on Github external
def test_cwd_passed_along(self):
        proc = Process('echo 123', cwd='fake-dir')
        proc._child_ctor = FakePopen
        proc.run(self.q)
        assert proc._child.kwargs['cwd'] == 'fake-dir'
github nickstenning / honcho / tests / test_process.py View on Github external
def test_ctor_colour(self):
        proc = Process('echo 123', colour='red')
        assert proc.colour == 'red'
github nickstenning / honcho / tests / test_process.py View on Github external
def test_output_receives_lines(self):
        def _ctor(*args, **kwargs):
            popen = FakePopen(*args, **kwargs)
            popen.stdout = FakeOutput(lines=[b"hello\n", b"world\n"])
            return popen

        proc = Process('echo 123')
        proc._child_ctor = _ctor
        proc.run(self.q)
        assert self.q.got_message(b"hello\n")
        assert self.q.got_message(b"world\n")
github nickstenning / honcho / tests / test_process.py View on Github external
def test_output_does_not_receive_lines_when_quiet(self):
        def _ctor(*args, **kwargs):
            popen = FakePopen(*args, **kwargs)
            popen.stdout = FakeOutput(lines=[b"hello\n", b"world\n"])
            return popen

        proc = Process('echo 123', quiet=True)
        proc._child_ctor = _ctor
        proc.run(self.q)
        assert not self.q.got_message(b"hello\n")
        assert not self.q.got_message(b"world\n")
github nickstenning / honcho / tests / test_process.py View on Github external
def test_output_receives_stop(self):
        proc = Process('echo 123')
        proc._child_ctor = FakePopen
        proc.run(self.q)
        msg = self.q.messages[-1]
        assert msg.type == 'stop'
github nickstenning / honcho / tests / test_process.py View on Github external
def test_message_contains_name(self):
        proc = Process('echo 123', name="barry")
        proc._child_ctor = FakePopen
        proc.run(self.q)
        msg = self.q.messages[0]
        assert msg.name == "barry"
github nickstenning / honcho / tests / test_process.py View on Github external
def test_ctor_quiet(self):
        proc = Process('echo 123', quiet=True)
        assert proc.quiet
github django-zero / django-zero / tests / test_integration.py View on Github external
# TODO: move back into make install
        os.system("python -m django_zero install")
        os.system("yarn install")

        os.system("python -m django_zero manage migrate")

        # Run the webpack assets builder
        os.system("python -m django_zero webpack")

        target = "127.0.0.1", get_free_port()
        print("Target:", *target)

        events = multiprocessing.Queue()
        server_command = "python -m django_zero manage runserver {0}:{1}".format(*target)
        print("Command:", server_command)
        server = Process(server_command, name="server")
        server_process = multiprocessing.Process(name="server", target=server.run, args=(events, True))

        try:
            server_process.start()
            exit = False
            pid = None

            while 1:
                try:
                    msg = events.get(timeout=0.1)
                except Empty:
                    if exit:
                        break
                else:
                    # print(msg)
                    if msg.type == "start":
github nickstenning / honcho / honcho / manager.py View on Github external
def __init__(self, printer=None):
        self.events = multiprocessing.Queue()
        self.returncode = None

        self._colours = get_colours()
        self._env = Env()

        self._printer = printer if printer is not None else Printer(sys.stdout)
        self._printer.width = len(SYSTEM_PRINTER_NAME)

        self._process_ctor = Process
        self._processes = {}

        self._terminating = False