← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #252800]: changes from True to False

 

Question #252800 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/252800

    Status: Answered => Open

Richi is still having a problem:
Hi i have tried the following code with sikuli :

def getInstructions(inp):
    store = {}
    configInput = open(inp)
    for line in configInput.readlines():
        (key, val) = line.strip().split("=")
        config[key.strip()] = val.strip()
    configInput.close()
    return store

def putInstructions(out, store):
    configOutput = open(out, "w")
    for key in store.keys():
        line = key + "=" + store[key] + "\n"
        out.write(line)
    configInput.close()

# step 1: fetch current instructions
instructions = getInstructions("C:\\Users\\Richi\\Desktop\\Instructions.txt")       

# step 2: modify instructions
instructions["data.configure.camera"] = "false"

# one might add additional instructions
instructions["data.configure.newoption"] = "true"

# step 3: write the instructions back to file
putInstructions("C:\\Users\\Richi\\Desktop\\Instructions.txt", instructions)



But the above code does not work.

The error message which is displayed by Sikuli is the following:


[error] script [ ConfigDR ] stopped with error in line 16
[error] NameError ( global name 'config' is not defined )
[error] --- Traceback --- error source first line: module ( function ) statement 6: main ( getInstructions ) config[key.strip()] = val.strip()
[error] --- Traceback --- end --------------


line 16 is : 
 # step 1: fetch current instructions
instructions = getInstructions("C:\\Users\\Richi\\Desktop\\Instructions.txt")       


can you please help?

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.