在Mac上进行软件包安装时如何将数据传递到文件 [英] How to pass data to a file while Package installation on mac

查看:123
本文介绍了在Mac上进行软件包安装时如何将数据传递到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用python开发一个应用程序.在Mac OS X 10.8.5上使用python 2.7.我使用py2app将python代码转换为应用程序.然后,我使用Packages将myapp.app转换为包myapp.pkg. 我正在使用保存在目录->资源-> config.cfg中的配置文件. config.cfg文件包含运行应用程序所需的数据.

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.我的config.cfg文件就像键值对.我正在使用config.parsar读取config.cfg文件.

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 = 

我在安装软件包时需要将这些值传递给config.cfg文件.安装程序应询问这些值,用户应输入这些值.

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.

推荐答案

一种可能的解决方案是编写一个packagemaker plugin,它将向用户询问这些详细信息,然后将其保存到某个文件中.然后,在安装过程中,可以从安装后脚本读取此文件并修改配置文件.

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.

但是,将此类配置文件保留在应用程序文件中是个坏主意.此类文件的更好位置是~/Library/Preferences~/Library/Application Support.

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.

用于创建packagemaker插件的教程:(需要可可知识) http://www.mactech.com/articles/mactech /Vol.25/25.06/InstallerPlugins/index.html http://s.sudre.free.fr/Stuff/Installer/Installer_Plugins/

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/

这篇关于在Mac上进行软件包安装时如何将数据传递到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