def CreateServer(self): with open(self.filename) as stream: appinfo_external = appinfo_includes.Parse(stream) appengine_config = vmconfig.BuildVmAppengineEnvConfig() vmstub.Register(vmstub.VMStub(appengine_config.default_ticket)) app = meta_app.FullyWrappedApp(appinfo_external, appengine_config) self.server = self.server_class(self.host, self.port, app, appinfo_external) logging.info('Configured server on %s:%s', self.host, self.port)
def CreateServer(self): with open(self.filename) as stream: appinfo_external = appinfo_includes.Parse(stream) appengine_config = vmconfig.BuildVmAppengineEnvConfig() vmstub.Register(vmstub.VMStub(appengine_config.default_ticket)) if 'googleclouddebugger' in sys.modules: try: googleclouddebugger.AttachDebugger() except Exception as e: logging.warn('Exception while initializing Cloud Debugger: %s', traceback.format_exc(e)) try: import appengine_config as user_appengine_config except ImportError: pass app = meta_app.FullyWrappedApp(appinfo_external, appengine_config) self.server = self.server_class(self.host, self.port, app, appinfo_external) logging.info('Configured server on %s:%s', self.host, self.port)
# Configure logging to output structured JSON to Cloud Logging. root_logger = logging.getLogger('') try: handler = cloud_logging.CloudLoggingHandler() root_logger.addHandler(handler) except IOError: # If the Cloud Logging endpoint does not exist, just use the default handler # instead. This will be the case when running in local dev mode. pass root_logger.setLevel(logging.INFO) # Fetch application configuration via the config file. appinfo = get_module_config(get_module_config_filename()) env_config = vmconfig.BuildVmAppengineEnvConfig() # Ensure API requests include a valid ticket by default. vmstub.Register(vmstub.VMStub(env_config.default_ticket)) # Take an immutable snapshot of env data from env_config. This is added to the # environment in `reset_environment_middleware` in a particular order to ensure # that it cannot be overridden by other steps. frozen_env_config_env = tuple( env_vars_from_env_config(env_config).iteritems()) # Also freeze user env vars specified in app.yaml. Later steps to modify the # environment such as env_vars_from_env_config and request middleware # will overwrite these changes. This is added to the environment in # `reset_environment_middleware`. frozen_user_env = tuple(
# 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. # Python CLI for sending email. Currently does not handle attachments from google.appengine.api import mail import click import logging import json import os '''The below statements are required because we are not using the standard python runtime This will be fixed in the next launch but we have to live with it for now''' from google.appengine.ext.vmruntime import vmconfig from google.appengine.ext.vmruntime import vmstub vmstub.Register(vmstub.VMStub(vmconfig.BuildVmAppengineEnvConfig().default_ticket)) vmstub.app_is_loaded = True @click.command() @click.option('--to', help='users to receive the email') @click.option('--email_subject', help='email subject to be sent to users') @click.option('--email_body', help='email body to be sent to users') @click.option('--cc', help='cc users to receive the email') def send_mail(to, email_subject, email_body, cc): application_id = os.environ.get('GAE_LONG_APP_ID') message = mail.EmailMessage(sender="*****@*****.**", subject=email_subject) message.sender = "noreply@" + application_id + ".appspotmail.com" message.to = json.loads(to) message.body = email_body if cc: