[Tutor] Not sure how to use external command within python code (3.6)
David L Neil
PyTutor at DancesWithMice.info
Sat Dec 7 15:02:16 EST 2019
On 8/12/19 8:41 AM, Alan Gauld via Tutor wrote:
> On 07/12/2019 16:16, Robert Alexander wrote:
>
>> process = subprocess.Popen(['/usr/local/bin/speedtest', '-f json'],
>
> Sorry I haven't looked at this closely but it might be better to pass
> the flag and value seperately:
>
> process = subprocess.Popen(['/usr/local/bin/speedtest', '-f', 'json'],...
>
> Just a thought,
Similar thinking: when the complex/advanced case doesn't work, simplify!
Recommend review of https://docs.python.org/3/library/subprocess.html
(.run() eases life, in most cases) and use the Python REPL to experiment
with the simplest access to Speedtest (and to 'see' what is happening at
each step!), then to add the 'bells and whistles', eg formatted output,
and only then, receiving same back into Python...
--
Regards =dn
More information about the Tutor
mailing list