473,797 Members | 2,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

where should config files go in Windows?

I'm writing a cross-platform app. Presently it runs on unix and MacOS X,
but eventually I'd like to get it working on Windows (nothing older than
2000).

For unix and MacOS X I store settings in ~/.TUIPrefs and ~/.TUIGeom and
allow extensions to be stored in ~/TUIAdditions/ and <app's parent
dir>/TUIAdditions/.

Is the home dir easily accessible from vanilla Python (and if so, how do
I get there)? Is there a better directory (I'm really not keen to mess
with the registry) or some special add-on library that I'll need?

Also, is there something simple like unix's leading "." that makes
Windows files invisible?

Any help appreciated. I tried google and found this topic discussed
several years ago, but the answers were confusing and didn't seem to
apply to current Windows.

-- Russell
Jul 18 '05 #1
4 1724
Russell E. Owen wrote:
....
For unix and MacOS X I store settings in ~/.TUIPrefs and ~/.TUIGeom and
allow extensions to be stored in ~/TUIAdditions/ and <app's parent
dir>/TUIAdditions/.

Is the home dir easily accessible from vanilla Python (and if so, how do
I get there)? Is there a better directory (I'm really not keen to mess
with the registry) or some special add-on library that I'll need?

There are actually multiple directories for this kind of thing,
depending on whether you're describing user's documents,
application-specific data for the user (e.g. custom dictionaries),
common application-specific data (app-specific system dictionaries),
etceteras. You can see an example of retrieving the user's
application-specific data directory here:

http://cvs.sourceforge.net/viewcvs.p...py?view=markup

using either of _winreg (standard module) or win32com's shell (common
add-on, part of win32all).

See the MSDN documentation for the various folders which are defined.

http://msdn.microsoft.com/library/de...folderpath.asp
Also, is there something simple like unix's leading "." that makes
Windows files invisible?

Haven't tried to do this myself. But then I hate "hidden" files enough
to simply disable hiding them in the explorer, so who knows, maybe I
hide them all the time :) . On windows it's more common to just put the
file in the correct directory, where they are "out of the way", instead
of dumping them into a "home" directory and hiding them.

Good luck,
Mike

_______________ _______________ _________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/

Jul 18 '05 #2
I use the following for multi-platform home directories in my own
project http://pype.sourceforge.net

I've had no complaints from people using *nix or Windows. I haven't
heard of any users on macs yet, so have no comment.

- Josiah
default_homedir = os.path.dirname (os.path.abspat h(__file__))
dotpath = '.application_n ame'

try:
#all user-based OSes
thd = os.path.expandu ser("~")
if thd == "~": raise
homedir = os.path.join(th d, dotpath)
except:
try:
#*nix fallback
homedir = os.path.join(os .environ['HOME'], dotpath)
except:
try:
#windows NT,2k,XP,etc. fallback
homedir = os.path.join(os .environ['USERPROFILE'], dotpath)
except:
#What os are people using?
homedir = os.path.join(de fault_homedir, dotpath)
try:
# create the config directory if it
# doesn't already exist
def expandfull(var, rem=3):
if not rem:
return os.path.expandv ars(var)
a = os.path.expandv ars(var)
b = []
d = [b.extend(i.spli t('\\')) for i in a.split('/')]
c = []
for i in b:
if '%' in i:
c.append(expand full(i, rem-1))
else:
c.append(i)
return '\\'.join(c)
if eol == "\r\n" and '%' in homedir:
homedir = expandfull(home dir)
if not os.path.exists( homedir):
os.mkdir(homedi r)
except:
#print "unable to create config directory", homedir
homedir = default_homedir
Jul 18 '05 #3
In article <ma************ *************** ************@py thon.org>,
"Mike C. Fletcher" <mc******@roger s.com> wrote:
Russell E. Owen wrote:
...
(essentiall y I asked where prefs and application-specific data go on Windows)

There are actually multiple directories for this kind of thing,
depending on whether you're describing user's documents,
application-specific data for the user (e.g. custom dictionaries),
common application-specific data (app-specific system dictionaries),
etceteras. You can see an example of retrieving the user's
application-specific data directory here:

http://cvs.sourceforge.net/viewcvs.p...ser/homedirect
ory.py?view=ma rkup

using either of _winreg (standard module) or win32com's shell (common
add-on, part of win32all).

See the MSDN documentation for the various folders which are defined.

http://msdn.microsoft.com/library/de...shellcc/platfo
rm/shell/reference/functions/shgetfolderpath .asp


Thank you very much! That's just what I wanted. I'll put preferences
<AppData>\TUIPr efs, optional user additions in <AppData>\TUIAd ditions
and optional shared additions in <Common_AppData >\TUIAddition s. There
are equivalent standard directories on MacOS X (easily found; code
available on request). For unix I'll use ~/.TUIPrefs, ~/TUIAdditions and
(for lack of a better place), shared additions in
<tui_root>/TUIAdditions, where <tui_root> is the folder containing the
app's code.

