Exemplo n.º 1
0
def emulateIDU():
	"""Emulate an IDU"""
	ui.clear()
	ui.setInIDU(True)
	ui.writeToConsole(etc.IDU_TEXT)
	opsys.setTitleText("COM5:38400baud - Tera Term VT")
	
	ui.getUserMsg("", sleepEn=False, pwd=True, log=False)
	getUser = True
	while getUser:
		username = ""
		while username == "":
			username = ui.getUserMsg("SDIDU login: "******"Password: "******"factory") or (username == "root")
		if user and ((password == "exit") or (password == "arct1c")):
			opsys.exit()
		elif user and (password == "resume"):
			getUser = False
		else:
			ui.writeToConsole("Login incorrect")
	
	opsys.setTitleText(TITLE)
	ui.clear()
	ui.setInIDU(False)
	ui.writeToConsole(msgLog)
Exemplo n.º 2
0
def main():
    gc.collect()  # Garbage collect

    # Check arguments
    if len(sys.argv) < 2:
        return showUsage()
    ui.clear()
    # Pre-process PDFs
    dirname = sys.argv[1]
    images, targets, plotType = pproc.processPDFs(dirname)

    # Extract feature vectors (until user quits)
    doneExtracting = False
    while not doneExtracting:
        data, ftType = ft.extract_features(images)

        # Create, train, and evaluate model (until user quits)
        doneTraining = False
        while not doneTraining:
            tr.train(data, targets, plotType, ftType)
            options = ["Try another model", "Extract new features", "Quit"]
            res = ui.prompt(options=options)
            if options[int(res)] == "Quit":
                doneTraining = True
                doneExtracting = True
            elif options[int(res)] == "Extract new features":
                doneTraining = True
        gc.collect()  # Garbage collect
Exemplo n.º 3
0
def main():
    ui.clear()
    while True:
        handle_menu()
        try:
            choose()
        except KeyError as err:
            ui.clear()
            ui.print_error(str(err))
Exemplo n.º 4
0
def ainspect(): #function för att printa en del utav ui
    ui.clear() #Clear call
    ui.line(False)  # printar en linje gjord utav *
    ui.header("ARTIST DATABASE")
    ui.line(True)  # printar en linje gjord utav -
    web.inspectart() #kallar på funktionen som tar fram informationen på specifika artister.
    ui.line(False)  # printar en linje gjord utav *
    ui.echo("| Press enter to return ")  # Printar våra val
    ui.line(False)  # printar en linje gjord utav *
    ui.prompt()
Exemplo n.º 5
0
def alist(): #function för att printa en del utav ui
    ui.clear() #Clear call
    ui.line(False)  # printar en linje gjord utav -
    ui.header("ARTIST DATABASE")
    ui.line(True)  # printar en linje gjord utav *
    web.getart() #kallar på funktionen som tar fram listna av artister
    ui.line(False)  # printar en linje gjord utav -
    ui.echo("| Press enter to return ")  # Printar våra val
    ui.line(False)  # printar en linje gjord utav -
    ui.prompt()
Exemplo n.º 6
0
def main():
    options = [
        ("Store manager", store.start_module),
        ("Human resources manager", hr.start_module),
        ("Inventory manager", inventory.start_module),
        ("Accounting manager", accounting.start_module),
        ("Sales manager", sales.start_module),
        ("Customer Relationship Management (CRM)", crm.start_module),
    ]
    stay = True
    while stay:
        ui.print_menu("Main menu", options, "Exit program")
        try:
            stay = choose(options)
        except KeyError as err:
            ui.print_error_message(err)
    ui.clear()
Exemplo n.º 7
0
def main():
    ui.splash(version)
    if len(sys.argv) < 2:
        filename = ui.chooseFile("No file specified!")
    else:
        filename = sys.argv[1]

    #	r = test.Record(filename)

    data = load.Excel(filename)
    print("Successfully parsed record!")
    r = Record(data)

    if ui.ask("Print response table?"):
        ui.clear()
        print(r.table())
    if ui.ask("Calculate structural summary?"):
        s = structuralSummary.calc(r)
Exemplo n.º 8
0
def start_module():
    ui.clear()
    while True:
        Show_menu()
        try:
            if not choose():
                break
            else:
                ui.get_inputs('\nPress ENTER to continue')
                ui.clear()
        except KeyError as err:
            ui.clear()
            ui.print_error(str(err))
