diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-07-02 11:13:33 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-07-02 11:13:33 -0400 |
commit | 91fc975ba2bf0414624aa9c263ddf441beadfa3d (patch) | |
tree | a4c7489d7d2f96a588b2d262f844038e9414acbd | |
parent | 9054a211b60f55e00ea446433444c0bf4970a50f (diff) | |
download | cmd2-git-91fc975ba2bf0414624aa9c263ddf441beadfa3d.tar.gz |
Removed unnecessary try/except in do_shell
Since in the subprocess.Popen() call, shell=True and stderr=sys.stderr, errors get printed on stderr. There is no need to catch an exception.
-rw-r--r-- | CHANGES.md | 1 | ||||
-rwxr-xr-x | cmd2.py | 11 |
2 files changed, 4 insertions, 8 deletions
@@ -22,6 +22,7 @@ News * ``load`` command has better error checking and reporting * Clipboard copy and paste functionality is now handled by the **pyperclip** module * NOTE: This adds an additional required 3rd-party dependency + * ``shell`` command now supports redirection and piping of output * Added a lot of unit tests 0.7.3 @@ -479,9 +479,7 @@ class Cmd(cmd.Cmd): self.initial_stdout = sys.stdout self.history = History() self.pystate = {} - # noinspection PyUnresolvedReferences - self.keywords = self.reserved_words + [fname[3:] for fname in dir(self) - if fname.startswith('do_')] + self.keywords = self.reserved_words + [fname[3:] for fname in dir(self) if fname.startswith('do_')] self.parser_manager = ParserManager(redirector=self.redirector, terminators=self.terminators, multilineCommands=self.multilineCommands, legalChars=self.legalChars, commentGrammars=self.commentGrammars, @@ -1142,11 +1140,8 @@ class Cmd(cmd.Cmd): """Execute a command as if at the OS prompt. Usage: shell <command> [arguments]""" - try: - proc = subprocess.Popen(command, stdout=self.stdout, stderr=sys.stderr, shell=True) - proc.communicate() - except FileNotFoundError as e: - self.perror(e.strerror, traceback_war=False) + proc = subprocess.Popen(command, stdout=self.stdout, stderr=sys.stderr, shell=True) + proc.communicate() def path_complete(self, text, line, begidx, endidx, dir_exe_only=False, dir_only=False): """Method called to complete an input line by local file system path completion. |