Oct-21-2018, 03:20 PM
Hi.
I'm trying to write a BBS lister script in Python (obviously). But, whenever I try to execute the script, I get this error:
File "./proj.py", line 14
c = 0;
^
IndentationError: expected an indented block
I've made sure that the indentation is correct, yet I still get this error.
Can someone please tell me what's wrong with my code?
Thank you.
I'm trying to write a BBS lister script in Python (obviously). But, whenever I try to execute the script, I get this error:
File "./proj.py", line 14
c = 0;
^
IndentationError: expected an indented block
I've made sure that the indentation is correct, yet I still get this error.
Can someone please tell me what's wrong with my code?
Thank you.
#!/usr/bin/env python from os import system import curses import sys from sites import sites commands = [" add ", " connect ", " information ", " help ", " quit "]; def execute_cmd(cmd_string): def character(stdscr): c = 0; screen = curses.initscr(); while c != ord('q') and c != ord('Q'): attributes = {} curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) attributes['normal'] = curses.color_pair(1) curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLUE) attributes['highlighted'] = curses.color_pair(2) c = 0 # last character read option = 0 # the current option that is marked option2 = 0 while c != 10: # Enter in ascii stdscr.erase() for i in range(len(commands)): if i == option: attr = attributes['highlighted'] else: attr = attributes['normal'] stdscr.addstr("{0}. ".format(i + 1)) stdscr.addstr(commands[i] + '', attr) for j in range(len(sites)): if j == option2: attr = attributes['highlighted'] else: attr = attributes['normal'] stdscr.addstr("{0}. ".format(j + 1)) stdscr.addstr(sites[j] + '\n', attr) c = stdscr.getch() if c == curses.KEY_LEFT and option > 0: option -= 1 elif c == curses.KEY_RIGHT and option < len(commands) - 1: option += 1 if c == curses.KEY_UP and option2 > 0: option2 -= 1 elif c == curses.KEY_DOWN and option < len(sites) - 1: option2 += 1 elif c == 10 and option2 == 1: i = option; screen.clear(); curses.endwin(); execute_cmd( sites[j][1] + " " + sites[j][2] ); #break; elif c == 10 and option2 == 0: i = option; screen.clear(); curses.endwin(); sysopname = raw_input("^[[2J^[[H^[[1;34mname of sysop^[[0;34m: ^[[0;37m" ) type(sysopname); bbsname = raw_input("^[[1;34mname of bbs^[[0;34m: ^[[0;37m" ) type(bbsname); address = raw_input("^[[1;34mtelnet address^[[0;34m: ^[[0;37m") type(address); software = raw_input("^[[1;34msoftware^[[0;34m: ^[[0;37m"); type(software); saveFile = open("bbslist","a") file = open("sites.py", "a+") saveFile.write(sysopname) saveFile.write("\n") saveFile.write(bbsname) saveFile.write("\n") saveFile.write(address) saveFile.write("\n") saveFile.write(software) saveFile.write("\n") saveFile.close() system("cat sites.py | sed -e 's/];//g' > sites") system("mv sites sites.py") system("sed -i -e '$a ,' sites.py") file = open("sites.py", "a") file.write('["') file.write(bbsname) file.write('", "telnet", ') file.write('"') file.write(address) file.write('"]') file.write('\r\n];') file.close() elif c == 10 and option2 == 2: i = option; screen.clear(); curses.endwin(); print("INFO"); elif c == 10 and option2 == 3: i = option; elif c == 10 and option2 == 4: i = option; screen.clear(); curses.endwin(); screen.clear(); curses.endwin(); curses.wrapper(character)