How to pass data to a file while Package installation on mac

自古美人都是妖i 提交于 2019-12-11 13:19:07

问题


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:


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/



来源:https://stackoverflow.com/questions/19893324/how-to-pass-data-to-a-file-while-package-installation-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!