Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 36 lines (27 sloc) 982 Bytes
#!/usr/bin/env python
from getpass import getpass
from optparse import OptionParser
import posterous
"""Launch an interactive shell ready for Posterous usage
This script is handy for debugging posterous during development
or to just play around with the library.
It imports posterous and creates an authenticated API instance (api)
using the credentials provided.
"""
opt = OptionParser(usage='posterous-shell <username> <password>')
options, args = opt.parse_args()
if len(args) == 1:
username, password = args[0], getpass()
elif len(args) == 2:
username, password = args[0], args[1]
else:
username, password = None, None
local_ns = {'posterous': posterous, 'api': posterous.API(username, password)}
shellbanner = '<Posterous shell>'
try:
import IPython
ipshell = IPython.Shell.IPShell([''], user_ns = local_ns)
ipshell.mainloop(sys_exit=1, banner = shellbanner)
except ImportError:
import code
code.interact(shellbanner, local = local_ns)