[Tutor] Subprocess help

Crush crushed26 at gmail.com
Sun Sep 21 22:43:14 CEST 2014


Thank you Danny for your assistance. Just a couple of follow up questions to help me understand what is going on.

You said...

"Semantically, the command above means:
  execute "./octosetupBROADCASTER-linux_i386.bin" in an environment
that binds BYPASSROOT to "yes"."

Does the above mean "BYPASSROOT" is an environmet variable? Is this created and set by default by the system or is it created and set by "octosetupBROADCASTER-linux_i386.bin?"

The code you suggested...

"envCopy = os.environ.copy()
 envCopy['BYPASSROOT'] = 'yes'
 subprocess.Popen(["./octosetupBROADCASTER-linux_i386.bin"], env=envCopy)"

This copies the systems environment variables and stores them in the variable "envCopy?" What do the "[ ]'s" mean? Are the variables stored in an array or list and by enclosing "BYPASSROOT" in brackets, we are ultimately selecting "BYPASSROOT" and assinging its value to "yes?"

We then pass this to subprocess, but how does subprocess know we want "BYPASSROOT" to equal "yes" when we only pass on envCopy, which is coded before "
envCopy['BYPASSROOT'] = 'yes'?" Does python not work from top to bottom? 


Bo 



More information about the Tutor mailing list