forked from baz/app-sales-machine
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshell.py
80 lines (65 loc) · 2.24 KB
/
shell.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
import getpass
import os
import sys
## Application specific
SDK_DIR = '/usr/local/google_appengine'
APP_DIR = os.getcwd()
APPID = 'jgaappsales'
REMOTE_API_PATH = '/remote_api'
## Extra paths to be inserted into sys.path,
## including the SDK, it's libraries, your APPDIR, and APPDIR/lib
EXTRA_PATHS = [
SDK_DIR,
os.path.join(SDK_DIR, 'lib', 'antlr3'),
os.path.join(SDK_DIR, 'lib', 'django'),
os.path.join(SDK_DIR, 'lib', 'webob'),
os.path.join(SDK_DIR, 'lib', 'yaml', 'lib'),
APP_DIR,
#os.path.join(APP_DIR, 'lib'),
]
sys.path = EXTRA_PATHS + sys.path
from google.appengine.ext.remote_api import remote_api_stub
def attach(host=None):
def auth_func():
if host and host.startswith('localhost'):
return ('foo', 'bar')
else:
email = raw_input("Email: ")
return (email, getpass.getpass())
remote_api_stub.ConfigureRemoteApi(APPID, REMOTE_API_PATH, auth_func, host)
remote_api_stub.MaybeInvokeAuthentication()
os.environ['SERVER_SOFTWARE'] = 'Development (remote_api)/1.0'
if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == '-l':
host = 'localhost:8080'
else:
host = None
attach(host)
from google.appengine.ext import db
from google.appengine.api import memcache
BANNER = "App Engine remote_api shell\n" + \
"Python %s\n" % sys.version + \
"The db, and memcache modules are imported."
## Use readline for completion/history if available
try:
import readline
except ImportError:
pass
else:
HISTORY_PATH = os.path.expanduser('~/.remote_api_shell_history')
readline.parse_and_bind('tab: complete')
if os.path.exists(HISTORY_PATH):
readline.read_history_file(HISTORY_PATH)
import atexit
atexit.register(lambda: readline.write_history_file(HISTORY_PATH))
sys.ps1 = '%s <-- ' % (host or APPID)
#import code
#code.interact(banner=BANNER, local=globals())
#import models
#from models import *
from models.data import *
#import IPython
#IPython.Shell.IPShell(argv = [], user_ns=globals()).mainloop(sys_exit=1)
from bpython import cli
cli.main(args=[], locals_=globals(), banner=BANNER)