Exemplo n.º 1
0
def setup():
    if os.path.exists('frankenserver/python'):
        sdk_path = 'frankenserver/python'
    else:  # running on travis
        sdk_path = '../google_appengine'

    # If the SDK path points to a Google Cloud SDK installation
    # then we should alter it to point to the GAE platform location.
    if os.path.exists(os.path.join(sdk_path, 'platform/google_appengine')):
        sdk_path = os.path.join(sdk_path, 'platform/google_appengine')

    # Make sure google.appengine.* modules are importable.
    fixup_paths(sdk_path)

    # Make sure all bundled third-party packages are available.
    import dev_appserver
    dev_appserver.fix_sys_path()
    from google.appengine.ext import vendor
    vendor.add('lib-local')
    vendor.add('lib-both')

    # Loading appengine_config from the current project ensures that any
    # changes to configuration there are available to all tests (e.g.
    # sys.path modifications, namespaces, etc.)
    try:
        import appengine_config
        (appengine_config)
    except ImportError:
        print('Note: unable to import appengine_config.')
Exemplo n.º 2
0
def _AddThirdPartyLibraries():
  """Registers the third party libraries with App Engine.

  In order for third-party libraries to be available in the App Engine
  runtime environment, they must be added with vendor.add. The directories
  added this way must be inside the App Engine project directory.
  """
  # The deploy script is expected to add links to third party libraries
  # before deploying. If the directories aren't there (e.g. when running tests)
  # then just ignore it.
  for library_dir in dashboard.THIRD_PARTY_LIBRARIES:
    if os.path.exists(library_dir):
      vendor.add(os.path.join(os.path.dirname(__file__), library_dir))
Exemplo n.º 3
0
    def get(self):
        from google.appengine.ext import vendor

# add `lib` subdirectory to `sys.path`, so our `main` module can load
# third-party libraries.
        sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib'))
        vendor.add('lib')
        articles = Article.published()
        if len(articles) > defs.MAX_ARTICLES_PER_PAGE:
            articles = articles[:defs.MAX_ARTICLES_PER_PAGE]

        self.response.out.write(self.render_articles(articles,
                                                     self.request,
                                                     self.get_recent()))
Exemplo n.º 4
0
def _AddThirdPartyLibraries():
    """Registers the third party libraries with App Engine.

  In order for third-party libraries to be available in the App Engine
  runtime environment, they must be added with vendor.add. The directories
  added this way must be inside the App Engine project directory.
  In order to do this, a link can be made to the real third_party
  directory. Unfortunately, this doesn't work on Windows.
  """
    if os.name == "nt":
        logging.error("Can not use the symlink to ../third_party on Windows.")
        return
    for library_dir in _THIRD_PARTY_LIBRARIES:
        vendor.add(os.path.join(_THIRD_PARTY_LINK, library_dir))
Exemplo n.º 5
0
def _AddThirdPartyLibraries():
  """Registers the third party libraries with App Engine.

  In order for third-party libraries to be available in the App Engine
  runtime environment, they must be added with vendor.add. The directories
  added this way must be inside the App Engine project directory.
  """
  # The deploy script is expected to add a link to third_party in this directory
  # before deploying. If the directory isn't there (e.g. for tests), then ignore
  # it; the libraries should be set up in run_tests.py.
  third_party_dir = os.path.join(os.path.dirname(__file__), 'third_party')
  if os.path.exists(third_party_dir):
    for library_dir in dashboard.THIRD_PARTY_LIBRARIES:
      vendor.add(os.path.join(third_party_dir, library_dir))
def _SetupPaths():
  """Sets up the sys.path with special directories for endpointscfg.py."""
  sdk_path = _FindSdkPath()
  if sdk_path:
    sys.path.append(sdk_path)
    try:
      import dev_appserver  # pylint: disable=g-import-not-at-top
      if hasattr(dev_appserver, 'fix_sys_path'):
        dev_appserver.fix_sys_path()
      else:
        logging.warning(_NO_FIX_SYS_PATH_WARNING)
    except ImportError:
      logging.warning(_IMPORT_ERROR_WARNING)
  else:
    logging.warning(_NOT_FOUND_WARNING)

  # Add the path above this directory, so we can import the endpoints package
  # from the user's app code (rather than from another, possibly outdated SDK).
  # pylint: disable=g-import-not-at-top
  from google.appengine.ext import vendor
  vendor.add(os.path.dirname(os.path.dirname(__file__)))
