Пример #1
0
    def remote(self, cmd, *args, **kwargs):
        remote_kwargs = self.remote_kwargs.copy()
        remote_kwargs.update(kwargs)

        cmd = self._wrap_cmd(cmd, 'cwd')

        self._output(prefixlines(self.env['host'], "running", cmd, "blue"))

        start = time.time()
        status = remote(self.env['host'],
                        cmd,
                        output=False,
                        *args,
                        **remote_kwargs).values()[0]
        end = time.time()

        try:
            self._check_status(status)
        except BadReturnCode:
            self._output(
                cmd_status(end - start,
                           self.env['host'],
                           cmd,
                           status,
                           state='failed',
                           color="red"), logging.warning)
            raise

        self._output(cmd_status(end - start, self.env['host'], cmd, status))
        return status
Пример #2
0
    def local(self, cmd, *args, **kwargs):
        cmd = self._wrap_cmd(cmd, 'lcwd')
        self._output(prefixlines('localhost', "running", cmd, "blue"))
        start = time.time()
        status = local(cmd, output=False, *args, **kwargs)
        end = time.time()
        try:
            self._check_status(status)
        except BadReturnCode:
            self._output(cmd_status(end - start, 'localhost', cmd,
                                    status, state='failed', color="red"),
                         logging.warning)
            raise

        self._output(cmd_status(end - start, 'localhost', cmd, status))
        return status
Пример #3
0
    def local(self, cmd, *args, **kwargs):
        cmd = self._wrap_cmd(cmd, 'lcwd')
        self._output(prefixlines('localhost', "running", cmd, "blue"))
        start = time.time()
        status = local(cmd, output=False, *args, **kwargs)
        end = time.time()
        try:
            self._check_status(status)
        except BadReturnCode:
            self._output(
                cmd_status(end - start,
                           'localhost',
                           cmd,
                           status,
                           state='failed',
                           color="red"), logging.warning)
            raise

        self._output(cmd_status(end - start, 'localhost', cmd, status))
        return status
Пример #4
0
    def remote(self, cmd, *args, **kwargs):
        remote_kwargs = self.remote_kwargs.copy()
        remote_kwargs.update(kwargs)

        cmd = self._wrap_cmd(cmd, 'cwd')

        self._output(prefixlines(self.env['host'], "running", cmd, "blue"))

        start = time.time()
        status = remote(self.env['host'], cmd, output=False,
                        *args, **remote_kwargs).values()[0]
        end = time.time()

        try:
            self._check_status(status)
        except BadReturnCode:
            self._output(cmd_status(end - start, self.env['host'], cmd,
                                    status, state='failed', color="red"),
                         logging.warning)
            raise

        self._output(cmd_status(end - start, self.env['host'], cmd, status))
        return status
Пример #5
0
def _run_command(host, cmd, runner, output=True):
    """runner: function which runs the command, must be of the form f(cmd)
               and return a Pstatus named-tuple
    """

    if output:
        with _output_lock:
            logging.info(prefixlines(host, "running", cmd, "blue"))

    start = time.time()
    status = runner(cmd)
    end = time.time()

    if output:
        with _output_lock:
            logging.info(cmd_status(end - start, host, cmd, status))

    return status
Пример #6
0
def _run_command(host, cmd, runner, output=True):
    """runner: function which runs the command, must be of the form f(cmd)
               and return a Pstatus named-tuple
    """

    if output:
        with _output_lock:
            logging.info(prefixlines(host, "running", cmd, "blue"))

    start = time.time()
    status = runner(cmd)
    end = time.time()

    if output:
        with _output_lock:
            logging.info(cmd_status(end - start, host, cmd, status))

    return status