Exemplo n.º 9
0
def clientthread(y, x, height, width, sock):

    color = ui.curses.color_pair(ui.colors['BK/W'])

    color_alt = ui.curses.color_pair(ui.colors['W/BK'])

    ui.window(y, x, height, width, color, False)

    sock.settimeout(0)

    rdy_event.set()

    curs_y, curs_x = y, x

    while True:

        try:
            data = sock.recv(MAX_BYTES)

        except:
            continue

        else:

            ret = data.decode('ascii')

            ret_msg = ''

            if str(ret) in SUCCESS:

                ret_code, ret_msg = SUCCESS[ret][0], SUCCESS[ret][1]

                ui.clear(28, 3, 3, 50)

                ui.message(28, 3, ret_msg)

            elif str(ret) in ERROR:

                ret_code, ret_msg = ERROR[ret][0], ERROR[ret][1]

                ui.clear(28, 3, 3, 50)

                ui.message(28, 3, ret_msg)

                if ret == 'NOMSGS':

                    msg_event[0] = 'NOMSGS'

                    msg_event[1].set()

            else:

                ret = ret.split('\n\n')

                if str(ret[0]) == 'INCMSG':

                    ret = ret[1:]

                    user, msg = ret[0], ret[1]

                    if curs_y > (y + height - 1):

                        curs_y = y

                        ui.window(y, x, height, width, color, False)

                    ui.stdscr.addstr(curs_y, curs_x, 'FROM ' + user, color_alt)

                    curs_x += len('FROM ' + user)

                    ui.stdscr.addstr(curs_y, curs_x, ' ' + msg, color)

                    ui.stdscr.refresh()

                    curs_y, curs_x = (curs_y + 1), x

                elif str(ret[0]) == 'OUTMSG':

                    ret = ret[1:]

                    user, msg = ret[0], ret[1]

                    if curs_y > (y + height - 1):

                        curs_y = y

                        ui.window(y, x, height, width, color, False)

                    ui.stdscr.addstr(curs_y, curs_x, 'TO ' + user, color_alt)

                    curs_x += len('TO ' + user)

                    ui.stdscr.addstr(curs_y, curs_x, ' ' + msg, color)

                    ui.stdscr.refresh()

                    curs_y, curs_x = (curs_y + 1), x

                elif str(ret[0]) == 'INCUSRS':

                    ret = ret[1:]

                    users, status = ret[0::2], ret[1::2]

                    users = users[:-1]

                    collect = []

                    for i in range(len(users)):

                        if int(status[i]): collect.append({'USER': users[i]})

                    usr_event[0] = collect

                    usr_event[1].set()

                elif str(ret[0]) == 'INCMSGS':

                    ret = ret[1:]

                    users, msgs = ret[0::2], ret[1::2]

                    users = users[:-1]

                    collect = []

                    for i in range(len(msgs)):

                        collect.append({'FROM': users[i], 'MESSAGE': msgs[i]})

                    msg_event[0] = collect

                    msg_event[1].set()
Exemplo n.º 10
0
ui.line()
ui.echo("Welcome to a world of")
ui.echo("Musice!")
ui.line()
ui.echo(" L | List artists")
ui.echo(" V | View artist profile")
ui.echo(" E | Exit application")
ui.line()
s = ui.prompt("Selection")
s
# urlen går genom get funktionen från web
url = "https://5hyqtreww2.execute-api.eu-north-1.amazonaws.com/artists/"
r = web.get(url)
# om man skriver in L
if s == "L" or s == "l":
    ui.clear()
    ui.line()
    ui.header("ARTIST DATABASE")
    ui.line()
    ui.echo("Ariana Grande")
    ui.echo("Avicii")
    ui.echo("Blink -182")
    ui.echo("Brad Paisley")
    ui.echo("Ed Sheeran")
    ui.echo("Imagine Dragons")
    ui.echo("Maroon 5")
    ui.echo("Scorpions")
    ui.line(True)
    ui.echo("L | List artists")
    ui.echo("V | View artist profile")
    ui.echo("E | Exit application")
