def prompt_user(self):
        self.clear_menu()

        name = prompt('Enter user Name')
        screen_name = prompt('Enter screen_name')

        self.bird.create_new_user(name, screen_name)

        print('Your new user has been created')
        pause()
    def prompt_create_payment(self):
        self.clear_menu()

        if not self.bang.is_active_customer():
            pause('You must choose a customer account first')
            return

        payment_type = prompt('Enter Payment Type (e.g. AmEx, Visa, Checking)')
        account_number = prompt('Enter Account Number')
        self.bang.create_new_payment(payment_type, account_number, self.bang.active_customer_id)

        print('New Payment Option created as {} with account number {}'
            .format(payment_type, account_number))
        pause()
    def prompt_create_chirp(self):
        self.clear_menu()

        if self.bird.active_user_id == 0:
            pause('You must choose a user account first')
            return

        chirp_type = prompt('Enter Chirp Type (e.g. Public or Private)')
        chirp_title = prompt('Enter Account Number')
        self.bird.create_new_chirp(chirp_type, chirp_title, self.bird.active_user_id)

        print('New chirp created as {} with title {}'
            .format(chirp_type, chirp_title))
        pause()
def RunTimeModule(dataset):

	# Define a boolean variable
	x = True

	while (x==True):

		try:
			print "\nType '1' to view a time series of complaints by borough.\nType '2' to view a time series of complaints by agency.\nType 'Finish' to exit."

			method = raw_input()

			if method.capitalize() == 'Finish':
				break

			elif method in ['1', '2']:

				# Put the borough analysis method
				if method == '1':
					time_interval = TakeUserInput()
					try:
						if time_interval.capitalize() == "Finish":
							break
					except:
						print "\nThis will take a few moments...\n"
						time_analysis = Plot_TimeSeries(time_interval[0], time_interval[1])
						time_analysis.Plot_BoroGraphs(dataset)
					x = prompt()

				# Put the agency analysis method
				elif method == '2':
					time_interval = TakeUserInput()
					agencies = list(dataset.Agency.unique())
					agency = ui.get_agency(agencies)
					try:
						if time_interval.capitalize() == "Finish" or agency.capitalize=="Finish":
							break
					except:
						print "\nThis will take a few moments...\n"
						time_analysis = Plot_TimeSeries(time_interval[0], time_interval[1])
						time_analysis.Plot_AgencyGraphs(dataset, agency)
					x = prompt()
			else:
				print "Please type the inputs '1', '2' or 'Finish'."

		except ValueError:
			print "\nOops!  Invalid input."
		except KeyboardInterrupt:
			print '\nYou pressed Ctrl+C! Exiting...'
			sys.exit() 
    def prompt_customer(self):
        self.clear_menu()

        name = prompt('Enter Customer Name')
        address = prompt('Enter Street Name')
        city = prompt('Enter City')
        state = prompt('Enter State')
        zipcode = prompt('Enter Zip Code')
        phone = prompt('Enter Phone Number')
        self.bang.create_new_user(name, address, city, state, zipcode, phone)

        print(name + ' has been created')
        pause()
    def prompt_complete_order(self):
        self.clear_menu()
        if not self.bang.is_active_order():
            pause('You must have an active order before you can checkout')
            return

        order_total = float(sql.select_order_total(self.bang.active_order_id)[0])
        should_continue = prompt('Your order total is ${:.2f}. Pay now? [\033[32mY\033[37m/n]'
                                    .format(order_total))

        if should_continue and should_continue.lower()[0] == 'n': return

        payment_menu = self.bang.get_payment_options(self.bang.active_customer_id)
        chosen_payment = show_menu('Choose Your Payment Method', payment_menu, '')
        self.bang.pay_order(chosen_payment[0])

        print('Your order is complete! You paid ${:.2f} with your {}.'.format(
            order_total,
            chosen_payment[0]))
        pause()
Example #7
0
if __name__ == "__main__":
	server = ThreadedNetChallonged((HOST, PORT), NerdHandler)

	def shutUp():
		print ("Shuting down.. eh, up")
		server.shutdown()
		exit()

	print ( "The Challonge is alive" )
	serveraddr, serverport = server.server_address
	try:
		serverThread = threading.Thread(target=server.serve_forever)
		serverThread.setDaemon(True)
		serverThread.start()
		while 1:
			cmd = prompt("Code::Phun->NetChallongeD>> ")
			if "quit" in cmd:
				shutUp()


			if "help" in cmd:
				args = cmd.split(" ")
				
				#Lists all cmds
				if len(args) == 1:
					for k in ["load", "scores", "quit", "help", "users", "load state", "save state", "challenges"]:
						print (k)
					print ("Usage help [<command>]  \n if no command given, it lists all commands")
					continue

				if "load" in args[1]:
