dont use a subprocess when os can be used

Replaced the complex parsing of an external command with pythons native
commands.