Use subprocess instead of os.system
closes #1026, closes #1470, closes #1476
Master is now Python 3 only. This needs to be rebased, and compat for shutil.which can be removed.
#1543 reverts the previous shlex.quote pr because of an issue with calling quote on a command that might actually be a command and options, like less -FRSX (and also an issue with quoting on Windows, which is sidestepped here). Unfortunately, just calling shlex.split on the command first will fail on Windows unless slashes in paths are double escaped:
>>> shlex.split("C:\\path\\to\\exe /test other\\path")
['C:pathtoexe', '/test', 'otherpath']
>>> shlex.split("C:\\path\\to\\exe /test other\\path".replace("\\", "\\\\"))
['C:path\\to\\exe', '/test', 'other\\path']
>>> shlex.split("C:\\path\\to\\exe /test other\\path", posix=False)
['C:path\\to\\exe', '/test', 'other\\path']
Technically that last one with posix=False is not correct, as the argument refers to non-Posix shells on Unix, not completely different platforms like cmd on Windows. Either solution would probably be fine for the limited case here, although I'd lean towards replace since it's more clear what's being special-cased.