I'm creating an app that relies on a configuration file at launch. The file
will always exist in the app's installation directory, but I have no control
over where that might be.
Is there an OS-independent way that I can instruct the app to look in it's
home directory for startup files? Right now, I'm hard coding the path, which
won't work.
Thanks,
Jeff
Jul 19 '05
12 1375
On 2005-05-11, jeff elkins <je********@ear thlink.net> wrote: I'm totally new to Python (obvious,yes?) so how might argv[0] fail?
argv[0] contains whatever is put there by the program that
exec'ed you, and can therefore contain just about anything (or
nothing). It may not contain a full path, and your program's
install directory may not be in your $PATH (it be executed by a
shortcut or symlink).
If you're controlling how the program is installed and started,
then you're probably safe.
--
Grant Edwards grante Yow! I guess it was all a
at DREAM... or an episode of
visi.com HAWAII FIVE-O...
On Thu, 12 May 2005 00:24:55 -0500, Mike Meyer <mw*@mired.or g> declaimed
the following in comp.lang.pytho n: Yes, but Windows these days supports multiple users. Are you sure that you want to restrict your users to one configuration file per installed version of the program?
Even worse -- I've got a few applications that won't even run
from a "user account" because XP "protects" the normal "program files"
install directory, and the application tries to open/update the
configuration files.
-- =============== =============== =============== =============== == < wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG < wu******@dm.net | Bestiaria Support Staff < =============== =============== =============== =============== == < Home Page: <http://www.dm.net/~wulfraed/> < Overflow Page: <http://wlfraed.home.ne tcom.com/> <
Grant Edwards <gr****@visi.co m> writes: On 2005-05-11, jeff elkins <je********@ear thlink.net> wrote:
I'm totally new to Python (obvious,yes?) so how might argv[0] fail?
argv[0] contains whatever is put there by the program that exec'ed you, and can therefore contain just about anything (or nothing). It may not contain a full path, and your program's install directory may not be in your $PATH (it be executed by a shortcut or symlink).
That's true for the C-level, i.e. main's argv. If you're only concerned
about CPython and the program is a script living in a file, then
sys.argv[0] is the filename the python interpreter itself used to read
the script. Hence it's a valid filename that refers to the script. It
may be a relative filename, of course, in which case it won't be correct
anymore if the program changes its working directory.
Bernhard
--
Intevation GmbH http://intevation.de/
Skencil http://skencil.org/
Thuban http://thuban.intevation.org/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Neil Benn |
last post by:
Hello,
I'm looking at a small app which would need a very quick
startup time for the Python interpreter. It doesn't do much (copying
and caching of files, no GUI) but I need the Python interpreter to start
up very quickly (<1 second on a Windows box). Is there a way to have a
'stripped' down Python interpreter which can start up very quickly on a
windows box. Once thing I was thinking of was to use PyExe to make a
quick startup (does...
|
by: Andrew Wrigley |
last post by:
Hi
Is there any way to walk thru memory to find a variable that holds a
reference to a recordset that has been left open? (I use ADO for my
recordsets.)
The reason I want this info:
I am writing code to compact back end files.
|
by: Douglas Buchanan |
last post by:
Buttons don't work if form is opened on startup
A2k
If 'frmMain' is set to open by default at startup none of the buttons
work.
If 'frmMain' is opened from the database window then all the buttons
work.
The form's name ('frmMain') is selected from in the Startup dialog
box.
|
by: David |
last post by:
Hi,
Would someone please mind showing me how to obtain the absolute
path to a folder that is created under the application folder at install
time.
ie. On my development machine the path is
C:\engineering\development\software\BMSLITE\bin\Database
On the target machine it may be c:\program files\orbit\bmslite\database
|
by: Larry |
last post by:
I have a Perl script using DBD::DB2, that runs during system startup on
a Solaris system. The script is working fine during startup on many
machines, except on one machine it fails complaining about a missing
".so" file, with Perl flagging the "use DBD::DB2" line. (I don't have
the exact message since I'm heard about it from a remote sysadmin who
only saw it scroll by on the console). However, if I login as root on
that machine and run...
| |
by: chinkuang |
last post by:
Hi Everyone:
I have a question here: I used a startup object to protect my
application - whenever PC starts up, I will check the setting of my
application like registry, program files and so on, if they have been
tampered then I will restore the original settings from the backup
files I store in some hidden place.
However now a guy said he has a tool that able to modify the Windows XP
registry without even login to window - that means...
|
by: e'kong.tse |
last post by:
Hi All,
I'm trying to use C# to open up an Excel file that has a bunch of
dependent files. Inside Excel, you can specify the startup files in
Tools->Options->General Tab. My excel file has a reference to an .XLA
file and links to 2 .XLS files. However, when I use C# to open up my
excel file, only the .XLA file got open up but the 2 .XLS files didn't.
So now I've a lot of #VALUE and #NAME errors in my excel file. Can
anyone help me...
|
by: rdemyan via AccessMonster.com |
last post by:
I'm having a complicated linking problem. Before I get into the particulars,
I'd like to know how Access links to the back-end file at startup, AFTER I've
distributed my application to the client.
Here's the issue. While I'm working on my app, I'm linked to the backend on
my computer. When I distribute the app, the backend file is obviously in a
different location (on the client server).
But the first time my app is started up at...
|
by: =?Utf-8?B?RVF1QWw=?= |
last post by:
Hi,
We have an application developed in VC2005 with mixed code, primarily C++
but using a C# dll for database access (DBUploader), the dll exposes a C++
interface. We are experiencing intermittent failure on startup - no errors or
warnings are generated (including in the EventVwr). Once running there are no
issues. The process is started either manually or spawned via a Windows
service. The dll is compiled with the following compiler...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |