German Larrain avatar German Larrain committed d825239

demo_runner: changed "while" loop to use new options and funtions, making output
less verbose (the demo list is not displayed in every prompt).

Comments (0)

Files changed (1)

 
 def main():
 	user_input = None
+	print(INTRODUCTION_MSG)
 
-	while user_input != 'q':
-		show_demo_list()
-		user_input = raw_input('Select an option (%s to quit): ' % QUIT_STR)
+	while True:
+		print(INSTRUCTIONS)
+		user_input = raw_input('value: ')
+		user_input = user_input.strip().lower()
 
-		if user_input.strip().lower() == QUIT_STR:
+		if user_input == 'd':
+			show_demo_list()
+
+		elif user_input == QUIT_STR:
 			print('Bye')
 			return 0
 
-		try:
-			selected_demo_index = int(user_input)
-		except ValueError:
-			print('Error, invalid input')
-			return 1
-
-		try:
-			selected_demo = DEMOS[selected_demo_index]  # (module, class_name)
-		except IndexError:
-			print('Error, option number is out of range')
-			return 2
-		module = import_module(DEMOS_PACKAGE_PREFIX + '.' + selected_demo[0])
-		klass = getattr(module, selected_demo[1])
-
-		sim_program = klass()
-		sim_program.start()
-		try:
-			sim_program.print_final_data()
-		except AttributeError:
-			pass
-		sim_program.finalize()
+		else:
+			run_demo(user_input)
 
 if __name__ == '__main__':
 	exit_value = main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.