Exemplo n.º 7
0
from google.appengine.api import urlfetch
from google.appengine.ext import vendor
vendor.add("libs")
import logging
import json
import telegram
import framework
from webapp2 import Response


TELEGRAM_API_TOKEN = "234472068:AAHspi0uV9ip_NVNeCkePcJJCqbaPoG9xEg"
PLATFORM_URL = "http://yuranich-server.ddns.net:8080/travel-agent/rest/dialog?userid={}&text={}"

app = framework.WSGIApplication()
bot = telegram.Bot(token=TELEGRAM_API_TOKEN)
webhook = bot.setWebhook('https://magellan-telegram.appspot.com/messagehandler')

@app.route("/messagehandler")
def messagehandler(request, *args, **kwargs):
	update = telegram.Update.de_json(json.loads(request.body))
	chat_id = update.message.chat.id
	text = update.message.text.encode('utf-8')

	logging.info("Received {} from {}".format(text, chat_id))
	try:
		answer = json.loads(urlfetch.fetch(url = PLATFORM_URL.format(chat_id, text), method = "GET").content)
	except:
		return ""
	answer_text = answer.get('response')
	answer_buttons = answer.get('buttons')
	logging.info("Got {}".format(answer))
Exemplo n.º 8
0
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os

if not os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine'):
    # In non-production environment, protobuf and GAE have a package name conflict
    # on 'google'. This hack is to solve the conflict.
    import google
    google.__path__.insert(
        0,
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     'third_party', 'google'))

from google.appengine.ext import vendor

# Add all the first-party and third-party libraries.
vendor.add(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), 'first_party'))
vendor.add(
    os.path.join(os.path.dirname(os.path.realpath(__file__)), 'third_party'))
Exemplo n.º 9
0
# Copyright (C) 2018 Google Inc.
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>

"""`appengine_config.py` is automatically loaded when Google App Engine starts
a new instance of your application. This runs before any WSGI applications
specified in app.yaml are loaded.
"""

import os

from google.appengine.ext import vendor

# Third-party libraries are stored in "packages", vendoring will make
# sure that they are importable by the application.
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
PACKAGES_PATH = os.path.join(DIR_PATH, "packages")
vendor.add(PACKAGES_PATH)
Exemplo n.º 10
0
import os
import google
from google.appengine.ext import vendor

lib_directory = os.path.dirname(__file__) + '/lib'

# Background: https://github.com/GoogleCloudPlatform/google-auth-library-python/issues/169
# By the time we reach this code, we've already imported google.  But since we
# are vendoring google.auth, and adding it to the path here, python would just
# look for google.auth in the directory where we initially imported google, and
# that doesn't have an auth subpackage.
#
# To work around that, we need to muck with google.__path__ to include the
# vendor directory we're adding.
google.__path__ = [os.path.join(lib_directory, 'google')] + google.__path__

# Add any libraries install in the "lib" folder.
vendor.add(lib_directory)
Exemplo n.º 11
0
    message='The `channel` argument is deprecated; use `transport` instead.',
)
warnings.filterwarnings('ignore',
                        category=DeprecationWarning,
                        module=r'.*google.protobuf.*')
warnings.filterwarnings(
    'ignore',
    category=DeprecationWarning,
    module=r'.*datastore_types',
    message='object.__init__() takes no parameter',
)

# Include libraries
# `google.appengine.ext.vendor.add` is just `site.addsitedir()` with path shuffling

vendor.add('./lib')  # processes `.pth` files
try:
    vendor.add('./lib/site-packages')  # processes `.pth` files
except ValueError:
    pass


