Re: Finding where to store application data portably
On Thu, 22 Sep 2005 19:09:28 +0400, en.karpachov wrote: There is an other way around: look at your home dir as if it is your settings dir and don't clutter it with files other than application config dot-files. Just make ~/files/, ~/bin/ ~/lib/ etc. for it. Do you put everything into /etc (/etc/bin, /etc/var, /etc/usr, /etc/mnt, and so forth)? If your home directory is for settings, why would you store files and binaries inside your settings directory? I understand the historical reasons for why ~/ is treated as a structureless grab-bag of everything and anything. That made sense back in the distant past when users used dumb terminals and they had perhaps half a dozen dot files. But at the point your home directory has three times as many dot files as regular files, the time has come to stop doing things just because that's the way they have always been done. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Steven D'Aprano wrote: On Thu, 22 Sep 2005 19:09:28 +0400, en.karpachov wrote: There is an other way around: look at your home dir as if it is your settings dir and don't clutter it with files other than application config dot-files. Just make ~/files/, ~/bin/ ~/lib/ etc. for it. Do you put everything into /etc (/etc/bin, /etc/var, /etc/usr, /etc/mnt, and so forth)? If your home directory is for settings, why would you store files and binaries inside your settings directory? I understand the historical reasons for why ~/ is treated as a structureless grab-bag of everything and anything. That made sense back in the distant past when users used dumb terminals and they had perhaps half a dozen dot files. But at the point your home directory has three times as many dot files as regular files, the time has come to stop doing things just because that's the way they have always been done. Yes, it's all pretty much historical isn't it. Someones needs to start form scratch I think as far as file storage systems go. Personally I'd love a cross platform intelligent file storage device that managed security and user accounts independent of the operating system. (With it's own internal CPU and firmware.) A few thoughts ... It should be built on concepts of 'Responsibility', 'Authority', and 'Delegation', So you could call it.. RADOS or RAD for short, or just use my initials. RA.. (just kidding) ;-) Also note that an application is just another user by proxy. And it all comes down to private and shared user data. In other words, organize all files by who's Responsible for them. You would Delegate Authority by using file links with private keys in them. Giving a file link to someone else wouldn't work since it would need to be ran from your user account to be valid. These file links is how you would access other files in other users file space. Anyway... such a system would mean that when an application accesses the Internet, (has Authority), to update it's own files, (Responsibility), it does so in it's own user space and can't access any other users (or applications) files. Virus's would find this very limiting. Every user account would be a complete unit which can be backed up and restored independently of the OS. If something went wrong you could always find out which user (or application developer) was responsible. Anyway... just wishful thinking. I'm sure there are a lot of problems that would need to be worked out. ;-) Cheers, Ron Adam -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
On Thu, 22 Sep 2005 02:14:57 +, Ron Adam wrote: Don't all file managers have an option to hide files beginning with '.'? I don't want to hide them. I just don't want them in my face when I open my home directory. +1 This has been a gripe of mine on windows as well, and hiding files (or extensions) is definitely not the answer. Personally I think hidden files do more harm than good. It's not a substitute for good file management, and it not an acceptable alternative to good security either. Agreed. If hidden files are under the control of the user, then they aren't really hidden, they are merely filtered from the current view. Filtering may be useful in many circumstances, but if you are filtering the same files all the time (eg don't show me files starting with a period or don't show me files with the invisible flag set) then you should stick them in a subdirectory. And if hidden files aren't under the control of the user (as certain obscure ways of hiding files under Windows aren't), then it is a serious security risk. You, the user might not be able to hide the files, but you can bet some virus will. Eg if you drop an executable file in the Windows XP font directory, it will not show up in the file explorer. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Ron Adam wrote: Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. There are plenty of messages in the archives for this group about how to find the correct location in Windows, but what about Mac OS? There I don't know the correct location for this sort of thing at all. And there are other, more obscure systems like RISC OS (it may not have pygame but it definitely has python). Surely this is something that's crying out for an official function in os or sys. This works on Win XP. Not sure if it will work on Linux. import os parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0] file = parent + os.sep + '.bombz' Ooh, no, I don't want saved data to go in the installation directory. In general that practice encourages people to run with Admin access, and it's about time Windows users were discouraged from that. -- The address in the Reply-To is genuine and should not be edited. See http://www.realh.co.uk/contact.html for more reliable contact addresses. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Ron Adam wrote: Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. There are plenty of messages in the archives for this group about how to find the correct location in Windows, but what about Mac OS? There I don't know the correct location for this sort of thing at all. And there are other, more obscure systems like RISC OS (it may not have pygame but it definitely has python). Surely this is something that's crying out for an official function in os or sys. This works on Win XP. Not sure if it will work on Linux. import os parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0] file = parent + os.sep + '.bombz' Cheers, Ron Since you've gone to the trouble to use os.path functions why not use file = os.path.join(parent, 'bombz') regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.pycon.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
On Tue, 2005-09-20 at 23:03 +0100, Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. There are plenty of messages in the archives for this group about how to find the correct location in Windows, but what about Mac OS? ~/.bombz works equally well on OSX. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
rbt [EMAIL PROTECTED] writes: On Tue, 2005-09-20 at 23:03 +0100, Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. There are plenty of messages in the archives for this group about how to find the correct location in Windows, but what about Mac OS? ~/.bombz works equally well on OSX. But Mac users - as opposed to Unix geeks - will expect to find it in ~/Library/Application Support/Bombz. Us unix geeks can symlink that to ~/.bombz if we use the application on both platforms. mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
On Thu, 22 Sep 2005 00:23:56 +1000 Steven D'Aprano wrote: I wish the Linux Standard Base folks would specify that settings files should all go into a subdirectory like ~/settings rather than filling up the home directory with cruft. That was acceptable in the days when people only looked at their files with ls, but in these days of GUI file managers, it is ridiculous that there are more than 100 dot files and directories in my home directory. So it is the very rationale why dot-files historically considered as hidden in all unix shells and filemanagers. tilting at windmills Can I ask developers to break with the obsolete and annoying habit of creating user-specific config files as ~/.app-name and use ~/settings/app-name instead? /tilting at windmills There is an other way around: look at your home dir as if it is your settings dir and don't clutter it with files other than application config dot-files. Just make ~/files/, ~/bin/ ~/lib/ etc. for it. -- jk -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Steve Holden wrote: Ron Adam wrote: Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. There are plenty of messages in the archives for this group about how to find the correct location in Windows, but what about Mac OS? There I don't know the correct location for this sort of thing at all. And there are other, more obscure systems like RISC OS (it may not have pygame but it definitely has python). Surely this is something that's crying out for an official function in os or sys. This works on Win XP. Not sure if it will work on Linux. import os parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0] file = parent + os.sep + '.bombz' Cheers, Ron Since you've gone to the trouble to use os.path functions why not use file = os.path.join(parent, 'bombz') It just didn't come to mind first. I don't use os.path that often. Thanks. :-) regards Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Tony Houghton wrote: This works on Win XP. Not sure if it will work on Linux. import os parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0] file = parent + os.sep + '.bombz' Ooh, no, I don't want saved data to go in the installation directory. In general that practice encourages people to run with Admin access, and it's about time Windows users were discouraged from that. Yes, it occurred to me you didn't want to do that after I posted. Looks like maybe the correct place would be as you suggested, but maybe doing it this way would be better. import os user = os.path.join( os.environ[USERPROFILE], 'Application Data', 'Bombz' ) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
In [EMAIL PROTECTED], Ron Adam [EMAIL PROTECTED] wrote: Tony Houghton wrote: This works on Win XP. Not sure if it will work on Linux. import os parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0] file = parent + os.sep + '.bombz' Ooh, no, I don't want saved data to go in the installation directory. In general that practice encourages people to run with Admin access, and it's about time Windows users were discouraged from that. Yes, it occurred to me you didn't want to do that after I posted. Looks like maybe the correct place would be as you suggested, but maybe doing it this way would be better. import os user = os.path.join( os.environ[USERPROFILE], 'Application Data', 'Bombz' ) I like that, it's nice and simple. It doesn't look like it's supported on Win 9x though, but on 9x using the installation directory would be acceptable. -- The address in the Reply-To is genuine and should not be edited. See http://www.realh.co.uk/contact.html for more reliable contact addresses. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
On Tue, 20 Sep 2005 23:03:52 +0100, Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. In Windows, you shouldn't hard-code the drive letter. I don't know how you find out what the correct value is, but hard-coding it is just Bad. As a Linux user, I really am sick of every damn application, script and program under the sun filling the top level of my home directory with dot-files. I wish the Linux Standard Base folks would specify that settings files should all go into a subdirectory like ~/settings rather than filling up the home directory with cruft. That was acceptable in the days when people only looked at their files with ls, but in these days of GUI file managers, it is ridiculous that there are more than 100 dot files and directories in my home directory. tilting at windmills Can I ask developers to break with the obsolete and annoying habit of creating user-specific config files as ~/.app-name and use ~/settings/app-name instead? /tilting at windmills -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Steven D'Aprano wrote: On Tue, 20 Sep 2005 23:03:52 +0100, Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. In Windows, you shouldn't hard-code the drive letter. I don't know how you find out what the correct value is, but hard-coding it is just Bad. As a Linux user, I really am sick of every damn application, script and program under the sun filling the top level of my home directory with dot-files. I wish the Linux Standard Base folks would specify that settings files should all go into a subdirectory like ~/settings rather than filling up the home directory with cruft. That was acceptable in the days when people only looked at their files with ls, but in these days of GUI file managers, it is ridiculous that there are more than 100 dot files and directories in my home directory. tilting at windmills Can I ask developers to break with the obsolete and annoying habit of creating user-specific config files as ~/.app-name and use ~/settings/app-name instead? /tilting at windmills While we're asking for the improbable, perhaps we could make that ~/.settings/app-name Ssh has used the ~/.ssh directory for a long time to avoid the need for lots of little dot files, and this works quite well. Good luck in your campaign! regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.pycon.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Steven D'Aprano wrote: As a Linux user, I really am sick of every damn application, script and program under the sun filling the top level of my home directory with dot-files. I wish the Linux Standard Base folks would specify that settings files should all go into a subdirectory like ~/settings rather than filling up the home directory with cruft. That was acceptable in the days when people only looked at their files with ls, but in these days of GUI file managers, it is ridiculous that there are more than 100 dot files and directories in my home directory. What difference does it make whether one is using a GUI or a command line? Anyway, the vast majority of Unix users I know still use ls a lot more often than GUI-based file managers. I prefer to keep my settings in ~/etc, as a sort of intuitive parallel to the Filesystem Hierarchy Standard. tilting at windmills Can I ask developers to break with the obsolete and annoying habit of creating user-specific config files as ~/.app-name and use ~/settings/app-name instead? /tilting at windmills Better: a user-specified $ETCDIR. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. In Windows, you shouldn't hard-code the drive letter. I don't know how you find out what the correct value is, but hard-coding it is just Bad. XP Pro seems to take print os.environ[APPDATA] C:\Documents and Settings\Dennis Lee Bieber\Application Data Though the more consistent might be to hit the registry: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\AppData and to confuse matters, there is also a Local AppData entry It isn't just the drive letter you shouldn't hardcode. In different locales the phrases Documents and Settings and Application Data are often different. The canonical way to get this dir on Windows is by using the SHGetFolderPath Windows API call with the CSIDL_APPDATA constant: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shgetfolderpath.asp In Python code that is: from win32com.shell import shellcon, shell path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) Unfortunately that either means having the PyWin32 extensions installed (which not all Python installations on Windows have) or building your own small binary extension to make that call. Failing that, using the registry location or the environment variable above might suffice Note that on some older Windows flavours -- not sure exactly which -- the APPDATA env. var. might not be defined. Also note that Windows app guidelines encourage you to have an additional vendor/owner directory level before the app name. So: %APPDATA%\company-or-vendor-name\Bombz I have a little working script that I use for this kind of stuff which you are welcome too, if it helps. (attached) Trent -- Trent Mick [EMAIL PROTECTED] # Copyright (c) 2005 ActiveState Corp. # License: MIT # Author: Trent Mick ([EMAIL PROTECTED]) Cross-platform application utilities: Utility Functions: user_data_dir(...) path to user-specific app data dir site_data_dir(...) path to all users shared app data dir #TODO: # - Add cross-platform versions of other abstracted dir locations, like # a cache dir, prefs dir, something like bundle/Contents/SharedSupport # on OS X, etc. # http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Concepts/UserPreferences.html # http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/enums/csidl.asp # import sys import os class Error(Exception): pass def user_data_dir(appname, owner=None, version=None): Return full path to the user-specific data dir for this application. appname is the name of application. owner (only required and used on Windows) is the name of the owner or distributing body for this application. Typically it is the owning company name. version is an optional version path element to append to the path. You might want to use this if you want multiple versions of your app to be able to run independently. If used, this would typically be major.minor. Typical user data directories are: Windows:C:\Documents and Settings\USER\Application Data\owner\appname Mac OS X: ~/Library/Application Support/appname Unix: ~/.lowercased-appname if sys.platform.startswith(win): # Try to make this a unicode path because SHGetFolderPath does # not return unicode strings when there is unicode data in the # path. if owner is None: raise Error(must specify 'owner' on Windows) from win32com.shell import shellcon, shell path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) try: path = unicode(path) except UnicodeError: pass path = os.path.join(path, owner, appname) elif sys.platform == 'darwin': from Carbon import Folder, Folders path = Folder.FSFindFolder(Folders.kUserDomain, Folders.kApplicationSupportFolderType, Folders.kDontCreateFolder) path = os.path.join(path.FSRefMakePath(), appname) else: path = os.path.expanduser(~/. + appname.lower()) if version: path = os.path.join(path, version) return path def site_data_dir(appname, owner=None, version=None): Return full path to the user-shared data dir for this application. appname is the name of application. owner (only required and used on Windows) is the name of the owner
Re: Finding where to store application data portably
Steven D'Aprano wrote: On Tue, 20 Sep 2005 23:03:52 +0100, Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. In Windows, you shouldn't hard-code the drive letter. I don't know how you find out what the correct value is, but hard-coding it is just Bad. That's why I said something like. It seems there is a definitive way of finding the correct value, but it needs extra W32 extensions installed. You could also start from os.path.expanduser('~') I suppose. As a Linux user, I really am sick of every damn application, script and program under the sun filling the top level of my home directory with dot-files. I wish the Linux Standard Base folks would specify that settings files should all go into a subdirectory like ~/settings rather than filling up the home directory with cruft. That was acceptable in the days when people only looked at their files with ls, but in these days of GUI file managers, it is ridiculous that there are more than 100 dot files and directories in my home directory. Don't all file managers have an option to hide files beginning with '.'? tilting at windmills Can I ask developers to break with the obsolete and annoying habit of creating user-specific config files as ~/.app-name and use ~/settings/app-name instead? /tilting at windmills You'll probably like the XDG basedir spec then: http://freedesktop.org/wiki/Standards_2fbasedir_2dspec I suppose I should really use that, but the trouble is it can be very difficult to decide whether some files are config or data, so it would be nice to have a standard that doesn't segregate the two. Thanks to everyone else who's replied. I've saved Trent Mick's script for later reference. -- The address in the Reply-To is genuine and should not be edited. See http://www.realh.co.uk/contact.html for more reliable contact addresses. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
On Wed, 21 Sep 2005 20:07:54 +0100, Tony Houghton wrote: I wish the Linux Standard Base folks would specify that settings files should all go into a subdirectory like ~/settings rather than filling up the home directory with cruft. That was acceptable in the days when people only looked at their files with ls, but in these days of GUI file managers, it is ridiculous that there are more than 100 dot files and directories in my home directory. Don't all file managers have an option to hide files beginning with '.'? I don't want to hide them. I just don't want them in my face when I open my home directory. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Steven D'Aprano wrote: On Wed, 21 Sep 2005 20:07:54 +0100, Tony Houghton wrote: I wish the Linux Standard Base folks would specify that settings files should all go into a subdirectory like ~/settings rather than filling up the home directory with cruft. That was acceptable in the days when people only looked at their files with ls, but in these days of GUI file managers, it is ridiculous that there are more than 100 dot files and directories in my home directory. Don't all file managers have an option to hide files beginning with '.'? I don't want to hide them. I just don't want them in my face when I open my home directory. +1 This has been a gripe of mine on windows as well, and hiding files (or extensions) is definitely not the answer. Personally I think hidden files do more harm than good. It's not a substitute for good file management, and it not an acceptable alternative to good security either. Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. There are plenty of messages in the archives for this group about how to find the correct location in Windows, but what about Mac OS? There I don't know the correct location for this sort of thing at all. And there are other, more obscure systems like RISC OS (it may not have pygame but it definitely has python). Surely this is something that's crying out for an official function in os or sys. This works on Win XP. Not sure if it will work on Linux. import os parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0] file = parent + os.sep + '.bombz' Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list
Finding where to store application data portably
I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. There are plenty of messages in the archives for this group about how to find the correct location in Windows, but what about Mac OS? There I don't know the correct location for this sort of thing at all. And there are other, more obscure systems like RISC OS (it may not have pygame but it definitely has python). Surely this is something that's crying out for an official function in os or sys. -- The address in the Reply-To is genuine and should not be edited. See http://www.realh.co.uk/contact.html for more reliable contact addresses. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. There are plenty of messages in the archives for this group about how to find the correct location in Windows, but what about Mac OS? There I don't know the correct location for this sort of thing at all. And there are other, more obscure systems like RISC OS (it may not have pygame but it definitely has python). Surely this is something that's crying out for an official function in os or sys. On OS X, the data should probably go to ~/Library/Application Support/Bombz/ -- Robert Kern [EMAIL PROTECTED] In the fields of hell where the grass grows high Are the graves of dreams allowed to die. -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding where to store application data portably
Tony Houghton wrote: I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use ~/.bombz, in Windows something like C:\Documents And Settings\user\Applicacation Data\Bombz. There are plenty of messages in the archives for this group about how to find the correct location in Windows, but what about Mac OS? There I don't know the correct location for this sort of thing at all. And there are other, more obscure systems like RISC OS (it may not have pygame but it definitely has python). Surely this is something that's crying out for an official function in os or sys. Perhaps using import user; user.home would be adequate. Note the documented side effects of doing that however. -Peter -- http://mail.python.org/mailman/listinfo/python-list