← 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: Open => Answered

RaiMan proposed the following answer:
I have revised and tested the snippet. It works for me.
(putInstructions had 2 errors, but had nothing to do with your problem)

now a workflow
step 1
step 2
step 3

will create an instructions file with the given options in step2, if the
named instructions file does not exist yet.

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

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

fInstructions = "C:\\Users\\Richi\\Astrator\\Instructions.txt"

# step 1: fetch current instructions
instructions = getInstructions(fInstructions)
# 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(fInstructions, instructions)

so please try again with this version

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