def printLogOffSubMenu(stdscr,con): selection = -2 option = 0 while selection < 0: graphics = [0]*2 graphics[option] = curses.A_REVERSE stdscr.refresh() stdscr.clear() stdscr.addstr(4, 2, "----------------------------------------------------------------------------") stdscr.addstr(6, 30, "-- LOG OFF --") stdscr.addstr(10, 13, "Are you sure you'd like to log off?") stdscr.addstr(13, 13, "Log Off",graphics[0]) stdscr.addstr(13, 35, "Return to Program",graphics[1]) # Collect user's navigation selection action = stdscr.getch() if action == curses.KEY_RIGHT: option = (option - 1) % 2 elif action == curses.KEY_LEFT: option = (option + 1) % 2 elif action == (ord('\n')): selection = option stdscr.clear() # If user wants to disconnect... Exit if selection == 0: # Close connection with db and exit con = database_queries.dbClose(con) curses.endwin() exit() # Return to main menu if selection == 1: printMainMenu(stdscr,con)
if response[1] == 'SELECT': # Print rows of a table if SELECT was chosen # print each row print '\nROWS IN SELECT:' for idx,row in enumerate(con['rows']): print 'row ' + str(idx) + ': ' + str(row) # print row count of table print 'Row Count: ' + str(con['row_cnt']) # Print the number of rows in the SELECT call else: # Query failed print 'Failed!', if VERBOSE: print '[' + con['msg'] + ']' # Print asssociated failure message print '\n--------------------------------------------' print 'Close Connection with Database' print '--------------------------------------------' print 'Attempt to disconnect...', con = database_queries.dbClose(con) # Attempt to close connection if con['state'] == 1: # Detect if connection state is closed print 'Disconnected!', elif con['state'] == 0: # Connection still exists (or atleast the state indicates that!) print 'Failed', if VERBOSE: print '[' + con['msg'] + ']' # Print associated debug message print '\n'