-- Russell
Jul 18 '05 #4
> >See the MSDN documentation for the various folders which are defined.

http://msdn.microsoft.com/library/de...-us/shellcc/pl

atform/shell/reference/functions/shgetfolderpath .asp
Thank you very much! That's just what I wanted. I'll put preferences
<AppData>\TUIPr efs, optional user additions in <AppData>\TUIAd ditions
and optional shared additions in <Common_AppData >\TUIAddition s.


I'd like to suggest creating only a single folder under Application Data,
with additional folders inside it for your specific needs. The usual
convention is to create a folder with your company name, then additional
folders inside that for each product, and finally folders inside those for
things like your TUIPrefs and TUIAdditions.

Also, make careful note of the difference between Application Data and Local
Settings\Applic ation Data. On most machines, it doesn't matter which of
those you use. But if someone uses "roaming profiles", then you need to
choose which of those folders to use. Application Data is part of the
roaming profile, and it gets copied from a server when the user logs in, and
back to the server when the user logs out. Local Settings\Applic ation Data
resides strictly on the local machine.

-Mike
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3831
by: Fuzzyman | last post by:
There have been a couple of config file 'systems' announced recently, that focus on building more powerful and complex configuration files. ConfigObj is a module to enable you to much more *simply* access config files. This is version 3, which is a big overhaul. It extends ConfigObj to reading config files with sections and various other simplifications. I find ConfigObj extremely easy to use and use it for reading config files and data...
3
20902
by: Peter Blum | last post by:
I have built an assembly (dll) from which I expect third parties to subclass. As a result, when my assembly has a version change, it will cause any third party assembly based on it to break unless I establish a Publisher Policy file. So I have that. I have built a Windows app for the same product. This app prompts the user for a path to a third party assembly that depends on my assembly. It opens the third party assembly (Assembly.Load)...
3
6569
by: Geoff Pennington | last post by:
It is really pathetic that I don't know this, but here it is. I have been writing ASP.Net apps for a while, and all configuration information, such as the database connection string, goes in a text file called Web.config. There, it is accessible to the entire app and can be changed without recompiling anything. Now I am writing a Windows app (using VB.Net). This type of project does not have a Web.config file (of course) so where do I...
5
4515
by: Guadala Harry | last post by:
What are my options for *securely* storing/retrieving the ID and password used by an ASP.NET application for accessing a SQL Server (using SQL Server authentication)? Please note that this ID and password would be different than the one the user enters for ASP.NET forms authentication. The ID/password in question is used by the application, itself, for accessing the SQL Server. Thanks in advance.
2
2657
by: Anna | last post by:
I added a small Web.Config file to the root of my website so that I could view errors on a machine other than the server: <configuration> <system.web> <customErrors mode="Off" /> </system.web> </configuration> However, this immediately threw a different error when I tried to view
4
3038
by: Henke | last post by:
Hi I'm building an globalized application (english, swedish and russian languages) and have a few questions: 1. In order to see the russian characters correct I have to set the requestEncoding and responseEncoding to windows-1251. Is this correct? 2. Now I set the requestEncoding and responseEncoding in the web.config file, but since I only have one web.config it only works for either english and swedish (utf-8 encoding) or just russian...
1
1809
by: herbert | last post by:
In VS.2005 a Windows Service can have an app.config file. A class library can also have an app.config file. Now if my Windows Services uses three class libraries, each of it coming with its own app.config file, in which sequence are the app config files read in? eg What happens if there are trace switches of the same name with different values in those files? Or a the config files local to a VS project/assembly ? If so, they should not...
10
7601
by: =?Utf-8?B?U3RlZmFuIEJhcmxvdw==?= | last post by:
This has been working perfectly for months. Since we switched from ASP.NET 1.1 to 2.0, we have constant and sporadic issues with updating our applications. Touching the web.config works about 40% of the time to cause an AppDomain to reload and flush all assemblies. Sometimes it works perfectly, but other times some Assemblies are not reloaded into the AppDomain, even after multiple web.config file touches. Sometimes multiple versions...
21
213
by: Nick Craig-Wood | last post by:
Lance Gamet <lance@gamet.comwrote: I've found http://docs.python.org/lib/module-ConfigParser.html To be easy to use and built in. It makes human readable / editable ..ini - like files. As for where to store it, I use os.path.expanduser("~") to find the
1
4848
by: =?Utf-8?B?VGVycnk=?= | last post by:
I am using the My.Settings object to save user settings. During testing, I want to 'zero' out what has been saved to start with the defaults again. Where doies the framwork actually persist these user settings? TIA, -- Terry
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10468
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4131
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.