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