How to pass data to a file while Package installat

2019-07-28 04:41发布

I am making an app in python. Using python 2.7 on mac osx 10.8.5. I converted python code into an app using py2app. Then I converted myapp.app into package myapp.pkg using Packages. I am using a configuration file which I kept in Contents-->Resources-->config.cfg. config.cfg file contains data which is necessary for running of app.

My issue is how to pass serverIP and serverPort to config.cfg file while installing myapp through myapp.pkg i.e. through Packages. My config.cfg file is like key-value pair.I am using config.parsar to read config.cfg file.

[KMS]
serverIP1 = 
serverPort1 =
serverIP2 =
serverPort2 = 

I need to pass these value to config.cfg file while installing package.The installer should ask these values and the user should input these values.

1条回答
戒情不戒烟
2楼-- · 2019-07-28 05:20

A possible solution would be to write a packagemaker plugin that will ask these details from the user and then save it to some file. Then during installation, from a post-install script, you can read this file and modify your config file.

However, it is bad idea to keep such config files inside the app file. A better place for such files is ~/Library/Preferences or ~/Library/Application Support.

Tutorials for creating packagemaker plugin: (Requires Cocoa knowledge) http://www.mactech.com/articles/mactech/Vol.25/25.06/InstallerPlugins/index.html http://s.sudre.free.fr/Stuff/Installer/Installer_Plugins/

查看更多
登录 后发表回答