Example #8
0
		raise Exception("Please make sure all the files in the same folder.")
		sys.exit()
	except KeyboardInterrupt:
		print ('You have touch the keyboard!')
		quitproject()
	i = True
	while (i == True):
		try:
			method = raw_input('Which method among the three u want to try?\n(You can type in "quit" to quit the program.)\n'+"1.Top Agency Complaints for each Zipcode\n"+
				"2.Compare two agencies' complaints\n"+"3.Use circles to represent complaints number for each Zipcode\n"+'Type number 1, 2, or 3:\n')
			if method == 'quit' or method == 'q' or method =='Q' or method == 'Quit':
				sys.exit()
			if int(method) > 3:
				print ('\n!!Please select one of the numbers.(1, 2, or 3)\n')
			if int(method) == 1:
				mapPoints = getmapPoints(complaintsdata)
				k.TopAgencyforEachzipCode(mapPoints,dat)
				prompt()
			if int(method) == 2:
				m = getinput()
				agencymapPoints = getagencymapPoints(complaintsdata,m[0],m[1])
				k.comparetowagencies(agencymapPoints,dat)
				prompt()
			if int(method) ==3:
				zipmapPoints = getzipmapPoints(complaintsdata)
				k.plotzipcomplaints(zipmapPoints,dat)
				prompt()
			
		except ValueError:
			raise Exception ('There is a problem with the input you gave, please check it and run the program again.')
		