Exemplo n.º 11
0
            "Years Active: " +
            str(info["artist"]["years_active"]))  # information om aktiva år
    else:
        ui.Echo(
            select + "is not present in the database or/ misspelled"
        )  # om artisten som man begärde inte finns i data basen så får man upp ett error medelande


title("ARTIST DB")  # skriver upp titeln
ui.Echo(
    "Welcome to a world of")  # skriver ett medelande som bara skrivs en gång
ui.Echo("Music!")
while (Exit == False
       ):  # en while loop som loopar programmet tills användaren stänger av
    answer = selection()  # frågar användaren vad hen vill göra
    ui.clear()  #rensar det som stod ovan
    title("ARTIST DB")  # skriver titeln igen
    if (
            answer.lower() == "e"
    ):  # om man vill avsluta så rensas consolen och programmet stängs av eftersom exit kriteriet inte längre stämmer
        ui.clear()
        Exit = True
    elif (
            answer.lower() == "l"
    ):  # om man vill se listan av artister så kallar programmet på den funktionen
        List()
    elif (
            answer.lower() == "v"
    ):  # om man vill se en speciell artist så kallar programmet på den funktionen
        view()
Exemplo n.º 12
0
def choose():
    myfile = "position/positions.txt"
    option = ui.get_inputs("\nPlease enter a number: ")
    table = data_manager.imports_from_file(myfile)
    if option == "1":
        ui.clear()
        data_manager.export_to_file(myfile, create_position(table))
    elif option == "2":
        ui.clear()
        idx = ui.get_inputs("Enter the position ID: ")
        if common.check_valid_id(table, idx) == False:
            ui.clear()
            ui.print_error(f"Invalid position ID! ('{idx}')")
        else:
            ui.print_result(
                get_applied_students(read_position(table, idx), idx),
                "Position details")
    elif option == "3":
        ui.clear()
        result = common.read_elements(table)
        if len(result) == 0:
            ui.clear()
            ui.print_error("There are no positions in this list!")
        else:
            show_table(format_seats(result))
    elif option == "4":
        ui.clear()
        idx = ui.get_inputs("Enter position ID: ")
        if common.check_valid_id(table, idx) == False:
            ui.clear()
            ui.print_error(f"Invalid position ID! ('{idx}')")
        else:
            data_manager.export_to_file(
                myfile,
                update_position(
                    table, idx, "description",
                    ui.get_inputs(
                        "Enter the new value of the description.\n")))
    elif option == "5":
        ui.clear()
        idx = ui.get_inputs("Enter position ID: ")
        if common.check_valid_id(table, idx) == False:
            ui.clear()
            ui.print_error(f"Invalid position ID! ('{idx}')")
            return True

        if common.check_data_in_app(idx, "position") == True:
            ui.clear()
            ui.print_error("You cannot delete this position!")
        else:
            data_manager.export_to_file(myfile,
                                        common.delete_element(table, idx))
    elif option == "0":
        ui.clear()
        return False
    else:
        raise KeyError(f"There is no such option. ({option})")
    return True
Exemplo n.º 13
0
def choose():
    myfile = "application/applications.txt"
    option = ui.get_inputs("\nPlease enter a number: ")
    table = data_manager.imports_from_file(myfile)
    if option == "1":
        ui.clear()
        pos_name = ui.get_inputs("Enter a position name to apply: ")
        positions = data_manager.imports_from_file("position/positions.txt")
        student_id = ui.get_inputs("Enter a student id to apply: ")
        students = data_manager.imports_from_file("student/students.txt")
        opt = ui.get_inputs("Enter the status(applied/not applied): ")
        if common.check_valid_id(positions,
                                 pos_name) == False or common.check_valid_id(
                                     students, student_id) == False:
            ui.clear()
            ui.print_error("Non existing position or student!")
        else:
            if opt != "applied" and opt != "not applied":
                ui.clear()
                ui.print_error("Thats not an option")
            else:
                data_manager.export_to_file(
                    myfile,
                    create_applicaion(table, opt, pos_name, student_id,
                                      positions))
    elif option == "2":  ##Update Applications
        ui.clear()
        idx = ui.get_inputs("Enter application ID: ")
        if common.check_valid_id(table, idx) == False:
            ui.clear()
            ui.print_error(f"Invalid application ID! ('{idx}')")
            return True
        else:
            if common.check_if_applied(table, idx) == True:
                ui.clear()
                ui.print_error("You cant modify not applied status")
            else:
                for row in table:
                    if row[0] == idx:
                        row[1] = "not applied"
                data_manager.export_to_file(myfile, table)
    elif option == "3":
        ui.clear()
        idx = ui.get_inputs("Enter application ID: ")
        if common.check_valid_id(table, idx) == False:
            ui.clear()
            ui.print_error(f"Invalid application ID! ('{idx}')")
        else:
            data_manager.export_to_file(myfile,
                                        common.delete_element(table, idx))
    elif option == "4":
        ui.clear()
        result = common.read_elements(table)
        if len(result) == 0:
            ui.clear()
            ui.print_error("There are no application in this list!")
        else:
            show_table(result)
    elif option == "0":
        ui.clear()
        return False
    else:
        raise KeyError(f"There is no such option. ({option})")
    return True
