scripts/interactive.py
author Daniel Hans <Daniel.M.Hans@gmail.com>
Tue, 10 Nov 2009 18:18:06 +0100
changeset 3085 ded7a67e7e0a
parent 2907 fbf0d63f37b9
permissions -rwxr-xr-x
Some functions which applies to scoped tags in general moved from TaskTag to Task model. Also, some stylish and whitespace changes and docstrings added.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2009 the Melange authors.
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
"""This module supplies an interactive shell with remote api configured.
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
Usage is simple:
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
2039
07f46319d24f Fix docstring in interactive.py script.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2024
diff changeset
    21
App Engine interactive console
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
>>> from soc.models.user import User
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
>>> gen = lambda: User.all()
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
>>> it = deepFetch(gen)
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
>>> result = [i for i in it]
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
"""
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
__authors__ = [
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
2702
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    30
  '"Pawel Solyga" <pawel.solyga@gmail.com>',
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
]
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
import code
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
import getpass
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
import os
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
import sys
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
def auth_func():
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
  """Returns a tuple with username and password.
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
  """
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
  return raw_input('Username:'), getpass.getpass('Password:')
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
2702
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    47
def deepFetch(queryGen, key=None, filters=None, batchSize = 100):
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
  """Iterator that yields an entity in batches.
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
  Args:
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
    queryGen: should return a Query object
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
    key: used to .filter() for __key__
2702
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    53
    filters: dict with additional filters
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
    batchSize: how many entities to retrieve in one datastore call
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
  Retrieved from http://tinyurl.com/d887ll (AppEngine cookbook).
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
  """
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
2056
bbd16a156bde Print how many entities have been retrieved
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2046
diff changeset
    59
  from google.appengine.ext import db
bbd16a156bde Print how many entities have been retrieved
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2046
diff changeset
    60
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
   # AppEngine will not fetch more than 1000 results
2702
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    62
  batchSize = min(batchSize, 1000)
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
  query = None
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
  done = False
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
  count = 0
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
  if key:
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
    key = db.Key(key)
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    70
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    71
  while not done:
2056
bbd16a156bde Print how many entities have been retrieved
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2046
diff changeset
    72
    print count
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    73
    query = queryGen()
2702
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    74
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    75
    if filters:
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    76
      for key, value in filters.items():
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    77
        query.filter(key, value)
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    78
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    79
    if key:
2702
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    80
      query.filter("__key__ > ", key)
028f6adffde7 Added optional filters property to deepFetch.
Pawel Solyga <pawel.solyga@gmail.com>
parents: 2056
diff changeset
    81
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    82
    results = query.fetch(batchSize)
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    83
    for result in results:
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    84
      count += 1
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    85
      yield result
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    86
    if batchSize > len(results):
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    87
      done = True
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    88
    else:
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    89
      key = results[-1].key()
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    90
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    91
2046
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
    92
def remote(args, context=None):
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    93
  """Starts a shell with the datastore as remote_api_stub.
2046
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
    94
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
    95
  Args:
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
    96
    args: arguments from the user
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
    97
    context: locals that should be added to the shell
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    98
  """
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    99
2879
cb0f9b4646aa Revert "revert wrong head"
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2871
diff changeset
   100
  from google.appengine.api import apiproxy_stub_map
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   101
  from google.appengine.ext import db
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   102
  from google.appengine.ext.remote_api import remote_api_stub
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   103
2046
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
   104
  if not context:
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
   105
    context = {}
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
   106
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   107
  app_id = args[0]
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   108
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   109
  if len(args) > 1:
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   110
    host = args[1]
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   111
  else:
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   112
    host = '%s.appspot.com' % app_id
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   113
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   114
  remote_api_stub.ConfigureRemoteDatastore(app_id, '/remote_api', auth_func, host)
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   115
2046
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
   116
  context['deepFetch'] = deepFetch
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   117
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   118
  code.interact('App Engine interactive console for %s' % (app_id,), None, context)
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   119
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   120
2046
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
   121
def setup():
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   122
  """Sets up the sys.path and environment for development.
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   123
  """
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   124
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   125
  here = os.path.abspath(__file__)
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   126
  here = os.path.join(os.path.dirname(here), '..')
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   127
  here = os.path.normpath(here)
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   128
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   129
  appengine_location = os.path.join(here, 'thirdparty', 'google_appengine')
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   130
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   131
  extra_paths = [here,
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   132
                 os.path.join(appengine_location, 'lib', 'django'),
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   133
                 os.path.join(appengine_location, 'lib', 'webob'),
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   134
                 os.path.join(appengine_location, 'lib', 'yaml', 'lib'),
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   135
                 appengine_location,
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   136
                 os.path.join(here, 'app'),
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   137
                ]
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   138
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   139
  sys.path = extra_paths + sys.path
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   140
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   141
  os.environ['SERVER_SOFTWARE'] = 'Development Interactive Shell'
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   142
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   143
  import main as app_main
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   144
2046
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
   145
def main(args):
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
   146
  """Convenience wrapper that calls setup and remote.
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
   147
  """
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
   148
1fb1c628ad60 Factor out the setup() method in interactive
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2039
diff changeset
   149
  setup()
2024
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   150
  remote(args)
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   151
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   152
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   153
if __name__ == '__main__':
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   154
  if len(sys.argv) < 2:
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   155
    print "Usage: %s app_id [host]" % (sys.argv[0],)
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   156
    sys.exit(1)
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   157
43e5b515b71d Add a script to start an interactive shell with remote api
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   158
  main(sys.argv[1:])