def setup_sdk_imports():
    """Sets up appengine SDK third-party imports."""
    # https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/standard/appengine_helper.py

    sdk_path = os.environ.get('GAE_SDK_PATH')

    if not sdk_path:
        return
# 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.

import datetime
import json
import logging
import os
from pprint import pformat
import jinja2
import webapp2
from google.appengine.api import app_identity
from  google.appengine.ext import vendor

vendor.add('lib1')

from googleapiclient import discovery
from oauth2client.client import GoogleCredentials


compute = discovery.build('compute','v1', credentials=GoogleCredentials.get_application_default())

SAMPLE_NAME = 'Instance timeout helper'

CONFIG = {
    # In DRY_RUN mode, deletes are only logged. Set this to False after you've
    # double-checked the status page and you're ready to enable the deletes.
    'DRY_RUN': False,

    # Be careful, this application could delete all instances in this project.
Exemplo n.º 13
0
# Copyright 2016 The Kubernetes Authors.
#
# 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.

import os

from google.appengine.ext import vendor

# Add any libraries installed in the "third_party" folder.
vendor.add('third_party')

# Use remote GCS calls for local development.
if os.environ.get('SERVER_SOFTWARE', '').startswith('Development'):
    os.environ['SERVER_SOFTWARE'] += ' remote_api'
Exemplo n.º 14
0
from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('SportsWebPython/lib')
Exemplo n.º 15
0
import os
from google.appengine.ext import vendor

# Third-party libraries are stored in "ext", vendoring will make
# sure that they are importable by the application.
vendor.add(os.path.join(os.path.dirname(__file__), 'ext'))

import requests
from requests_toolbelt.adapters import appengine
appengine.monkeypatch()
Exemplo n.º 16
0
from google.appengine.ext import vendor

# Add any libraries installed in the `lib` folder.
vendor.add('src/lib')
Exemplo n.º 17
0
from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('lib')
vendor.add('lib/networkx')
#vendor.add(os.path.join(kawairisa-no-MacBook-Air./Users/LisaKawai/Desktop/STEP_0624/hw5/python/watchful-audio-135423/lib.dirname(kawairisa-no-MacBook-Air.path.realpath(__file__)), 'lib'))
#vendor.add(os.path.join(kawairisa-no-MacBook-Air./Users/LisaKawai/Desktop/STEP_0624/hw5/python/watchful-audio-135423/lib.dirname(kawairisa-no-MacBook-Air.path.realpath(__file__)), 'networkx'))
import os
from google.appengine.ext import vendor

# Add the correct packages path if running on Production
# (this is set by Google when running on GAE in the cloud)
if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
    # on mac
    vendor.add('venv/lib/python2.7/site-packages')

    # on windows
    # vendor.add('venv/Lib/site-packages')
Exemplo n.º 19
0
from google.appengine.ext import vendor
vendor.add('extensions')

from google.appengine.api import mail
import jinja2
import os
import premailer

_appid = os.getenv('APPLICATION_ID').replace('s~', '')
EMAIL_SENDER = 'noreply@{}.appspotmail.com'.format(_appid)


class Emailer(object):
    def __init__(self, sender=None):
        self.sender = sender or EMAIL_SENDER

    def send(self, to, subject, template_path, kwargs=None):
        html = self._render(template_path, kwargs=kwargs)
        self._send(subject, to, html)

    def _render(self, template_path, kwargs=None):
        params = {}
        if kwargs:
            params.update(kwargs)
        template = self.env.get_template(template_path)
        html = template.render(params)
        return premailer.transform(html)

    def _send(self, subject, to, html):
        message = mail.EmailMessage(sender=self.sender, subject=subject)
        message.to = to
Exemplo n.º 20
0
from google.appengine.ext import vendor

# Third-party libraries are stored in "lib", vendoring will make
# sure that they are importable by the application.
vendor.add('libs/external')
import os
# name of the django settings module
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from google.appengine.ext import vendor
vendor.add('lib') # add third party libs to "lib" folder.
Exemplo n.º 22
0
#     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.

import webapp2
import urllib2
import json

import base64

from google.appengine.ext import vendor
vendor.add('server/lib')

import re
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials

# remove these things cause it could be taken the wrong way
DISCOVERY_URL = 'https://{api}.googleapis.com/$discovery/rest?version={apiVersion}'


class VisionApi(webapp2.RequestHandler):
    def __init__(self, request, response):
        # Set self.request, self.response and self.app.
        self.initialize(request, response)
        self.vision = self._create_client()
Exemplo n.º 23
0
"""Bridgy App Engine config.
"""
import logging
import os

# Load packages from virtualenv
# https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring
from google.appengine.ext import vendor
try:
  vendor.add('local')
except Exception as e_local:
  virtual_env = os.getenv('VIRTUAL_ENV')
  try:
    vendor.add(virtual_env)
  except Exception as e_env:
    logging.warning("Couldn't set up App Engine vendor for local: %s\n  or %s: %s",
                    e_local, virtual_env, e_env)
    raise

from granary.appengine_config import *

DISQUS_ACCESS_TOKEN = read('disqus_access_token')
DISQUS_API_KEY = read('disqus_api_key')
DISQUS_API_SECRET = read('disqus_api_secret')
FACEBOOK_TEST_USER_TOKEN = (os.getenv('FACEBOOK_TEST_USER_TOKEN') or
                            read('facebook_test_user_access_token'))
SUPERFEEDR_TOKEN = read('superfeedr_token')
SUPERFEEDR_USERNAME = read('superfeedr_username')

# Make requests and urllib3 play nice with App Engine.
# https://github.com/snarfed/bridgy/issues/396
Exemplo n.º 24
0
Arquivo: app.py Projeto: ericgj/fungi
"""
An example GAE app making use of memcache for session data
"""

import os.path


def local_file(fname):
    return os.path.join(os.path.dirname(__file__), fname)


from google.appengine.ext import vendor
vendor.add(local_file('lib'))

import logging
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)

from typing import Union, NamedTuple
from util.f import identity, always
from pymonad_extra.util.task import resolve
from pymonad_extra.util.maybe import with_default
from util.union import match

from fungi import mount
from fungi.parse import one_of, all_of, s, format, method, number
from fungi.gae.memcache import cache_get
from fungi.gae.user import current as current_user, login_url
from fungi.wsgi import adapter, from_html, redirect_to

redirect_to_login = lambda url: login_url(url).fmap(redirect_to)
"""
`appengine_config.py` is automatically loaded when Google App Engine
starts a new instance of your application. This runs before any
WSGI applications specified in app.yaml are loaded.
"""
import os
from google.appengine.ext import vendor

here = os.path.dirname(os.path.realpath(__file__))

# Third-party libraries are stored in "lib", vendoring will make
# sure that they are importable by the application.
vendor.add(os.path.join(here, 'lib'))

del here
Exemplo n.º 26
0
from google.appengine.ext import vendor
# Add any libraries installed in the "lib" folder.
# vendor.add('lib')
vendor.add(Flask)
vendor.add(click)
vendor.add(gunicorn)
vendor.add(itsdangerous)
vendor.add(Jinja2)
vendor.add(MarkupSafe)
vendor.add(pytz)
vendor.add(requests)
vendor.add(Werkzeug)
Exemplo n.º 27
0
from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('purchases/lib')
Exemplo n.º 28
0
# 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.
#
"""Simple subscriber that aggregates all feeds together."""

from google.appengine.ext import vendor
vendor.add("lib/appengine-subscriber")
#vendor.add(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib'))

import hashlib
import json
import logging
import os
import time

import feedparser
import jinja2
import webapp2
import urllib

# from appengine_subscriber import
Exemplo n.º 29
0
from google.appengine.ext import vendor

vendor.add('django_nonrel')
# Copyright 2020 Google LLC
#
# 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.

from google.appengine.ext import vendor

# Set PATH to your libraries folder.
PATH = 'lib'
# Add libraries installed in the PATH folder.
vendor.add(PATH)
Exemplo n.º 31
0
# Copyright 2018 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.

