Internal function to check the exit value of the shell. Do not use.
499863
def check_last_exit_values(self,
	                           send,
	                           check_exit=True,
	                           expect=None,
	                           exit_values=None,
	                           retry=0,
	                           retbool=False):
		
		shutit = self.shutit
		expect = expect or self.default_expect
		if not self.check_exit or not check_exit:
			shutit.log('check_exit configured off, returning', level=logging.DEBUG)
			return True
		if exit_values is None:
			exit_values = ['0']
		if isinstance(exit_values, int):
			exit_values = [str(exit_values)]
		# Don't use send here (will mess up last_output)!
		# Space before "echo" here is sic - we don't need this to show up in bash history
		send_exit_code = ' echo EXIT_CODE:$?'
		shutit.log('Sending with sendline: ' + str(send_exit_code), level=logging.DEBUG)
		assert not self.sendline(ShutItSendSpec(self,
		                                        send=send_exit_code,
		                                        ignore_background=True)), shutit_util.print_debug()
		shutit.log('Expecting: ' + str(expect), level=logging.DEBUG)
		self.expect(expect,timeout=10)
		shutit.log('before: ' + str(self.pexpect_child.before), level=logging.DEBUG)
		res = shutit.match_string(str(self.pexpect_child.before), '^EXIT_CODE:([0-9][0-9]?[0-9]?)$')
		if res not in exit_values or res is None: # pragma: no cover
			res_str = res or str(res)
			shutit.log('shutit_pexpect_child.after: ' + str(self.pexpect_child.after), level=logging.DEBUG)
			shutit.log('Exit value from command: ' + str(send) + ' was:' + res_str, level=logging.DEBUG)
			msg = ('\nWARNING: command:\n' + send + '\nreturned unaccepted exit code: ' + res_str + '\nIf this is expected, pass in check_exit=False or an exit_values array into the send function call.')
			shutit.build['report'] += msg
			if retbool:
				return False
			elif retry == 1 and shutit_global.shutit_global_object.interactive >= 1:
				# This is a failure, so we pass in level=0
				shutit.pause_point(msg + '\n\nInteractive, so not retrying.\nPause point on exit_code != 0 (' + res_str + '). CTRL-C to quit', shutit_pexpect_child=self.pexpect_child, level=0)
			elif retry == 1:
				shutit.fail('Exit value from command\n' + send + '\nwas:\n' + res_str, throw_exception=False) # pragma: no cover
			else:
				return False
		return True
760694
def do_EOF(self, args):
        """"""
        if _debug: ConsoleCmd._debug("do_EOF %r", args)
        return self.do_exit(args)
1330524
@Deprecated
    @Then("^the command exit status is '(.+?)'$")
    public void checkShellExitStatus(int expectedExitStatus) throws Exception {
        assertThat(commonspec.getCommandExitStatus()).as("Is equal to " + expectedExitStatus + ".").isEqualTo(expectedExitStatus);
    }
433135
def exit(self) -> None:
        """"""
        total = sum(len(logs) for logs in self.logs.values())
        if self.json:
            self.logs['total'] = total
            print(json.dumps(self.logs, indent=self.indent))

        else:
            for name, log in self.logs.items():
                if not log or self.parser[name].as_bool("quiet"):
                    continue

                print("[[{0}]]".format(name))
                getattr(snekchek.format, name + "_format")(log)
                print("\n")

            print("-" * 30)
            print("Total:", total)

        sys.exit(self.status_code)
761100
def check_output_command(file_path, head=None, tail=None):
    ''''''
    if os.path.exists(file_path):
        if sys.platform == 'win32':
            cmds = ['powershell.exe', 'type', file_path]
            if head:
                cmds += ['|', 'select', '-first', str(head)]
            elif tail:
                cmds += ['|', 'select', '-last', str(tail)]
            return check_output(cmds, shell=True).decode('utf-8')
        else:
            cmds = ['cat', file_path]
            if head:
                cmds = ['head', '-' + str(head), file_path]
            elif tail:
                cmds = ['tail', '-' + str(tail), file_path]
            return check_output(cmds, shell=False).decode('utf-8')
    else:
        print_error('{0} does not exist!'.format(file_path))
        exit(1)
