.. link: http://dgplug.org/summertraining/2013/posts/resham-myshellv1-20130719-025856.html .. description: .. tags: .. date: 2013/07/19 02:58:56 .. title: resham Myshellv1 20130719-025856 .. slug: resham-myshellv1-20130719-025856 Problem ------- 1.To get "hi username" as output on giving greet command. 2.To get stock value of GOOG on giving stockGOOG command. Solution --------- from cmd2 import Cmd from getpass import getuser import requests import sys __version__ = '0.1' class Application(Cmd): """ The main Application class """ def __init__(self): Cmd.__init__(self) def do_hello(self, line): print "Hello:", line def do_sayit(self,line): print "Python Rocks!" def do_greet(self,line): print "hi,%s" % (getuser()) def do_stockgoog(self,line): link = requests.get("http://download.finance.yahoo.com/d/quotes.csv?s=GOOG&f=l1") stockvalue=r.text print stockvalue if __name__ == '__main__': app = Application() app.cmdloop() Commands -------- $python psh.py Link ---- The link of actual file is https://github.com/resham/summer-training-hometask/blob/master/psh.py