import os
from google.appengine.ext import vendor

vendor.add(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib'))
Exemplo n.º 32
0
"""
`appengine_config.py` is automatically loaded when Google App Engine
starts a new instance of your application. This runs before any
WSGI applications specified in app.yaml are loaded.
"""

from google.appengine.ext import vendor

# Third-party libraries are stored in "lib", vendoring will make
# sure that they are importable by the application.
vendor.add('apis')
vendor.add('lib')
Exemplo n.º 33
0
# https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring
"""`appengine_config` gets loaded when starting a new application instance."""
from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('lib')
Exemplo n.º 34
0
#
# We cannot special-case this using DEV_MODE because it is possible to run
# Oppia in production mode locally, where a built-in PIL won't be available.
# Hence the check for oppia_tools instead.
if os.path.isdir(OPPIA_TOOLS_PATH):
    PIL_PATH = os.path.join(OPPIA_TOOLS_PATH, 'Pillow-6.2.2')
    if not os.path.isdir(PIL_PATH):
        raise Exception('Invalid path for oppia_tools library: %s' % PIL_PATH)
    sys.path.insert(0, PIL_PATH)  # type: ignore[arg-type]

# Google App Engine (GAE) uses its own virtual environment that sets up the
# python library system path using their third party python library, vendor. In
# order to inform GAE of the packages that are required for Oppia, we need to
# add it using the vendor library. More information can be found here:
# https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27
vendor.add(THIRD_PARTY_PYTHON_LIBS_PATH)
pkg_resources.working_set.add_entry(THIRD_PARTY_PYTHON_LIBS_PATH)

# It is necessary to reload the six module because of a bug in the google cloud
# ndb imports. More details can be found here:
# https://github.com/googleapis/python-ndb/issues/249.
# We need to reload at the very end of this file because we have to add the
# six python path to the app engine vendor first.
import six  # isort:skip  pylint: disable=wrong-import-position, wrong-import-order
reload(six)  # pylint: disable=reload-builtin

# For some reason, pkg_resources.get_distribution returns an empty list in the
# prod env. We need to monkeypatch this function so that prod deployments
# work. Otherwise, pkg_resources.get_distribution('google-api-core').version in
# google/api_core/__init__.py throws a DistributionNotFound error, and
# similarly for pkg_resources.get_distribution('google-cloud-tasks').version in
Exemplo n.º 35
0
"""
`appengine_config.py` is automatically loaded when Google App Engine
starts a new instance of your application. This runs before any
WSGI applications specified in app.yaml are loaded.
"""
import os
import sys
from google.appengine.ext import vendor

ROOTPATH = os.path.dirname(__file__)
SRCPATH = os.path.join(ROOTPATH, 'src')
sys.path.append(SRCPATH)

vendor.add('libraries')
Exemplo n.º 36
0
# Copyright (C) 2017 Google Inc.
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
"""`appengine_config.py` is automatically loaded when Google App Engine starts
a new instance of your application. This runs before any WSGI applications
specified in app.yaml are loaded.
"""

import os

from google.appengine.ext import vendor

# Third-party libraries are stored in "packages", vendoring will make
# sure that they are importable by the application.
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
PACKAGES_PATH = os.path.join(DIR_PATH, "packages")
vendor.add(PACKAGES_PATH)
import logging
import os
from google.appengine.ext import vendor
from dancedeets.util import runtime

vendor.add('lib-both')

if runtime.is_local_appengine():
    vendor.add('lib-local')
else:
    # Import our lib/ directory on dev only (on prod, they should be installed in the Docker image)
    os.environ['GAE_USE_SOCKETS_HTTPLIB'] = '1'

# We don't need such real-time statistics (normally 1 second) on the mapreduce job.
# More of an optimization to save on the associated database Get/Put every second.
mapreduce__CONTROLLER_PERIOD_SEC = 5
# Let's run these mapreduce tasks for longer.
# There's no reason to make them 15 seconds in an age without task runtime limits.
# And sometimes the TransientShareState goes above 1MB and can't be saved,
# resulting in an impossible-to-complete mapreduce. This just helps it avoid that.
mapreduce__SLICE_DURATION_SEC = 30

# Ugh, we are running a super-long mapreduce for now. Let's avoid failures...eventually we'll reduce these.
# How many times to re-attempt the data in this slice, before giving up and restarting the entire shard
mapreduce_TASK_MAX_DATA_PROCESSING_ATTEMPTS = 1000
# How many times to re-attempt this shard as a whole, before giving up and aborting the entire mapreduce
mapreduce_SHARD_MAX_ATTEMPTS = 1000
# How many times to re-attempt this task (outside of the data-processing attempts), before giving up and aborting the entire mapreudce
mapreduce_TASK_MAX_ATTEMPTS = 1000

appstats_MAX_STACK = 25
Exemplo n.º 38
0
from config import settings
from google.appengine.ext.appstats import recording
from google.appengine.ext import vendor

vendor.add("libraries")

Exemplo n.º 39
0
from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('gae/lib')
Exemplo n.º 40
0
# appengine_config.py
import os
from google.appengine.ext import vendor

# libraries are folder created by virtualenv
vendor.add(os.path.join(os.path.dirname(os.path.realpath(__file__)),
           'lib', 'python2.7', 'site-packages'))
Exemplo n.º 41
0
from google.appengine.ext import vendor

# Add any libraries installed in the "libs" folder.
vendor.add('libs')
Exemplo n.º 42
0
from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('lib')
vendor.add('src')
Exemplo n.º 43
0
from google.appengine.ext import vendor

vendor.add('lib') # project apps
vendor.add('extlib') # external libraries

# solution for the bug of multipart/formdata file upload with text parameters
import base64
import quopri

from webob import multidict


def from_fieldstorage(cls, fs):
    """
    Create a dict from a cgi.FieldStorage instance
    """
    obj = cls()
    if fs.list:
        # fs.list can be None when there's nothing to parse
        for field in fs.list:
            if field.filename:
                field_value = field
                obj.add(field.name, field)
            else:

                # first, set a common charset to utf-8.
                common_charset = 'utf-8'

                # second, check Content-Transfer-Encoding and decode
                # the value appropriately
                field_value = field.value
Exemplo n.º 44
0
# Load packages from virtualenv
# https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring
from google.appengine.ext import vendor
vendor.add('local')

from granary.appengine_config import *

# Make requests and urllib3 play nice with App Engine.
# https://github.com/snarfed/bridgy/issues/396
# http://stackoverflow.com/questions/34574740
from requests_toolbelt.adapters import appengine
appengine.monkeypatch()
Exemplo n.º 45
0
# appengine_config.py
from google.appengine.ext import vendor
import sys
sys.path.insert(0, 'lib')

# Add any libraries install in the "lib" folder.
vendor.add('env')
Exemplo n.º 46
0
"""
`appengine_config.py` is automatically loaded when Google App Engine
starts a new instance of your application. This runs before any
WSGI applications specified in app.yaml are loaded.
"""

from google.appengine.ext import vendor

# Third-party libraries are stored in "lib", vendoring will make
# sure that they are importable by the application.
vendor.add('ext')
"""
`appengine_config.py` is automatically loaded when Google App Engine
starts a new instance of your application. This runs before any
WSGI applications specified in app.yaml are loaded.
"""

from google.appengine.ext import vendor

# Add any libraries installed in the "vendor" folder.
vendor.add('vendor')
Exemplo n.º 48
0
"""
`appengine_config.py` gets loaded every time a new instance is started.

Use this file to configure app engine modules as defined here:
https://developers.google.com/appengine/docs/python/tools/appengineconfig
"""

import os

from google.appengine.ext import vendor

from shared import deploy


# Use external libraries.
required_externals = file("externals/externals.txt").read().split("\n")
have_externals = os.listdir("externals").remove("externals.txt")

for external in required_externals:
  if (external and not external.startswith("#")):
    # Not vertical whitespace or a comment.
    _, _, _, module_name = deploy.make_name(external)

    try:
      vendor.add(os.path.join("externals", module_name))
    except ValueError:
      raise RuntimeError("Could not find external '%s'."
                         " Did you run using deploy.py?" % (external))
Exemplo n.º 49
0
"""
`appengine_config.py` is automatically loaded when Google App Engine
starts a new instance of your application. This runs before any
WSGI applications specified in app.yaml are loaded.
"""

from google.appengine.ext import vendor

# Third-party libraries are stored in "deps", vendoring will make
# sure that they are importable by the application.
vendor.add('deps')
Exemplo n.º 50
0
    locales = []
    default_locale = None
    build_server_config = {}
    static_paths = []
else:
    podspec = yaml.load(open(podspec_path))
    locales = podspec.get('localization', {}).get('locales', [])
    default_locale = podspec.get('localization', {}).get('default_locale')
    build_server_config = podspec.get('build_server', {})
    static_paths = []
    for static_dir in podspec.get('static_dirs', []):
        static_paths.append(static_dir['serve_at'])

from google.appengine.ext import vendor
extensions_dir = os.path.join(os.path.dirname(podspec_path), 'extensions')
vendor.add('extensions')
vendor.add(extensions_dir)

# Set build root.
root = os.path.join(os.path.dirname(__file__), '..', '..', DEFAULT_DIR)
root = os.path.abspath(root)

build_server_config['default_locale'] = default_locale
build_server_config['static_paths'] = static_paths
build_server_config['root'] = root
build_server_config['locales'] = locales


def instance():
    locales = build_server_config['locales']
    default_locale = build_server_config['default_locale']
Exemplo n.º 51
0
import os
import sys

from google.appengine.ext import vendor

vendor.add("lib")
sys.path.append(os.path.join(os.path.dirname(__file__), "lib"))
Exemplo n.º 52
0
from google.appengine.ext import vendor
vendor.add('.python-libs')
vendor.add('server/utils')
Exemplo n.º 53
0
#Credit to: http://bekt.github.io/p/gae-ssl/#sthash.w67DneFj.dpbs
from os import environ
from google.appengine.ext import vendor
vendor.add('lib') #Make GAE aware of lib path...

# Workaround the dev-environment SSL
# http://stackoverflow.com/q/16192916/893652
if environ.get('SERVER_SOFTWARE', '').startswith('Development'):
    import imp
    import os.path
    from google.appengine.tools.devappserver2.python import sandbox
    sandbox._WHITE_LIST_C_MODULES += ['_ssl', '_socket']
    # Use the system socket.
    psocket = os.path.join(os.path.dirname(os.__file__), 'socket.py')
    imp.load_source('socket', psocket)
Exemplo n.º 54
0
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os

from google.appengine.ext import vendor

from base import constants

for library in constants.THIRD_PARTY_LIBRARIES:
    vendor.add(os.path.join('third_party', library))
Exemplo n.º 55
0
import os
from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('lib')
vendor.add(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib'))
Exemplo n.º 56
0
from google.appengine.ext import vendor
import os

# Add any libraries installed in the "vendor" folder.
path = os.path.join(os.path.dirname(__file__), '..')
vendor.add(path)
Exemplo n.º 57
0
"""
`appengine_config.py` is automatically loaded when Google App Engine
starts a new instance of your application. This runs before any
WSGI applications specified in app.yaml are loaded.
"""

from google.appengine.ext import vendor

# Third-party libraries are stored in "lib", vendoring will make
# sure that they are importable by the application.
vendor.add('venv/lib/python2.7/site-packages')
Exemplo n.º 58
0
# appengine_config.py
from google.appengine.ext import vendor

# Add any libraries install in the "lib" folder.
vendor.add('vendor')
Exemplo n.º 59
0
from google.appengine.ext import vendor

# Add any libraries installed in the "lib" folder.
vendor.add('lib')

Exemplo n.º 60
0
from google.appengine.ext import vendor

vendor.add("lib")