Roundup Tracker - Issues

Issue 736830

classification
demo.py does not work on windows
Type: Severity: normal
Components: Installation Versions:
process
Status: closed fixed
:
: richard : mikethompson, richard
Priority: normal :

Created on 2003-05-13 04:00 by mikethompson, last changed 2003-05-16 01:42 by richard.

Messages
msg818 Author: [hidden] (mikethompson) Date: 2003-05-13 04:00
In demo.py, I had add a couple of lines at the top of the 
install_demo() to get it to work on windows (XP):


def install_demo(home):
    # create the instance
    try:
        shutil.rmtree(home)
    except WindowsError, error:    #### added
        if error.errno != 3:                #### added
            raise                              #### added
    except os.error, error:
        if error.errno != errno.ENOENT:
            raise


WindowsError is a subclass of os.error so the ordering 
of the except clauses is important.

I'm too much of a newbie with python to know if this 
change with cause problems on other platforms.  I'll have 
to leave this up to those that know.
msg819 Author: [hidden] (mikethompson) Date: 2003-05-13 04:26
Logged In: YES 
user_id=630223

Sorry, that code I gave does not come out very well when 
viewed. 

The problem is that, under windows, when the path does not 
exist, the exception thrown is a WindowsError, which is a 
subclass of os.error BUT uses a different numbering system 
for errors.  

So, under windows, the constant errno.ENOENT (2) does not 
match the value in the exception object which is 3.

Actually the easiest, portable solution is take out the try 
completely and put an if (path exists):  before the shutil.rmtree
() line.

Cheers,
Mike
msg820 Author: [hidden] (richard) Date: 2003-05-16 01:42
Logged In: YES 
user_id=6405

Oddly enough, the code has been patched to have the exists() check already. 
Much cleaner :)
History
Date User Action Args
2003-05-13 04:00:03mikethompsoncreate