| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import code | |
| 7 import getpass | |
| 8 import logging | |
| 9 import os | |
| 10 import sys | |
| 11 | |
| 12 ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..') | |
| 13 LIB = os.path.join(ROOT, '..', 'google_appengine', 'lib') | |
| 14 sys.path.insert(0, os.path.join(ROOT, '..', 'google_appengine')) | |
| 15 sys.path.append(os.path.join(LIB, 'yaml', 'lib')) | |
| 16 sys.path.append(os.path.join(LIB, 'fancy_urllib')) | |
| 17 sys.path.append(os.path.join(LIB, 'webob')) | |
| 18 sys.path.append(ROOT) | |
| 19 | |
| 20 from google.appengine.ext.remote_api import remote_api_stub | |
| 21 | |
| 22 | |
| 23 def auth_func(): | |
| 24 user = os.environ.get('EMAIL_ADDRESS') | |
| 25 if user: | |
| 26 print('User: %s' % user) | |
| 27 else: | |
| 28 user = raw_input('Username:') | |
| 29 try: | |
| 30 pwd = open('.pwd').readline().strip() | |
| 31 except IOError: | |
| 32 pwd = getpass.getpass('Password:') | |
| 33 return user, pwd | |
| 34 | |
| 35 | |
| 36 def main(): | |
| 37 if len(sys.argv) < 2: | |
| 38 app_id = 'chromium-status' | |
| 39 else: | |
| 40 app_id = sys.argv[1] | |
| 41 if len(sys.argv) > 2: | |
| 42 host = sys.argv[2] | |
| 43 else: | |
| 44 host = '%s.appspot.com' % app_id | |
| 45 logging.basicConfig(level=logging.ERROR) | |
| 46 | |
| 47 # pylint: disable=W0612 | |
| 48 from google.appengine.api import memcache | |
| 49 from google.appengine.ext import db | |
| 50 remote_api_stub.ConfigureRemoteDatastore( | |
| 51 app_id, '/_ah/remote_api', auth_func, host) | |
| 52 | |
| 53 from appengine_module.chromium_status import base_page | |
| 54 from appengine_module.chromium_status import breakpad | |
| 55 from appengine_module.chromium_status import commit_queue | |
| 56 from appengine_module.chromium_status import event_push | |
| 57 from appengine_module.chromium_status import lkgr | |
| 58 from appengine_module.chromium_status import profiling | |
| 59 from appengine_module.chromium_status import static_blobs_inline | |
| 60 from appengine_module.chromium_status import static_blobs_store | |
| 61 from appengine_module.chromium_status import status | |
| 62 from appengine_module.chromium_status import utils | |
| 63 from appengine_module.chromium_status import xmpp | |
| 64 | |
| 65 utils.bootstrap() | |
| 66 | |
| 67 def remove(entity, functor, batch=100): | |
| 68 """Remove entries.""" | |
| 69 count = 0 | |
| 70 items = [] | |
| 71 while True: | |
| 72 entries = [i for i in entity.all().fetch(limit=batch) if functor(i)] | |
| 73 count += len(entries) | |
| 74 print '%s' % count | |
| 75 if entries: | |
| 76 db.delete(entries) | |
| 77 else: | |
| 78 break | |
| 79 | |
| 80 # Symbols presented to the user. | |
| 81 predefined_vars = locals() | |
| 82 | |
| 83 prompt = ( | |
| 84 'App Engine interactive console for "%s".\n' | |
| 85 'Available symbols:\n' | |
| 86 ' %s\n') % (app_id, ', '.join(sorted(predefined_vars))) | |
| 87 code.interact(prompt, None, predefined_vars) | |
| 88 | |
| 89 | |
| 90 if __name__ == '__main__': | |
| 91 sys.exit(main()) | |
| OLD | NEW |