def run(self, block=True, binary=False, cwd=None, env=None):
self.blocking = block<EOL>if self.blocking:<EOL><INDENT>popen_kwargs = self._default_popen_kwargs.copy()<EOL>del popen_kwargs["<STR_LIT>"]<EOL>popen_kwargs["<STR_LIT>"] = not binary<EOL>if cwd:<EOL><INDENT>popen_kwargs["<STR_LIT>"] = cwd<EOL><DEDENT>if env:<EOL><INDENT>popen_kwargs["<STR_LIT>"].update(env)<EOL><DEDENT>s = subprocess.Popen(self._popen_args, **popen_kwargs)<EOL><DEDENT>else:<EOL><INDENT>pexpect_kwargs = self._default_pexpect_kwargs.copy()<EOL>if binary:<EOL><INDENT>pexpect_kwargs["<STR_LIT>"] = None<EOL><DEDENT>if cwd:<EOL><INDENT>pexpect_kwargs["<STR_LIT>"] = cwd<EOL><DEDENT>if env:<EOL><INDENT>pexpect_kwargs["<STR_LIT>"].update(env)<EOL><DEDENT>pexpect_kwargs["<STR_LIT>"]["<STR_LIT>"] = "<STR_LIT:1>"<EOL>s = PopenSpawn(self._popen_args, **pexpect_kwargs)<EOL><DEDENT>self.subprocess = s<EOL>self.was_run = True<EOL>
Runs the given command, with or without pexpect functionality enabled.