From: <sv...@ww...> - 2005-01-30 21:35:53
|
Author: mkrose Date: 2005-01-30 13:35:45 -0800 (Sun, 30 Jan 2005) New Revision: 1454 Modified: trunk/CSP/tools/CSP_bootstrap Log: Clean up the bootstrap loader and add better checking for case errors in the workspace root directory name. Please run './setup.py --force' to install the new loader. (must be run as admin/su) Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1454 Modified: trunk/CSP/tools/CSP_bootstrap =================================================================== --- trunk/CSP/tools/CSP_bootstrap 2005-01-26 10:26:02 UTC (rev 1453) +++ trunk/CSP/tools/CSP_bootstrap 2005-01-30 21:35:45 UTC (rev 1454) @@ -37,26 +37,46 @@ self = sys.modules['CSP'] del sys.modules['CSP'] -case_insensitive = os.name.startswith('win') or os.name.startswith('nt') -if case_insensitive: - tr_case = string.upper -else: - tr_case = lambda x: x +# on windows it isn't uncommon/difficult to accidentally check out +# the repository under 'csp' instead of 'CSP'. we go to some trouble +# here to detect this problem and complain accordingly. this requires +# a case insensitive search for the root directory under windows. +# this isn't necessary (or desirable) under linux, but nevertheless +# we do the same in order to help keep the windows and linux development +# environments in sync. For example, adding a directory 'csp' below the +# root CSP directory is a bad thing, and we will catch it on either +# platform. -# look for the root of the current workspace +# look for the root of the current workspace (first 'CSP' directory +# above cwd). cwd = os.getcwd() parts = cwd.split(os.sep) -if not 'CSP' in map(tr_case, parts): +if not 'CSP' in map(string.upper, parts): + print print 'Error: trying to import CSP from outside of a workspace.' print 'Current working directory is %s' % cwd sys.exit(1) -while tr_case(parts[-1]) != 'CSP': +while parts[-1].upper() != 'CSP': parts = parts[:-1] +# hmm, found some mixed or lower-case variant of 'CSP'. the user +# probably made a mistake when checking out the repository. +if parts[-1] != 'CSP' and parts[-1].upper() == 'CSP': + print + print 'Error: the current workspace appears to be under a directory named "csp"' + print ' ==> %s' % os.path.join(*parts) + print + print 'The correct top-level directory should be all uppercase ("CSP"). You may' + print 'have made a mistake when checking out the repository (which is easy to do' + print 'with TortoiseSVN and other GUI clients). Please rename "csp" to "CSP" and' + print 'try again.' + sys.exit(1) + CSP_PATH = os.path.sep.join(parts[:-1]) ROOT = os.path.join(CSP_PATH, 'CSP') if not os.path.exists(os.path.join(ROOT, '.svn')): + print print 'Warning: %s does not contain .svn and may not be a valid CSP workspace.' % ROOT # load the real CSP package. we strip away the original sys.path to @@ -74,6 +94,7 @@ # cleanup, notify, and pass the error along. del sys.CSP_PATH sys.path = old_path + print print 'Unable to bootstrap a CSP module space from the current working directory.' raise |