Exemplo n.º 14
0
 def _nvim_clear(self):
     ui.clear()
Exemplo n.º 15
0
			getUser = False
		else:
			ui.writeToConsole("Login incorrect")
	
	opsys.setTitleText(TITLE)
	ui.clear()
	ui.setInIDU(False)
	ui.writeToConsole(msgLog)

if __name__ == "__main__":
	"""Initialize and run threads."""
	# Set current mode
	mode[LOCAL_IP] = CHAT
	
	# Clear screen and welcome user
	ui.clear()
	printMsg(etc.welcome(ui.getCols(), VERSION))
	opsys.setTitleText(TITLE)
	
	# Initialize the database module
	dbNick, botResponses = database.initialize(LOCAL_IP)
	
	myNick = dbNick
	
	# Get nickname
	if myNick == None:
		prompt = "Please enter a nickname: "
		myNick = sleepPrompt(prompt)
		msgLog.append(prompt + myNick)
	else:
		returnString = "Welcome back, " + myNick
Exemplo n.º 16
0
def ainspect(): #function för att printa en del utav ui
    ui.clear() #Clear call
    ui.line(False)  # printar en linje gjord utav *
    ui.header("ARTIST DATABASE")
    ui.line(True)  # printar en linje gjord utav -
    web.inspectart() #kallar på funktionen som tar fram informationen på specifika artister.
    ui.line(False)  # printar en linje gjord utav *
    ui.echo("| Press enter to return ")  # Printar våra val
    ui.line(False)  # printar en linje gjord utav *
    ui.prompt()



while True: #kör en stor while sålänge som end variabeln inte innehåller
    ui.clear() #Clear call
    ui.line(False) #printar en linje gjord utav -
    ui.header("Welcome to the Music Library") #printar en header
    ui.line(False)#printar en linje gjord utav -
    ui.line(False)#printar en linje gjord utav -
    ui.echo("| L | Lista alla Artister") #Printar våra val
    ui.echo("| V | Inspektera Artist ")#Printar våra val
    ui.echo("| E | Stäng av ")
    ui.line(False)
    choice = ui.prompt()#variable input så att du kan kalla på

    if choice == "L": #gör så att vi kan välja olika val
        alist() #kallar på functionen alist
    if choice == "V": #gör så att vi kan välja olika val.
        ainspect() #kallar på functionen ainspect
    if choice == "E":