540085
def _exit(self):
        
        self._removeInputPrompt()
        print(self._color(self.COLOR_YELLOW, 'CLOSING TERMINAL...')) 
        self.stop()
57364
def _safe_exit(start, output):
    
    try:
        sys.stdout.write(output)
        sys.stdout.flush()
    except TypeError:  # python3
        sys.stdout.write(str(output, 'utf-8'))
        sys.stdout.flush()
    except IOError:
        pass

    seconds = time.time() - start
    print("\n\n%5.3f seconds" % (seconds), file=sys.stderr)
913076
def cli(ctx, cmd):
    """"""

    exit_code = util.call(cmd)
    ctx.exit(exit_code)
633670
def exit(self, code=None, message=None, perfdata=None, extdata=None):
        
        code = UNKNOWN if code is None else int(code)
        message = "" if message is None else str(message)
        perfdata = "" if perfdata is None else str(perfdata)
        extdata = "" if extdata is None else str(extdata)
        print("{0} {1} - {2} | {3}".format(self.name.upper(),
                                           _CODES_STR[code],
                                           message, perfdata))
        if extdata:
            print(extdata)
        sys.exit(code)
1100709
def check_output(self, cmd, timeout=None, keep_rc=False, env=None):
        
        return subproc.call(cmd, timeout=timeout or self.timeout,
                keep_rc=keep_rc, env=env)
971616
def expect_exitstatus(self, exit_status):
        
        self.expect_end()
        logger.debug("Checking exit status of '{0}', output so far: {1}".format(
            self.name, self.get_output()))
        if self._spawn.exitstatus is None:
            raise WrongExitStatusException(
                instance=self, expected=exit_status, output=self.get_output())

        if self._spawn.exitstatus is not exit_status:
            raise WrongExitStatusException(
                instance=self,
                expected=exit_status,
                got=self._spawn.exitstatus,
                output=self.get_output())
883889
def check_shell_redirection(cmd):
    
    curly_brackets = True
    while curly_brackets:
        SRE_match_obj = re.search(r'\{(.*?)}',cmd)
        if SRE_match_obj is not None:
            cmd = cmd[:SRE_match_obj.start()] + cmd[(SRE_match_obj.end()+1):]
            if re.search(r'\{(.*?)}',cmd) is None:
                curly_brackets = False
        else:
            curly_brackets = False
    return ">" in cmd
281489
def exit(self, status=0, message=None):
        
        if status:
            self.logger.error(message)
        if self.__parser__:  # pylint: disable-msg=E1101
            self.__parser__.exit(status, message)  # pylint: disable-msg=E1101
        else:
            sys.exit(status)
78140
def _chk_docopt_exit(self, args, exp_letters):
        """"""
        if args is None:
            args = sys.argv[1:]
        keys_all = self.exp_keys.union(self.exp_elems)
        if exp_letters:
            keys_all |= exp_letters
        unknown_args = self._chk_docunknown(args, keys_all)
        if unknown_args:
            raise RuntimeError("{USAGE}\n    **FATAL: UNKNOWN ARGS: {UNK}".format(
                USAGE=self.doc, UNK=" ".join(unknown_args)))
1066034
def exit_if_path_exists(self):
        
        if os.path.exists(self.output_path):
            ui.error(c.MESSAGES["path_exists"], self.output_path)
            sys.exit(1)
1133345
def safe_exit(output):
    """"""
    try:
        sys.stdout.write(output)
        sys.stdout.flush()
    except IOError:
        pass
950034
def system_exit(object):
    

    @functools.wraps(object)
    def system_exit_wrapper(*args, **kwargs):
        """
        Handles proper system exit in case of critical exception.

        :param \*args: Arguments.
        :type \*args: \*
        :param \*\*kwargs: Keywords arguments.
        :type \*\*kwargs: \*\*
        """

        try:
            if object(*args, **kwargs):
                foundations.core.exit(0)
        except Exception as error:
            sys.stderr.write("\n".join(foundations.exceptions.format_exception(*sys.exc_info())))
            foundations.core.exit(1)

    return system_exit_wrapper