wxglade codegen causes exception error Cannot create a file when that file already exists

Graeme Glenn - InfoComm Engineering <[email protected]>
Newsgroups gmane.comp.python.wxglade
Organization InfoComm Engineering
Message-ID <[email protected]>
Hi All,

I've looked a bit further. It seems there might be a bug in line 517.
If the backup file already exists, you can't rename the current working
file to that file name. This bug has reared it's head a few times for me
already, because I'm working on existing code. It's even happened just
going round the development cycle loop a few times. Change GUI, save GUI
wxg file and regenerate code.

I'm not sure if the problem is caused by some earlier code, but the fix
even if temporary I implemented was to add a test to see if the backup
file exists, if so delete it and then do the rename of current file to
the backup file.

    try:
        if need_backup:
            # GGG added following two lines to delete existing back if
exists
            if os.path.isfile(filename + config.preferences.backup_suffix):
                os.remove(filename + config.preferences.backup_suffix)
            os.rename(filename, filename + config.preferences.backup_suffix)
            config.backed_up[filename] = True

Hope this helps. It seems to be working just fine now.

Regards
Graeme

> Exception type:      <type 'exceptions.WindowsError'>
> Exception details:   [Error 183] Cannot create a file when that file
> already exists
> Application stack trace:
> Stack frame at level 0
> ======================
>   File "C:\Program Files\wxGlade\common.py", line 517
>   Function
> "save_file(filename=u'C:\\src\\python\\effectivo02\\DialogCat.py',
> content='# -*- coding: ISO-8859-15 -*-\n#\n# generated by wxGlade
> 0.7.1 on Tue Jan 05 14:09:10 2016\n#\n\... n', which='codegen')"
>   Source code context:
>           outfile = None
>           try:
>               if need_backup:
>   ->571              os.rename(filename, filename +
> config.preferences.backup_suffix)
>                   config.backed_up[filename] = True
>      

Graeme G. Glenn
PEng. Dip Electronics BEng Comm Dip Theo
InfoComm Engineering
http://www.coolice.com.au/catalog/
<http://www.coolice.com.au/catalog/%3Ewww.coolice.com.au>
Ph: +61 3 9789 3547

------------------------------------------------------------------------------

_______________________________________________
wxGlade-general mailing list
wxGlade-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/wxglade-general
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.