Exemplo n.º 17
0
def handleUser():
	"""Get and parse user input."""
	global botPower
	hiberCounter = 0
	
	# Get and process user input
	while True:
		# Get user input
		prompt = peers[LOCAL_IP] + ": "
		inputString = sleepPrompt(prompt)
		msgLog.append(prompt + inputString)
		
		# Process user input
		if len(inputString) > 0:
			commandString = inputString.lower()
			hiberCounter = 0
			if commandString.startswith(etc.AGAVEBOT):
				botPower = not botPower
				if botPower:
					printMsg("Agavebot: Agavebot is now activated.")
				else:
					printMsg("Agavebot: Why do you hate agavebot?")
			elif commandString.startswith(etc.CLEAR):
				ui.clear()
			elif commandString.startswith(etc.KICK):
				traffic.sendText(traffic.KICK, inputString[len(etc.KICK):])
			elif commandString.startswith(etc.HELP):
				printMsg(etc.help(ui.getCols(), VERSION, HIBER_NUM))
			elif commandString.startswith(etc.NICK):
				if len(inputString[len(etc.NICK):]) > 2:
					database.setNick(inputString[len(etc.NICK):])
					peers[LOCAL_IP] = inputString[len(etc.NICK):]
					sendStatus()
				else:
					printMsg("Nicknames must be at least 3 characters long.")
			elif (commandString.startswith(etc.QUIT) or commandString.startswith(etc.EXIT)):
				traffic.sendText(traffic.QUIT, peers.keys())
				opsys.exit()
			elif commandString.startswith(etc.WHOS):
				whosString = "\nPeer IP addresses  | Mode       | Peer nicknames\n" + "".center(34,"-")
				for ip in peers:
					whosString += "\n"
					if ip == LOCAL_IP:
						whosString += "-->"
					else:
						whosString += "   "
					whosString += ip.ljust(18) + MODE_TEXT[mode[ip]].ljust(13) + peers[ip]
				printMsg(whosString)
			elif commandString.startswith(etc.AWAY):
				setMode(AWAY)
				emulateIDU()
				setMode(CHAT)
			elif commandString.startswith("$test".lower()):
				printMsg(msgLog, log=False)
			else:
				if commandString.startswith(traffic.COMMAND_CHAR):
					inputString = traffic.COMMAND_CHAR + inputString
				traffic.sendText(inputString, peers.keys())
		else:
			msgLog.pop()
			hiberCounter += 1
			if hiberCounter >= HIBER_NUM:
				setMode(HIBERNATE)
				opsys.closePopup()
				emulateIDU()
				setMode(CHAT)
				opsys.resumePopup()
Exemplo n.º 18
0
def choose():
    myfile = "student/students.txt"
    option = ui.get_inputs("\nPlease enter a number: ")
    table = data_manager.imports_from_file(myfile)
    if option == "1":
        ui.clear()
        data_manager.export_to_file(myfile, create_student(table))
    elif option == "2":
        ui.clear()
        idx = ui.get_inputs("Enter the student ID: ")
        if common.check_valid_id(table, idx) == False:
            ui.clear()
            ui.print_error(f"Invalid student ID! ('{idx}')")
        else:
            result = get_student_applications(idx, read_student(table, idx))
            ui.print_result(result, "Student details")
    elif option == "3":
        ui.clear()
        result = read_students(table)
        if len(result) == 0:
            ui.clear()
            ui.print_error("There are no students in this list!")
        else:
            show_table(result)
    elif option == "4":
        ui.clear()
        attributes = ["name", "age", "status"]
        idx = ui.get_inputs("Enter student ID: ")
        if common.check_valid_id(table, idx) == False:
            ui.clear()
            ui.print_error(f"Invalid student ID! ('{idx}')")
            return True
        update = ui.get_inputs("Which attribute do you want to change?\n")
        update = update.lower()
        if update not in attributes:
            ui.clear()
            ui.print_error(f"You cannot change this attribute! ('{update}')")
        else:
            data_manager.export_to_file(
                myfile,
                update_student(
                    table, idx, update,
                    ui.get_inputs(f"Enter the new value of the {update}.\n")))
    elif option == "5":
        ui.clear()
        idx = ui.get_inputs("Enter student ID: ")
        if common.check_valid_id(table, idx) == False:
            ui.clear()
            ui.print_error(f"Invalid student ID! ('{idx}')")
        else:
            data_manager.export_to_file(
                myfile,
                update_student(table, idx, "status",
                               get_new_status(table, idx)))
    elif option == "6":
        ui.clear()
        idx = ui.get_inputs("Enter student ID: ")
        if common.check_valid_id(table, idx) == False:
            ui.clear()
            ui.print_error(f"Invalid student ID! ('{idx}')")
            return True

        if common.check_data_in_app(idx, "student") == True:
            ui.clear()
            ui.print_error("You cannot delete this student!")
        else:
            data_manager.export_to_file(myfile,
                                        common.delete_element(table, idx))
    elif option == "0":
        ui.clear()
        return False
    else:
        raise KeyError(f"There is no such option. ({option})")
    return True
Exemplo n.º 19
0
def test_clear():
    print "foo"
    ui.clear()
    print "bar"