Greetings all!
I have been using FileConfig for a couple of small applications to
store, well, configs for XML-RPC details.
What I have found is that in some cases, it is necessary to touch the
filename like so:
def GetConfig(self):
"""
Reads the config file for the application if it exists and
return a configfile object for use later.
"""
if not os.path.exists(self.GetDataDir()):
os.makedirs(self.GetDataDir())
if not os.path.exists(os.path.join(self.GetDataDir(),
"chisimbauploader")):
open(os.path.join(self.GetDataDir(), "chisimbauploader"),
'w').close()
config = wx.FileConfig(
localFilename=os.path.join(self.GetDataDir(),
"chisimbauploader"))
return config
in order for the config to get written on config.write()
This seems to happen spuriously, which leads me to believe that it may
be a bug.
Is this indeed the case?
--Paul
Hi Paul,
I have been using FileConfig for a couple of small applications to
store, well, configs for XML-RPC details.
What I have found is that in some cases, it is necessary to touch the
filename like so:
def GetConfig(self):
"""
Reads the config file for the application if it exists and
return a configfile object for use later.
"""
if not os.path.exists(self.GetDataDir()):
os.makedirs(self.GetDataDir())
if not os.path.exists(os.path.join(self.GetDataDir(),
"chisimbauploader")):
open(os.path.join(self.GetDataDir(), "chisimbauploader"),
'w').close()
config = wx.FileConfig(
localFilename=os.path.join(self.GetDataDir(),
"chisimbauploader"))
return config
in order for the config to get written on config.write()
This seems to happen spuriously, which leads me to believe that it may
be a bug.
Is this indeed the case?
I don't know on which platform this happens and which wxPython version
you are using, but I use exactly the same code (except the "touch") on
Windows XP for my GUI2Exe and everything works fine. As I know of some
user of GUI2Exe using GTK and Mac without issues with wx.FileConfig, I
don't suppose a bug exists.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
···
On Thu, Nov 6, 2008 at 8:37 AM, Paul Scott wrote:
Andrea,
Sorry, had a bit of a dumb moment this morning when I typed that mail.
.
The platform I am using is Ubuntu 8.04 with wxPython-2.8.
What I have found is that if more than one wxPython application uses the
same directory to write config files to (even though the files have
unique names) it results in the OP description. The only way to get
around it is to add the pseudo touch code to create the file first. I
have checked permissions and all (which shouldn't be an issue in my own
home directory) as well as looking at all feedback from the script
itself.
The only thing that I can think of is that I am only passing in the
localFile parameter, which may be the issue?
Anyway, on my system(s) at least, this thing is almost 100% replicable.
If I have to code in that workaround every time, then I will, but
everything in me is screaming that this is not cool...
Anyway, thanks for the feedback!
--Paul
···
On Thu, 2008-11-06 at 09:04 +0000, Andrea Gavana wrote:
I don't know on which platform this happens and which wxPython version
you are using, but I use exactly the same code (except the "touch") on
Windows XP for my GUI2Exe and everything works fine. As I know of some
user of GUI2Exe using GTK and Mac without issues with wx.FileConfig, I
don't suppose a bug exists.