views:

91

answers:

0

Hi

I am making a jython application that needs a config/settings file (and probably eventually directory) but I want it be stored in the expected/correct directory for each os.

~/.app_name/config in linux

c:/documents and Settings/User/app_name ?? in windows.

I have found this:

http://snipplr.com/view/7354/home-directory-crossos/

but this is for python and I have feeling that this might not necessary work for jython/windows and I don't have any dev stuff set up in my windows VM to test at this moment

If someone could provide any insight into the "best practices" (for jython) for achieving this I would greatly appreciate it.

Thanks.

EDIT:

Here is what I have come up with that seems to be working...I would appreciate any feedback

import os
from java.lang import System
from java.io import File
os_name =  System.getProperty('os.name')
os_sep = File.separator
app_name = 'ctrlmac'
if os_name == 'Windows':
    config_dir = os.environ["APPDATA"] + os_sep + app_name
else:
    config_dir = os.path.expanduser("~") + os_sep + '.' + app_name
print config_dir