[Pythonmac-SIG] retrieving config values from the System Preferences
Nicholas Riley
njriley at uiuc.edu
Tue Jun 7 17:06:41 CEST 2005
On Tue, Jun 07, 2005 at 02:54:12PM +0200, Antoine Pitrou wrote:
> I'm porting an app to Mac OS X and I need to retrieve the configuration
> values entered in the System Preferences (specifically the HTTP proxy
> settings). I already know how to do that under Gnome and Windows, but I
> haven't found how to retrieve those values under Mac OS X (Panther, by
> the way). Is there a reliable way to do that ?
Generic information is here:
<http://developer.apple.com/qa/qa2001/qa1234.html>
Bob Ippolito wrote a PyObjC-based wrapper for the SystemConfiguration
framework, which makes this very simple to do in Python:
>>> from SystemConfiguration import UNSystemConfigurationDynamicStore
>>> store = UNSystemConfigurationDynamicStore.alloc().initWithName_('foo')
>>> print store.proxies()
{
AppleProxyConfigurationSelected = 2;
ExcludeSimpleHostnames = 0;
FTPPassive = 1;
ProxyAutoDiscoveryEnable = 0;
}
If I enable a proxy, I get:
>>> print store.proxies()
{
AppleProxyConfigurationSelected = 2;
ExcludeSimpleHostnames = 0;
FTPPassive = 1;
HTTPEnable = 1;
HTTPPort = 80;
HTTPProxy = "127.0.0.1";
ProxyAutoDiscoveryEnable = 0;
}
You can download the wrapper from:
<http://undefined.org/python/SystemConfiguration-0.3.tar.gz>
--
Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
More information about the Pythonmac-SIG
mailing list