update README
[gaetalk.git] / remoteshell
blob424cef21b71fc00a94990166fb6905ec16a4977a
1 #!/usr/bin/python2
2 # vim:fileencoding=utf-8
3 import code
4 import getpass
5 import sys
7 sys.path.append('/opt/google-appengine/lib/yaml/lib')
8 sys.path.append('/opt/google-appengine/lib/fancy_urllib')
10 from google.appengine.ext.remote_api import remote_api_stub
11 from google.appengine.ext import db
12 from google.appengine.api import xmpp
14 def auth_func():
15   return raw_input('Username: '), getpass.getpass('Password: ')
17 if len(sys.argv) < 2:
18   print "Usage: %s app_id [host]" % (sys.argv[0],)
19   sys.exit(1)
20 app_id = sys.argv[1]
21 if len(sys.argv) > 2:
22   host = sys.argv[2]
23 else:
24   host = '%s.appspot.com' % app_id
26 remote_api_stub.ConfigureRemoteDatastore(app_id, '/remote_api', auth_func, host, secure=True)
28 import atexit
29 import readline
30 import rlcompleter # Tab 补全需要这个
31 import os
33 readline.parse_and_bind('tab: complete')
34 historyPath = ".gaehistory"
36 def save_history(historyPath=historyPath):
37     import readline
38     readline.write_history_file(historyPath)
40 if os.path.exists(historyPath):
41     readline.read_history_file(historyPath)
42 readline.set_history_length(1000)
44 atexit.register(save_history)
45 del atexit, readline, save_history, historyPath
47 code.interact('App Engine interactive console for %s' % (app_id,), None, locals())