-
Notifications
You must be signed in to change notification settings - Fork 3
/
shell.py
executable file
·58 lines (46 loc) · 1.74 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
#!bin/python -i
# Author: Leo Vidarte <http://nerdlabs.com.ar>
#
# This file is part of lai-client.
#
# lai-client is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3
# as published by the Free Software Foundation.
#
# lai-client is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with lai-client. If not, see <http://www.gnu.org/licenses/>.
import sys
import atexit
import os
import readline
import rlcompleter
from lai import config, Client, Database, Document
historyPath = os.path.expanduser("~/.pyhistory")
#readline.parse_and_bind('tab: menu-complete')
readline.parse_and_bind('tab: complete')
def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)
if os.path.exists(historyPath):
readline.read_history_file(historyPath)
atexit.register(save_history)
del os, atexit, readline, rlcompleter, save_history, historyPath
database = Database(**config.database)
client = Client(database)
print "Python", sys.version.split('\n')[0]
print "Welcome to lai shell"
print "Autocompletion and history are enabled"
print ""
print "Lai objects:"
print " config (module) from lai import config"
print " Database (class) from lai import Database"
print " Client (class) from lai import Client"
print " Document (class) from lai import Document"
print " database (object) database = Database()"
print " client (object) client = Client(database)"
print ""