← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #230996]: IDE: config file loaded in sub script is not reloaded at rerun

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
A general solution would be, to check, wether the config file has changed.
To accomplish this, you need some init() function in common.py, that would handle the file location challenge and check for changes.
This can be combined with the file location problem.

# commons.py:
lastTimeStamp = None
init()

def getTimeStamp():
    # check the file's time stamps and return some time, that makes sense

def configIsNewer():
     # find out wether config file has changed

def init(path):
    # evaluate the config file location from param path 
    if not lastTimeStamp or configIsNewer():
         # need to parse
         # parsing
         lastTimeStamp = getTimeStamp()

# usage in a script:
import commons
commons.init(getBundlePath())

This would even work, if you use a plain commons.py as long as the
config files are stored with some fixed relative position to the running
sikuli script.

# possible folder structure
running_script.sikuli
common.py # is found automagically with import common
config_files/
    config_file1
    ....

You might of course use classes, but besides raising complexity, it does
not deliver any additional options to your current module approach.

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