473,219 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,219 software developers and data experts.

How to save initial configuration? (program installation)

I've written a program. To install this program, I'm going to need to
initialize some stuff for the users environment, specifically the name/
location of an internal state file.

Currently, I'm hard coding the location of this file, but that's in-
elegant. What I'd like to do is just ask the user, with a suggested
default.

My question is how do I save this answer? It's kind of a chicken-and-
egg problem.

The only solution I've thought of is to write something that's self
modifying, but that's ugly (go in, grep for this variable
initialization, re-write that line with the new value, quit). Is
there a better way to do this? There almost has to be...

If not, are there some 'best practices' on how to do the self-
modification?

Thanks for any help;
Jason

Jun 25 '07 #1
6 1362
On Jun 25, 10:02 am, Jason Zapman II <zapman...@gmail.comwrote:
I've written a program. To install this program, I'm going to need to
initialize some stuff for the users environment, specifically the name/
location of an internal state file.

Currently, I'm hard coding the location of this file, but that's in-
elegant. What I'd like to do is just ask the user, with a suggested
default.

My question is how do I save this answer? It's kind of a chicken-and-
egg problem.

The only solution I've thought of is to write something that's self
modifying, but that's ugly (go in, grep for this variable
initialization, re-write that line with the new value, quit). Is
there a better way to do this? There almost has to be...

If not, are there some 'best practices' on how to do the self-
modification?

Thanks for any help;
Jason
I would think you could pop-up some dialog when the program is first
run to ask where they want the file to be. On the first run though,
you can just have the config file located in the current working
directory with the script file itself. Then just move it or save a new
copy to the new location and delete the original.

Mike

Jun 25 '07 #2
On Jun 25, 11:10 am, kyoso...@gmail.com wrote:
I would think you could pop-up some dialog when the program is first
run to ask where they want the file to be. On the first run though,
you can just have the config file located in the current working
directory with the script file itself. Then just move it or save a new
copy to the new location and delete the original.
The 'pop-up' is easy. The problem is how does the program know where
it's state file is the SECOND time it is run? I can't stash it in the
state file, since the program won't know where it is if it's not in
the CWD... (unless I'm missing something obvious).
Jun 25 '07 #3
ky******@gmail.com wrote:
On Jun 25, 10:02 am, Jason Zapman II <zapman...@gmail.comwrote:
>I've written a program. To install this program, I'm going to need to
initialize some stuff for the users environment, specifically the name/
location of an internal state file.

Currently, I'm hard coding the location of this file, but that's in-
elegant. What I'd like to do is just ask the user, with a suggested
default.

My question is how do I save this answer? It's kind of a chicken-and-
egg problem.

The only solution I've thought of is to write something that's self
modifying, but that's ugly (go in, grep for this variable
initialization, re-write that line with the new value, quit). Is
there a better way to do this? There almost has to be...

If not, are there some 'best practices' on how to do the self-
modification?

Thanks for any help;
Jason

I would think you could pop-up some dialog when the program is first
run to ask where they want the file to be. On the first run though,
you can just have the config file located in the current working
directory with the script file itself. Then just move it or save a new
copy to the new location and delete the original.

Mike
Or, better still, leave it in place to act as the defaults for the next
user who wants to start using this package?

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Jun 25 '07 #4
Jason Zapman II wrote:
On Jun 25, 11:10 am, kyoso...@gmail.com wrote:
>I would think you could pop-up some dialog when the program is first
run to ask where they want the file to be. On the first run though,
you can just have the config file located in the current working
directory with the script file itself. Then just move it or save a new
copy to the new location and delete the original.

The 'pop-up' is easy. The problem is how does the program know where
it's state file is the SECOND time it is run? I can't stash it in the
state file, since the program won't know where it is if it's not in
the CWD... (unless I'm missing something obvious).

The traditional choices are the registry for Windows, and the /etc
subtree for the various, almost uncountable, flavors of Unix and
nixalikes. You're right, it's much more difficult per-system than
per-user, since there are so many conventions.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Jun 25 '07 #5
On Jun 25, 11:37 am, Steve Holden <s...@holdenweb.comwrote:
The traditional choices are the registry for Windows, and the /etc
subtree for the various, almost uncountable, flavors of Unix and
nixalikes. You're right, it's much more difficult per-system than
per-user, since there are so many conventions.
I forgot to mention that this is for Unix environments, so the
registry isn't an option, unfortunately (never thought I'd say
that... ;-) ).

Is there anything in the distutils.* stuff that would be useful? This
isn't going to be a python package (it's a standalone program).

--Jason

Jun 25 '07 #6
On Jun 25, 10:58 am, Jason Zapman II <zapman...@gmail.comwrote:
On Jun 25, 11:37 am, Steve Holden <s...@holdenweb.comwrote:
The traditional choices are the registry for Windows, and the /etc
subtree for the various, almost uncountable, flavors of Unix and
nixalikes. You're right, it's much more difficult per-system than
per-user, since there are so many conventions.

I forgot to mention that this is for Unix environments, so the
registry isn't an option, unfortunately (never thought I'd say
that... ;-) ).

Is there anything in the distutils.* stuff that would be useful? This
isn't going to be a python package (it's a standalone program).

--Jason
Well, I don't know what your user file does, but couldn't you create
a .ini type file to hold the user's choice for the other file's
location and save the ini to the current working directory?

Something like this:

<ini file>
usersChosenPath = /usr/Path/to/Config
</ini file>

Kind of redundant, but I would think it would still work.

Mike

Jun 25 '07 #7

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

Similar topics

1
by: ulloa | last post by:
Hi. My name is Randall and I am from Costa Rica. I have a little problem. I did an application using Perl, DBI and DBI::Oracle, and now I have to upload my application in an Unix server. The...
3
by: Harry | last post by:
Using Oracle 8i enterprise on win 2000 (sp3) Installed the standard configuration & whenever I make a connection it takes about 10 secs. It's running on a P1900 with 1gb Ram so no reason there...
1
by: Roeland Kok | last post by:
Hello, I'm making a setup project for a Windows Installer, to update my application. The application has a configuration file (app.config) that is renamed after the build. I would like to not...
4
by: Jessard | last post by:
Hi Guys and Girls, I have a situation where I am wishing to deploy a .NET dll onto a number of servers. The classes in the DLL will be used by VBScripts. When one of the classes - Connection -...
6
by: nek | last post by:
Greetings, Platform is DB2 V8.1, FP2 on W2K. Has anyone succeeded in invoking 'Configuration Advisor' from Control Center with DB2 running on W2K? I tried but failed with SQL22205C if it...
2
by: serge | last post by:
Do I have to use the DB2 Configuration Assistant in order to create an ODBC System DSN? I had a windows computer with no IBM DB2 installed. I downloaded the IBM DB2 client i think which after...
2
by: Dave | last post by:
I'm sure this must be really simple but I can't find it. I have a setup/deployment project and I want to include a particular program (ie. a primary output) in the debug configuration but not in...
9
by: KarlM | last post by:
After reading some articles regarding confuguration data I'm a bit confused. Where is the right place for storing configuration data? - XML-files? - registry? - INI-files? (from a users point...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi, thanks, mister The code string rutaConfig = tbRutaConfigServicioBase.Text; '// Map to the application configuration file. ExeConfigurationFileMap configFile = New...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.