def node_list(args: dict): # get all args from cli verbose = args.get('verbose') ip = args.get('ip') debug = args.get('debug') filter_string = args.get('krakenctl_node_list_filter') node_id = args.get("krakenctl_node_info_node_id") list_type = args.get("krakenctl_node_list_type") print_json_bool = args.get("krakenctl_node_list_json") if debug: print("node list got args: {}".format(args)) # build the urls dsc_url = build_url(ip, "dsc/nodes") cfg_url = build_url(ip, "cfg/nodes") # if a node_id is defined, only get info for that node if node_id != None: dsc_url = build_url(ip, "dsc/node") dsc_url = "{}/{}".format(dsc_url, node_id) cfg_url = build_url(ip, "cfg/node") cfg_url = "{}/{}".format(cfg_url, node_id) list_type = args.get("krakenctl_node_info_type") print_json_bool = args.get("krakenctl_node_info_json") filter_string = args.get("krakenctl_node_info_filter") verbose = True # fetch the cfg and dsc data from kraken dsc_json = get_url(dsc_url, debug, verbose) cfg_json = get_url(cfg_url, debug, verbose) # regardless of if we are getting a single node or multiple, put them in their respective lists dsc_nodes = [] cfg_nodes = [] if node_id != None: dsc_nodes = [dsc_json] cfg_nodes = [cfg_json] else: dsc_nodes = dsc_json.get("nodes") cfg_nodes = cfg_json.get("nodes") # Handle the different types. # For dsc we merge in just node names # For mixed we merge everything from dsc into cfg if list_type == 'cfg': if debug: print("state type is cfg") final_nodes = cfg_nodes elif list_type == 'dsc': if debug: print("state type is dsc") final_nodes = merge_nodename(dsc_nodes, cfg_nodes) elif list_type == 'mixed': if debug: print("state type is mixed") no_state_cfg_nodes = remove_state_list(cfg_nodes) final_nodes = merge_list(no_state_cfg_nodes, dsc_nodes) # Do any provided filteres if filter_string is not None: final_nodes = filter_list(filter_string, final_nodes) dsc_nodes = filter_list(filter_string, dsc_nodes) cfg_nodes = filter_list(filter_string, cfg_nodes) # Print out json or table if print_json_bool: if node_id != None: dsc_nodes = dsc_nodes[0] cfg_nodes = cfg_nodes[0] final_nodes = final_nodes[0] else: dsc_nodes = {"nodes": dsc_nodes} cfg_nodes = {"nodes": cfg_nodes} final_nodes = {"nodes": final_nodes} if list_type == 'mixed': print("CFG:\n") print_json(cfg_nodes, verbose) print("\nDSC:\n") print_json(dsc_nodes, verbose) else: print_json(final_nodes, verbose) else: print_table(final_nodes, verbose=verbose)
def option_6(): t.print_table("fav drinks", fav_drinks_list) wait()
def print_favourites(self): items = [] for name, drink in self.fave_dict.items(): items.append(f'{name} favourite drink is {drink}') print_table('favourites', items)
def run_season_md(season): """ Calculates all results of one matchday and prints the tables of all leagues played in that matchday Input: instance of object season Output: printed results and table of all leagues """ md = season.matchday s = season.get_season_count() # i = Spieltag # j = Spiel / Spieltag """Kleines Problem: Aktuell muessen alle Ligen gleich viele Teams haben (siehe folgende while Schliefe mit Iterator i)""" if md < (len(season.leagues[0].teams)) - 1: for k in range(0, len(season.leagues)): j = 0 print(str(md + 1) + ". Spieltag - " + str(k + 1) + ". Liga") print("") while (j < len(season.leagues[k].teams) / 2): game.game_improved(season.leagues[k].first_leg[md][j][0], season.leagues[k].first_leg[md][j][1], s, season.matchday) j = j + 1 print "" table.print_table(season.leagues[k].teams) print "_____________________________________________" print "" print "" if md >= (len(season.leagues[0].teams)) - 1: md_sl = md - (len(season.leagues[0].teams)) - 1 for k in range(0, len(season.leagues)): j = 0 print(str(md + 1) + ". Spieltag - " + str(k + 1) + ". Liga") print("") while (j < len(season.leagues[k].teams) / 2): game.game_improved(season.leagues[k].second_leg[md_sl][j][0], season.leagues[k].second_leg[md_sl][j][1], s, season.matchday) j = j + 1 print("") table.print_table(season.leagues[k].teams) print "_____________________________________________" print "" print "" #~ season.matchday = season.matchday + 1 end_matchday(season) #~ add_del_trainer_player_fh(season,1,1) if season.matchday < (len(season.leagues[0].teams) - 1) * 2: for i in range(0, len(season.leagues)): for j in range(0, len(season.leagues[i].teams)): season.leagues[i].teams[j].finances.cost_mds[s].append(0) season.leagues[i].teams[j].finances.income_mds[s].append(0) if season.matchday == (len(season.leagues[0].teams) - 1) * 2: season = end_season(season)
if __name__ == "__main__": while True: print_menu() option = get_selection('Enter your selection:') if not option: print( "That option is invalid, Please only use numbers to select from the menue" ) wait() continue # Handle arguments if option == GET_PEOPLE_ARG: print_table('People', people) wait() elif option == GET_DRINKS_ARG: print_table('Drinks', drinks) wait() elif option == EXIT_ARG: print(f'Thank you for using {APP_NAME}') wait() exit() elif option == VIEW_DRINK: un_pack(peoplesDrinks) wait()
def return_items(self): items = [] for name, drink in self.orders.items(): items.append(f'{name},{drink}') print_table(f"{self.owner}'s round", items)
def option_8(): t.print_table(f"{server} is making the round", round_list) wait()
def option_7(): t.print_table(f"{server} is making the round", round_list) create_an_order() round_maker_loop()
def create_an_order(): name_add = name_input() drink_add = drink_input() round_list.append(f"{name_add} ordered {drink_add}") t.print_table(f"{server} is making the round", round_list)
def master_room(): global basket global room_entered global counter global counter_i cond = True counter_i += 1 while cond: inp = raw_input('Which room? >>> ').lower() if inp == 'blue': blue_room() elif inp == 'red': red_room() elif inp == 'green' and not room_entered: print ''' Here is Green room, which contains a tiger. you must really so lucky if you open the door and our little friend was slept, if not, I can only tell you rest in peace my friend ;) You can enter to the room and if the tiger was slept, then you can 'search' and 'claim' all the golds were there. also you must type 'return' for return to master room and resume searching for other room's golds. and the golds you can found there was between 0 and 250 !!! Remember that survive may be impossible if the tiger was awakened ;) >>> For enter to the room, Retype 'green' *** ''' room_entered = True elif inp == 'green' and room_entered: green_room() elif inp == 'basket': print basket, '\n' master_room() elif inp == 'table': table.print_table() elif inp == 'clear table': table.clear_list() elif inp == 'exit': print '\nDo you want save your points?\n Y or N ?' ex_inp = raw_input('> ').lower() if ex_inp == 'y': #*********************************************************************** if len(table.points) > 0 and basket in counter.itervalues(): print '\nYour point is similar to the last\n' elif basket == 0: print "\nYour point is 0 and you can't save that.\n" else: counter[counter_i] = basket table.points.append(basket) table.savePoint(table.points) print '\nYour point was saved ! Now the table is: ', table.loadPoint( ), '\n' #sys.exit(0) #************************************************************************* else: print '\nYour points not saved. Good luck ;)\n' sys.exit(0) else: print 'You must enter a valid Value\n' master_room()
import psycopg2 import unicodedata import table host = 'host=iServDB.cloudopenlab.org.tw port=5432' dbname = 'dbname=stanley811213_db_7744' login_info = 'user=stanley811213_user_7744 password=OUvWLGmm' conn = psycopg2.connect(host + ' ' + dbname + ' ' + login_info) cur = conn.cursor() query = raw_input('Input: ') cur.execute("SELECT text, user_name, user_id FROM twitter WHERE q='" + query + "';") result = cur.fetchall() final_result = sorted(result, key=lambda x: int(x[2])) table.print_table(final_result) cur.close() conn.close()