Curious problem while opening app using ini file

Asked by Shafiq Khan

config.ini content:
;========================
[AppPath]
Path = "C:\\Program Files\\myAwesomeApp\\myAwesomeApp.exe"
;========================

Script content:
#==================================================
myApp = "My Awesome App"

def FunAppPath():
    config = ConfigParser.ConfigParser()
    myFilePath = os.path.join(getBundlePath(),'config.ini')
    with open(myFilePath,'r') as configfile:
        config.readfp(configfile)
        myAppPath = config.get('AppPath','Path')
    return myAppPath

def appLaunch():
    if not myApp.window():
        App.open(FunAppPath())

appLaunch()
#==================================================

For some reason this is copying various files from "C:\\Program Files\\myAwesomeApp\\" into the script folder. No idea why.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

no idea, you either have to ask the with statement or the configparser ;-)

I do not see the need for the with nor for the intermediates:

  config.readfp(open(os.path.join(getBundlePath(),'config.ini')))
  myAppPath = config.get('AppPath','Path')

I generally distrust the with statement ;-)

Can you help with this problem?

Provide an answer of your own, or ask Shafiq Khan for more information if necessary.

To post a message you must log in.