| | 86 | # the code in the following "if" block handles situations where the |
|---|
| | 87 | # user has installed over an older release of 2.1 with a conflicting |
|---|
| | 88 | # version of the sessionfilter |
|---|
| | 89 | if 'install_lib' in dist.command_obj: |
|---|
| | 90 | |
|---|
| | 91 | # get the installation directory (is there a better way to do this?) |
|---|
| | 92 | install_dir = dist.command_obj['install_lib'].install_dir |
|---|
| | 93 | |
|---|
| | 94 | # make sure we have an absolute install path |
|---|
| | 95 | install_dir = os.path.join(os.path.abspath('/'), install_dir) |
|---|
| | 96 | |
|---|
| | 97 | old_session_filter_path = os.path.join( |
|---|
| | 98 | install_dir, 'cherrypy', 'lib', 'filter', 'sessionfilter') |
|---|
| | 99 | |
|---|
| | 100 | # check for existence of old sessionfilter package dir |
|---|
| | 101 | # and prompt the user if it exists |
|---|
| | 102 | if os.path.exists(old_session_filter_path): |
|---|
| | 103 | handle_old_session_filter(old_session_filter_path) |
|---|
| | 104 | |
|---|
| | 105 | |
|---|
| | 106 | def handle_old_session_filter(pth): |
|---|
| | 107 | warn_old_session_filter(pth) |
|---|
| | 108 | choice = raw_input('Delete old sessionfilter directory? (yes/no): ') |
|---|
| | 109 | if choice.lower() in ('y', 'yes'): |
|---|
| | 110 | shutil.rmtree(pth) |
|---|
| | 111 | print "Old sessionfilter directory deleted." |
|---|
| | 112 | else: |
|---|
| | 113 | print "You will need to manually need to delete the old sessionfilter directory." |
|---|
| | 114 | |
|---|
| | 115 | |
|---|
| | 116 | def warn_old_session_filter(pth): |
|---|
| | 117 | msg = """ |
|---|
| | 118 | ************************ WARNING ***************************** |
|---|
| | 119 | Since you have installed over the top of an existing CherryPy |
|---|
| | 120 | installation, you must remove the old sessionfilter package |
|---|
| | 121 | directory at: |
|---|
| | 122 | %s |
|---|
| | 123 | ************************ WARNING ***************************** |
|---|
| | 124 | """ % (pth,) |
|---|
| | 125 | print msg |
|---|
| | 126 | |
|---|
| | 127 | |
|---|