Added enable-app-engine-project
This commit is contained in:
@@ -12,3 +12,4 @@ include setpath.sh
|
||||
include setup_utils.py
|
||||
include gflags.py
|
||||
include gflags_validators.py
|
||||
include bin/enable-app-engine-project
|
||||
|
||||
116
bin/enable-app-engine-project
Normal file
116
bin/enable-app-engine-project
Normal file
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2007 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Copy the sources for google-api-python-client into an App Engine project.
|
||||
|
||||
Copies, or symbolically links the sources of the google-api-python-client
|
||||
library into a Google App Engine project. This is necessary so that the
|
||||
source can be uploaded when the application is deployed.
|
||||
"""
|
||||
|
||||
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||
|
||||
import gflags
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
|
||||
from distutils.dir_util import copy_tree
|
||||
from distutils.file_util import copy_file
|
||||
from distutils.errors import DistutilsFileError
|
||||
|
||||
FLAGS = gflags.FLAGS
|
||||
SOURCES = [
|
||||
'gflags',
|
||||
'gflags_validators',
|
||||
'httplib2',
|
||||
'oauth2client',
|
||||
'oauth2',
|
||||
'apiclient',
|
||||
'uritemplate',
|
||||
]
|
||||
|
||||
gflags.DEFINE_enum('logging_level', 'ERROR',
|
||||
['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
|
||||
'Set the level of logging detail.')
|
||||
|
||||
gflags.DEFINE_boolean('force', 'False',
|
||||
'Forcibly copy over client library files.')
|
||||
|
||||
gflags.DEFINE_boolean('dry_run', 'False', 'Don\'t actually do anything.')
|
||||
|
||||
def find_source(module):
|
||||
isdir = False
|
||||
location = ''
|
||||
m = __import__(module)
|
||||
logging.debug('Absolute path for module %s: %s' % (module, m.__file__))
|
||||
basename = os.path.basename(m.__file__)
|
||||
if basename.startswith('__init__.'):
|
||||
isdir = True
|
||||
location = os.path.dirname(m.__file__)
|
||||
else:
|
||||
location = m.__file__.rsplit('.', 1)[0] + '.py'
|
||||
|
||||
return (isdir, location)
|
||||
|
||||
def main(argv):
|
||||
# Let the gflags module process the command-line arguments
|
||||
try:
|
||||
argv = FLAGS(argv)
|
||||
except gflags.FlagsError, e:
|
||||
print '%s\\nUsage: %s ARGS\\n%s' % (e, argv[0], FLAGS)
|
||||
sys.exit(1)
|
||||
|
||||
# Set the logging according to the command-line flag
|
||||
logging.getLogger().setLevel(getattr(logging, FLAGS.logging_level))
|
||||
|
||||
logging.info('Setting up the directories: %s' % argv[1:])
|
||||
for dir in argv[1:]:
|
||||
# Check if the supplied directory is an App Engine project by looking
|
||||
# for an app.yaml
|
||||
if not os.path.isfile(os.path.join(dir, 'app.yaml')):
|
||||
sys.exit('The given directory is not a Google App Engine project: %s', dir)
|
||||
|
||||
|
||||
# Build up the set of file or directory copying actions we need to do
|
||||
action = [] # (src, dst, isdir)
|
||||
for source in SOURCES:
|
||||
isdir, source_location = find_source(source)
|
||||
if isdir:
|
||||
target = source
|
||||
else:
|
||||
target = source + ".py"
|
||||
full_target = os.path.join(dir, target)
|
||||
if not FLAGS.force and os.path.exists(full_target):
|
||||
noun = isdir and 'Directory' or 'File'
|
||||
sys.exit("%s already exists in project: %s" % (noun, target))
|
||||
action.append((source_location, full_target, isdir))
|
||||
|
||||
# Now perform all the copying actions we collected
|
||||
try:
|
||||
for src, dst, isdir in action:
|
||||
if isdir:
|
||||
results = copy_tree(src, dst, FLAGS.dry_run)
|
||||
for filename in results:
|
||||
logging.info('Copied to: %s' % filename)
|
||||
else:
|
||||
filename, copied = copy_file(src, dst, FLAGS.dry_run)
|
||||
logging.info('Copied to: %s Successfully: %s' % (filename, copied))
|
||||
except DistutilsFileError, e:
|
||||
sys.exit(str(e))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
||||
3
setup.py
3
setup.py
@@ -64,7 +64,7 @@ long_desc = """The Google API Client for Python is a client library for
|
||||
accessing the Buzz, Moderator, and Latitude APIs."""
|
||||
|
||||
setup(name="google-api-python-client",
|
||||
version="1.0alpha11",
|
||||
version="1.0beta1",
|
||||
description="Google API Client Library for Python",
|
||||
long_description=long_desc,
|
||||
author="Joe Gregorio",
|
||||
@@ -76,6 +76,7 @@ setup(name="google-api-python-client",
|
||||
package_data={
|
||||
'apiclient': ['contrib/*/*.json']
|
||||
},
|
||||
scripts=['bin/enable-app-engine-project'],
|
||||
license="Apache 2.0",
|
||||
keywords="google api client",
|
||||
classifiers=['Development Status :: 3 - Alpha',
|
||||
|
||||
Reference in New Issue
Block a user