Example #9
0
if __name__ == "__main__":
    server = ThreadedNetChallonged((HOST, PORT), NerdHandler)

    def shutUp():
        print("Shuting down.. eh, up")
        server.shutdown()
        exit()

    print("The Challonge is alive")
    serveraddr, serverport = server.server_address
    try:
        serverThread = threading.Thread(target=server.serve_forever)
        serverThread.setDaemon(True)
        serverThread.start()
        while 1:
            cmd = prompt("Code::Phun->NetChallongeD>> ")
            if "quit" in cmd:
                shutUp()

            if "help" in cmd:
                args = cmd.split(" ")

                #Lists all cmds
                if len(args) == 1:
                    for k in [
                            "load", "scores", "quit", "help", "users",
                            "load state", "save state", "challenges"
                    ]:
                        print(k)
                    print(
                        "Usage help [<command>]  \n if no command given, it lists all commands"
Example #10
0
    while (i == True):
        try:
            method = raw_input(
                'Which method among the three u want to try?\n(You can type in "quit" to quit the program.)\n'
                + "1.Top Agency Complaints for each Zipcode\n" +
                "2.Compare two agencies' complaints\n" +
                "3.Use circles to represent complaints number for each Zipcode\n"
                + 'Type number 1, 2, or 3:\n')
            if method == 'quit' or method == 'q' or method == 'Q' or method == 'Quit':
                sys.exit()
            if int(method) > 3:
                print('\n!!Please select one of the numbers.(1, 2, or 3)\n')
            if int(method) == 1:
                mapPoints = getmapPoints(complaintsdata)
                k.TopAgencyforEachzipCode(mapPoints, dat)
                prompt()
            if int(method) == 2:
                m = getinput()
                agencymapPoints = getagencymapPoints(complaintsdata, m[0],
                                                     m[1])
                k.comparetowagencies(agencymapPoints, dat)
                prompt()
            if int(method) == 3:
                zipmapPoints = getzipmapPoints(complaintsdata)
                k.plotzipcomplaints(zipmapPoints, dat)
                prompt()

        except ValueError:
            raise Exception(
                'There is a problem with the input you gave, please check it and run the program again.'
            )
Example #11
0
	def promptCall(self):
		prompt()
Example #12
0
def RunMapModule(complaintsdata):

    try:
        # Load zipcode data with pandas
        zipcodedata = pd.read_csv(sys.argv[2])

        # Load shapefiles
        dat = shapefile.Reader(sys.argv[3])

        zipBorough = getzipBorough(zipcodedata)
        k = plotMaps(zipBorough)

    # Check for all the files
    except IOError:
        raise Exception("Please make sure all the files in the same folder.")
        sys.exit()

    # Check for a keyboard interrupt
    except KeyboardInterrupt:
        print('You have interrupted the program!')
        quitproject()

    # Set a boolean variable to check for the while loop
    i = True
    while (i == True):
        # Start to take the input
        try:
            method = raw_input(
                'Which method among the three u want to try?\n(You can type in "Finish" to quit the program.)\n'
                + "1.Top Agency Complaints for each Zipcode\n" +
                "2.Compare two agencies' complaints\n" +
                "3.Use circles to represent complaints number for each Zipcode\n"
                + 'Type number 1, 2, or 3:\n')
            if method.capitalize() == 'Finish':
                break

            elif method in ['1', '2', '3']:

                if int(method) == 1:
                    print "The map is generating. This will take a few moments..."
                    mapPoints = getmapPoints(complaintsdata)
                    k.TopAgencyforEachzipCode(mapPoints, dat)
                    i = prompt()
                elif int(method) == 2:
                    print "\nPlease select the first agency."
                    a1 = get_agency()
                    print "\nPlease select the second agency."
                    a2 = get_agency()
                    print "The map is generating. This will take a few moments..."
                    agencymapPoints = getagencymapPoints(
                        complaintsdata, a1, a2)
                    k.comparetowagencies(agencymapPoints, dat)
                    i = prompt()
                elif int(method) == 3:
                    print "The map is generating. This will take a few moments..."
                    zipmapPoints = getzipmapPoints(complaintsdata)
                    k.plotzipcomplaints(zipmapPoints, dat)
                    i = prompt()

            else:
                print('\nPlease select one of the numbers.(1, 2, or 3)\n')

        except ValueError:
            raise Exception(
                'There is a problem with the input you gave, please check it and run the program again.'
            )
        except KeyboardInterrupt:
            print '\nYou pressed Ctrl+C! Exiting...'
            sys.exit()
+from prompt_toolkit import prompt
 from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
 from prompt_toolkit.history import FileHistory
-from prompt_toolkit.layout.lexers import PygmentsLexer
-from prompt_toolkit.styles.from_pygments import style_from_pygments
+from prompt_toolkit.lexers import PygmentsLexer
+from prompt_toolkit.styles.pygments import style_from_pygments_cls
 from pygments.styles import get_style_by_name
 from pygments.util import ClassNotFound
 from six.moves.http_cookies import SimpleCookie
@@ -135,7 +135,7 @@ def cli(spec, env, url, http_options):
         style_class = get_style_by_name(cfg['command_style'])
     except ClassNotFound:
         style_class = Solarized256Style
-    style = style_from_pygments(style_class)
+    style = style_from_pygments_cls(style_class)
 
     listener = ExecutionListener(cfg)
 
@@ -159,7 +159,9 @@ def cli(spec, env, url, http_options):
             text = prompt('%s> ' % context.url, completer=completer,
                           lexer=lexer, style=style, history=history,
                           auto_suggest=AutoSuggestFromHistory(),
-                          on_abort=AbortAction.RETRY, vi_mode=cfg['vi'])
+                          vi_mode=cfg['vi'])
+        except KeyboardInterrupt:
+            continue  # Control-C pressed
         except EOFError:
             break  # Control-D pressed
         else:
Example #14
0
if __name__ == "__main__":
    server = ThreadedNetChallonged((HOST, PORT), NerdHandler)

    def shutUp():
        print ("Shuting down.. eh, up")
        server.shutdown()
        exit()

    print ("The Daemon is alive")
    serveraddr, serverport = server.server_address
    try:
        serverThread = threading.Thread(target=server.serve_forever)
        serverThread.setDaemon(True)
        serverThread.start()
        while 1:
            cmd = prompt("Communica->Geoipd>> ")
            if "quit" in cmd:
                shutUp()

            if "help" in cmd:
                args = cmd.split(" ")

                #Lists all cmds
                if len(args) == 1:
                    for k in ["help", "quit", "lookup"]:
                        print (k)
                    print ("Usage help [<command>]  \n if no command given, it lists all commands")
                    continue

                if "lookup" in args[1]:
                    print("""