← Back to team overview

sikuli-driver team mailing list archive

[Question #449241]: os.getenv is not getting new variable settings each time it is called

 

New question #449241 on Sikuli:
https://answers.launchpad.net/sikuli/+question/449241

I'm trying to reset System environment variables for a string of tests (one starting after another. After each test several System environment variables need to be changed before next test is run... using the following code:

from sikuli import *
import os

def exeCmd(title,cmd):
   App.open('CMD /k start \"'+title+'\" '+cmd)

exeCmd ("env1","c:\\3mhis\\tests\\system1.bat")

Var1 = os.getenv('Var1')
Var2 = os.getenv('Var2')

print Var1
print Var2

wait (10)

exeCmd ("env1","c:\\3mhis\\tests\\system2.bat")

Var1 = os.getenv('Var1')
Var2 = os.getenv('Var2')

print Var1
print Var2

System1.bat and System 2.bat each use respectively:
Setx Var1 system1a /M
Setx Var2 system1b /M
exit

Setx with /M should set System wide environment variables and os.getenv should force retrieval of these variables.
However both print statements have the same values which are for system1.
I need to use System Environment variables because each test launches external applications that utilizes them.

I am fairly new to Sikuli 
Thanks in advance.

-Justin


-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.