thirdparty/google_appengine/dev_appserver.py
changeset 149 f2e327a7c5de
parent 109 620f9b141567
child 416 99771d263391
equal deleted inserted replaced
148:37505d64e57b 149:f2e327a7c5de
    12 # distributed under the License is distributed on an "AS IS" BASIS,
    12 # distributed under the License is distributed on an "AS IS" BASIS,
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14 # See the License for the specific language governing permissions and
    14 # See the License for the specific language governing permissions and
    15 # limitations under the License.
    15 # limitations under the License.
    16 #
    16 #
    17 """Convenience wrapper for starting dev_appserver."""
    17 """Convenience wrapper for starting an appengine tool."""
    18 
    18 
    19 
    19 
    20 import os
    20 import os
    21 import sys
    21 import sys
    22 
    22 
    31   sys.exit(1)
    31   sys.exit(1)
    32 if version_tuple == (2, 4):
    32 if version_tuple == (2, 4):
    33   sys.stderr.write('Warning: Python 2.4 is not supported; this program may '
    33   sys.stderr.write('Warning: Python 2.4 is not supported; this program may '
    34                    'break. Please use version 2.5 or greater.\n')
    34                    'break. Please use version 2.5 or greater.\n')
    35 
    35 
    36 DEV_APPSERVER_PATH = 'google/appengine/tools/dev_appserver_main.py'
       
    37 
       
    38 DIR_PATH = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
    36 DIR_PATH = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
       
    37 SCRIPT_DIR = os.path.join(DIR_PATH, 'google', 'appengine', 'tools')
    39 
    38 
    40 EXTRA_PATHS = [
    39 EXTRA_PATHS = [
    41   DIR_PATH,
    40   DIR_PATH,
    42   os.path.join(DIR_PATH, 'lib', 'django'),
    41   os.path.join(DIR_PATH, 'lib', 'django'),
    43   os.path.join(DIR_PATH, 'lib', 'webob'),
    42   os.path.join(DIR_PATH, 'lib', 'webob'),
    44   os.path.join(DIR_PATH, 'lib', 'yaml', 'lib'),
    43   os.path.join(DIR_PATH, 'lib', 'yaml', 'lib'),
    45 ]
    44 ]
    46 
    45 
       
    46 SCRIPT_EXCEPTIONS = {
       
    47   "dev_appserver.py" : "dev_appserver_main.py"
       
    48 }
       
    49 
    47 if __name__ == '__main__':
    50 if __name__ == '__main__':
    48   sys.path = EXTRA_PATHS + sys.path
    51   sys.path = EXTRA_PATHS + sys.path
    49   script_path = os.path.join(DIR_PATH, DEV_APPSERVER_PATH)
    52   script_name = os.path.basename(__file__)
       
    53   script_name = SCRIPT_EXCEPTIONS.get(script_name, script_name)
       
    54   script_path = os.path.join(SCRIPT_DIR, script_name)
    50   execfile(script_path, globals())
    55   execfile(script_path, globals())