Esempio n. 1
0
def add_client():
    name = input('Name: ').lower()
    last_name = input('Last Name: ').lower()
    dni = input('DNI most have 2 numbers and one capitalize letter: ')

    while True:
        if is_valid(name, last_name, dni):
            break
        else:
            helpers.clear()
            print('Incorrect values')
            name = input('Name: ').lower()
            last_name = input('Last Name: ').lower()
            dni = input('DNI most have 2 numbers and one capitalize letter: ')

    customer = Client(name, last_name, dni)
    if not os.path.isfile('clients/' + customer.name + '_' +
                          customer.last_name + '.json'):
        with open(
                'clients/' + customer.name + '_' + customer.last_name +
                '.json', 'w+') as file:
            data = {
                'name': customer.name,
                'last_name': customer.last_name,
                'dni': customer.dni,
                'date': datetime.datetime.now().strftime("%H:%M:%S"),
            }
            json.dump(data, file, indent=2)
            print('Customer created Successfuly')
    else:
        print('The file already exist'.upper())
 def getGeomOpts(self):
     # hp.clear()
     while True:
         print("Geometry Input")
         print("Number of Geometries: " + str(len(self.stlFiles)))
         print("1: Add Geometry")
         print("2: Build Geometry")
         print("3: Update Geometry")
         print("4: Render Geometries")
         print("5: Delete Geometry")
         print("0: Back to Main")
         opt = input("Option to use: ")
         hp.clear()
         if opt == "1":
             self.makeGeom()
             # self.makeSTL()
         elif opt == "2":
             print("Not Done")
         elif opt == "3":
             self.updateGeom()
         elif opt == "4":
             self.render()
         elif opt == "5":
             self.delGeom()
         elif opt == "0":
             break
         else:
             hp.clear()
             print("Bad Option")
     return True
Esempio n. 3
0
def login():

    count = 0

    while True:
        print(Fore.YELLOW + "LOGIN TO POLUX".center(80))
        print("\n",
              "(Even if you can not see, password is typing ;))".center(80))

        user = input("USERNAME:"******"PASSWORD:"******"Too much tryings...")
                stop_program()
            else:
                clear()
                print(Fore.RED + "User invalid, try again...".center(80))
                count += 1
                print(Style.RESET_ALL)
 def __init__(self, type, inpt):
     clear()
     print("*" * 60)
     print("You have entered: {}".format(str(inpt).upper()))
     if type == 'index_selection':
         print("Your choice is not available as an index.")
     elif type == 'value':
         print("You have not put an integer number.")
     elif type == 'orientation':
         print("You have not selected a correct value for orientation.")
     elif type == 'coordinates':
         print("You have not put a correct coordinates value number.")
     elif type == 'coordinate_int':
         print("Your coordinates second value is not an integer")
     elif type == 'coordinate_ord':
         print("Your coordinates second value is not a a letter")
     elif type == 'board_boundaries':
         print("Your coordinates are not within the boundaries of the board")
     elif type == 'guess':
         print("Your guess coordinates are invalid.")
     elif type == 'invalid_str':
         print("Your guess coordinates does not start with a letter.")
     elif type == 'guessed_already':
         print("You have already made that guess.")
     elif type == 'confirmation':
         print("You have not made the right selection.")
     print("\nTry again...")
     print("*" * 60)
 def delGeom(self):
     hp.clear()
     numStlFiles = len(self.stlFiles)
     if numStlFiles == 0:
         print("No Files to Delete...")
         return
     while True:
         print("Available STLs to Delete:")
         for k in range(len(self.stlFiles)):
             print(str(k + 1) + ": " + self.stlFiles[k].name)
         print("")
         print("0: Go Back")
         opt = input("Option to use: ")
         hp.clear()
         if opt == "0":
             return
         try:
             opt = int(opt)
         except:
             print("Option must be an integer...")
             continue
         if opt > numStlFiles:
             print("Bad Option")
             continue
         break
     self.stlFiles.pop(opt - 1)
Esempio n. 6
0
def main():
    """
    Main function for app handles camera, creating of thread and
    """
    img = Img()
    settingThreadArgs = SettingThreadArgs()
    chars = getWeightedChars()
    # Include img object in threadArgs to be able to change settings from thread
    settingThreadArgs.currentImg = img
    camThreadArgs = CameraThreadArgs(img, settingThreadArgs)
    # Create and start thread
    settingsThread = threading.Thread(target=adjustmentThread,
                                      args=(settingThreadArgs, ))
    camThread = threading.Thread(target=cameraThread, args=(camThreadArgs, ))
    settingsThread.start()
    camThread.start()
    helpMenu()
    while settingThreadArgs.status:
        # Status sets to false when pressing 'q'
        if settingThreadArgs.pressedKey == 'h':
            flushBuffer()
            helpMenu()
            settingThreadArgs.pressedKey = None
        asciiImage = generateAsciiImage(img, chars)
        clear()
        print(asciiImage)
    flushBuffer()
Esempio n. 7
0
def init_rounds(word):
    won = False
    hanged = False

    tries = 7
    guessed_letters = []
    word = normalize(word)
    mapped_word_positions = map_positions(word)
    hidden_word = [PLACEHOLDER_LETTER for _ in word]

    while (not won and not hanged):
        print_round_start_message(hidden_word, tries)
        guess, guessed_letters, guessed_before = input_guess(guessed_letters)

        if (guessed_before):
            continue

        tries, hidden_word = check_guess(guess, hidden_word,
                                         mapped_word_positions, tries)

        won = PLACEHOLDER_LETTER not in hidden_word
        hanged = tries <= 0

    clear()
    if (won):
        print_victory_message()
    elif (hanged):
        print_defeat_message(word)
Esempio n. 8
0
def edit_customer():
    name_edit = input('Name to edit: ').lower().split(' ')
    if customer_exist(name_edit):
        with open('clients/' + '_'.join(name_edit) + '.json', 'r') as file:
            name = input('New Name: ').lower()
            last_name = input('New Last Name: ').lower()
            dni = input(
                'New DNI most have 2 numbers and one capitalize letter: ')
            while True:
                if is_valid(name, last_name, dni):
                    break
                else:
                    helpers.clear()
                    print('Incorrect values')
                    name = input('New Name: ').lower()
                    last_name = input('New Last Name: ').lower()
                    dni = input(
                        'New DNI most have 2 numbers and one capitalize letter: '
                    )
            data = json.load(file)

        with open('clients/' + '_'.join(name_edit) + '.json', 'w+') as file:
            data['name'] = name
            data['last_name'] = last_name
            data['dni'] = dni
            data['date'] = datetime.datetime.now().strftime("%H:%M:%S")
            json.dump(data, file, indent=2)

        os.rename('clients/' + '_'.join(name_edit) + '.json',
                  'clients/' + name + '_' + last_name + '.json')

        print('Customer edited correctly')
    else:
        print('The customer doesn\'t exist')
Esempio n. 9
0
    def postcmd(self, stop, line):
        if stop:
            clear()
            return True

        print()
        return False
Esempio n. 10
0
 def _print_opening_message(self):
     clear()
     print('***************************')
     print("Bem vindo ao jogo da Forca!")
     print("***************************")
     sleep(0.5)
     print()
     input("Aperte enter para começar")
Esempio n. 11
0
def print_game_start_message():
    clear()
    print('***************************')
    print("Bem vindo ao jogo da Forca!")
    print("***************************")
    sleep(0.5)
    print()
    input("Aperte enter para começar")
Esempio n. 12
0
    def showTemplate(self):
        hp.clear()
        numTemplates = len(self.template)
        if numTemplates == 0:
            print("No templates to render...")
            return
        while True:
            for k in range(numTemplates):
                curTemp = self.template[k]
                curStr = "%i: Template Name [%s] with %i sphere(s)" % (k+1, curTemp.name, len(curTemp.atom))
                print(curStr)
            print("0: Go Back")

            opt = input("Option to use: ")
            hp.clear()
            if opt == "0":
                return
            try:
                opt = int(opt)
            except ValueError:
                print("Error: Input must be an integer")
                continue
            if int(opt) < 1 or int(opt) > numTemplates:
                print("Error: Input out of range")
            temp = self.template[int(opt)-1]

            fig = plt.figure()
            ax = fig.add_subplot(111, projection='3d')
            u = np.linspace(0.0,2.0*np.pi,self.renderLines)
            v = np.linspace(0.0,np.pi,self.renderLines)
            cosu = np.cos(u)
            sinu = np.sin(u)
            cosv = np.cos(v)
            sinv = np.sin(v)
            oneSizeU = np.ones(np.size(u))
            bounds = None
            for atom in temp.atom:
                x = atom[3]*np.outer(cosu, sinv) + atom[0]
                y = atom[3]*np.outer(sinu, sinv) + atom[1]
                z = atom[3]*np.outer(oneSizeU, cosv) + atom[2]
                ax.plot_surface(x,y,z,color='yellow')
                if bounds == None:
                    bounds = [
                        atom[0]-atom[3], atom[0]+atom[3],
                        atom[1]-atom[3], atom[1]+atom[3],
                        atom[2]-atom[3], atom[2]+atom[3]
                    ]
                else:
                    bounds = [
                        min([atom[0]-atom[3], bounds[0]]), max([atom[0]+atom[3], bounds[1]]),
                        min([atom[1]-atom[3], bounds[2]]), max([atom[1]+atom[3], bounds[3]]),
                        min([atom[2]-atom[3], bounds[4]]), max([atom[2]+atom[3], bounds[5]])
                    ]
            dB = max([bounds[1]-bounds[0], bounds[3]-bounds[2], bounds[5]-bounds[4]])
            ax.set_xlim3d([bounds[0], bounds[0] + dB])
            ax.set_ylim3d([bounds[2], bounds[2] + dB])
            ax.set_zlim3d([bounds[4], bounds[4] + dB])
            plt.show()
Esempio n. 13
0
def print_round_start_message(hidden_word, tries):
    clear()
    print('A palavra secreta é:')
    print(' '.join(hidden_word))
    print()
    print(f"Você tem {tries} tentativas.")
    print()
    draw_gallows(tries)
    print()
Esempio n. 14
0
def menu_preset(name, fmisid):
    helpers.clear()
    print(name)
    helpers.seperator()
    fromYear = input("From (year): ")
    toYear = input("To (year): ")
    helpers.seperator()

    plot_range(name, fromYear, toYear, fmisid)
Esempio n. 15
0
def make_scene(screen):
    clear()
    clear()
    print(Fore.RED + "                         Mario               " +
          Style.RESET_ALL)
    print(Fore.GREEN + "  Health               " + str(health) + Fore.YELLOW +
          "   Score             " +
          str(count * 10 + enemy_kill * 30 + mission_comp * 100))
    print(Fore.RED + "  Kills               " + str(enemy_kill) + Fore.YELLOW +
          "   Coins             " + str(count))
    screen.draw()
    def updateGeom(self):
        numStlFiles = len(self.stlFiles)
        if numStlFiles == 0:
            print("No Files to Update...")
            return
        while True:
            print("Available STLs to Update:")
            for k in range(len(self.stlFiles)):
                print(str(k + 1) + ": " + self.stlFiles[k].name)
            print("")
            print("0: Go Back")
            opt = input("Option to use: ")
            hp.clear()
            if opt == "0":
                return
            try:
                opt = int(opt)
            except:
                print("Option must be an integer...")
                continue
            if opt > numStlFiles:
                print("Bad Option")
                continue
            break

        oldVal = self.stlFiles[opt - 1].orgScale
        while True:
            scale = hp.getNum("Scaling to use for file (Was " + str(oldVal) +
                              "): ")
            if scale < 0.0:
                print("scale must be greater than 0.0...")
            else:
                break

        oldVal = self.stlFiles[opt - 1].orgMove
        mx = hp.getNum("Move Geom in x (Was " + str(oldVal[0]) + "): ")
        my = hp.getNum("Move Geom in y (Was " + str(oldVal[1]) + "): ")
        mz = hp.getNum("Move Geom in z (Was " + str(oldVal[2]) + "): ")

        oldVal = self.stlFiles[opt - 1].orgRotate
        rx = hp.getNum("Rotate Geom in x (Was " + str(oldVal[0]) + "): ")
        ry = hp.getNum("Rotate Geom in y (Was " + str(oldVal[1]) + "): ")
        rz = hp.getNum("Rotate Geom in z (Was " + str(oldVal[2]) + "): ")
        rv = hp.getNum("Rotate Geom by (Deg) (Was " + str(oldVal[3]) + "): ")

        newSTL = stlOb(name=self.stlFiles[opt - 1].name,
                       stlMesh=self.stlFiles[opt - 1].orgMesh,
                       move=(mx, my, mz),
                       rotate=(rx, ry, rz, rv),
                       scale=scale,
                       fileLocation=self.stlFiles[opt - 1].fileLocation,
                       stlObject=self.stlFiles[opt - 1].stlObject)
        self.stlFiles[opt - 1] = newSTL
        hp.clear()
Esempio n. 17
0
def main():
    if session.user != "NONE":
        print(f"Logged in as: {session.user}")
    else:
        print("Not currently logged in")

    helpers.showCommands()
    com = input("> ")
    if len(com) > 0:
        tryAction(com)
    else:
        helpers.clear()
Esempio n. 18
0
def loop():

    while True:

        # os.system('cls')  # 'clear' para Linux y OS X
        # os.system('clear')  # 'clear' para Linux y OS X
        helpers.clear()

        print("========================")
        print("  BIENVENIDO AL GESTOR  ")
        print("========================")
        print("[1] Listar clientes     ")
        print("[2] Mostrar cliente     ")
        print("[3] Añadir cliente      ")
        print("[4] Modificar cliente   ")
        print("[5] Borrar cliente      ")
        print("[6] Salir               ")
        print("========================")

        option = input("> ")

        # os.system('cls')  # 'clear' para Linux y OS X
        # os.system('clear')  # 'clear' para Linux y OS X
        helpers.clear()

        if option == '1':
            print("Listando los clientes...\n")
            manager.show_all()
            # TODO
        if option == '2':
            print("Mostrando un cliente...\n")
            manager.find()
            # TODO
        if option == '3':
            print("Modificando un cliente...\n")
            if manager.add():
                print("Cliente añadido correctamente \n")
            # TODO
        if option == '4':
            print("Modificando un cliente...\n")
            if manager.edit():
                print("cliente modificado correctamente \n")
            # TODO
        if option == '5':
            print("Borrando un cliente...\n")
            if manager.delete():
                print("Cliente borrado correctamente\n")
            # TODO
        if option == '6':
            print("Saliendo...\n")
            break

        input("\nPresiona ENTER para continuar...")
Esempio n. 19
0
def main():
	methodname, uploadfile = argv[1:3]
	params = argv[3:]

	clear(methodname, uploadfile)

	if methodname in ("TMVA_BDT", "TMVA_MLP"):
		TMVA_gen(params, methodname, uploadfile)

	elif methodname in ("SKL_BDT", "SKL_MLP"):
		SKL_gen(params, methodname, uploadfile)

	else:
		raise ValueError(f"No method: {methodname}")
Esempio n. 20
0
def find():

    socio = input("Introduce el socio del cliente\n> ")

    for i, client in enumerate(clients):
        if client['nsocio'] == socio:
            show(client)
            return i, client

    print("No se ha encontrado ningún cliente con ese socio")
    helpers.clear()
    volver = input("¿ Desea buscar otro cliente ?")
    if volver == "si":
        find()
Esempio n. 21
0
 def buildFactory(self, atomProps):
     while True:
         print("Set Factory Options")
         print("1: Factory Dimmenstions")
         print("2: Particle Distribution")
         print("3: Factory Options")
         print("4: Delete Factory")
         print("0: Go Back")
         opt = input("Option to use: ")
         hp.clear()
         if opt == '1':
             self.getFactoryType()
             hp.clear()
         elif opt == '2':
             self.setParticleDistribution(atomProps)
             hp.clear()
         elif opt == '3':
             self.setFactoryOptions()
             hp.clear()
         elif opt == '4':
             self.deleteFactory()
         elif opt == '0':
             return
         else:
             print("Bad Input")
Esempio n. 22
0
    def _run_rounds(self, number_of_rounds: int, players: [Player, ...]):
        clear()
        print(f'Serão {number_of_rounds} rodadas para decidir quem vai ganhar')
        sleep(2.5)
        print('Ganha quem tiver mais dinheiro')
        sleep(2.5)

        current_round = 1
        while current_round <= number_of_rounds:
            theme = self._draw_theme()
            secret_world = SecretWord(theme=theme)
            Round(secret_world, theme, players).run()
            current_round += 1

        return players
Esempio n. 23
0
 def getTargetTypeOptions(self, fact):
     hp.clear()
     while True:
         print("Insertion Types")
         print("1: Volume Fraction")
         opt = input("Select Insertion Type: ")
         hp.clear()
         if opt == '1':
             self.factories[fact].factoryOptions['targetType'][
                 0] = 'volumefraction_region'
             self.factories[fact].factoryOptions['targetType'][
                 1] = hp.getNum("volume fraction target: ")
         else:
             print("Bad Input")
     return
Esempio n. 24
0
    def print_start_message(secret_word: SecretWord, theme: str, current_player: Player):
        hidden_word = secret_word.get_hidden_word()
        guessed_letters = secret_word.previously_guessed_letters
        theme = theme.replace('_', ' ').strip().title()

        clear()
        print(f'Tema: {theme}')
        print(' '.join(hidden_word))
        print()

        if len(guessed_letters) > 0:
            RoundCLI.print_guessed_letters(guessed_letters)

        print(f"Turno: {current_player.name} | R${current_player.money:.2f}")
        print()
Esempio n. 25
0
def loop():

    while True:
        
        #IMPORTAMOS LA FUNCION AUXILIAR CLEAR
        helpers.clear()

        print("========================")
        print("  BIENVENIDO AL GESTOR  ")
        print("========================")
        print("[1] Listar clientes     ")
        print("[2] Mostrar cliente     ")
        print("[3] Añadir cliente      ")
        print("[4] Modificar cliente   ")
        print("[5] Borrar cliente      ")
        print("[6] Salir               ")
        print("========================")

        option = input("> ")

        #IMPORTAMOS LA FUNCION AUXILIAR CLEAR
        helpers.clear()  

        if option == '1':
            print("*** Listando los clientes ***\n")
            manage.show_all()
        if option == '2':
            print("*** Mostrando un cliente ***\n")
            manage.find()
        if option == '3':
            print("*** Añadiendo un nuevo cliente ***\n")
            manage.add()
            print("Cliente añadido correctamente\n")
        if option == '4':
            print("*** Modificando un cliente ***\n")
            if manage.edit():
                print("Cliente modificado correctamente\n")
            else:
                print("Cliente no se a modificado correctamente\n")
        if option == '5':
            print("*** Borrando un cliente ***\n")
            if manage.delete():
                print("Cliente borrado correctamente\n")
        if option == '6':
            print("Saliendo...\n")
            break

        input("\nPresiona ENTER para continuar...")
 def makeGeom(self):
     while True:
         print("1: Geometry from file")
         print("2: Primitive Geometry")
         # print("3: Create Geometry")
         print("0: Go Back")
         opt = input("Geometry Options: ")
         hp.clear()
         if opt == '1':
             self.makeSTL()
         elif opt == '2':
             self.makePrimitive()
         elif opt == '0':
             return
         else:
             print("Bad Option")
Esempio n. 27
0
 def deleteFactory(self):
     numFactories = len(self.factories)
     if numFactories == 0:
         print("You have no factories to delete... Returning")
         return
     hp.clear()
     while True:
         print("Which factory would you like to delete?")
         for k in range(numFactories):
             print("%i: %s" % (k + 1, self.factories[k].name))
         opt = hp.getNum("Factory to delete: ")
         hp.clear()
         if opt < 1 or numFactories < opt:
             print("Bad Input")
         else:
             break
Esempio n. 28
0
def plot_range(name, startYear, endYear, fmisid):
    print("Downloading weather data from fmi.fi...")

    progress = '░'
    y = int(startYear)
    while y <= int(endYear):
        helpers.clear()
        print("Fetching weather data from fmi.fi for: ")
        print(name)
        print(str(y) + "/" + str(endYear) + " " + progress)
        fetch_and_plot_data(y, fmisid)
        y += 1
        progress += '░'

    helpers.seperator()
    print("Rendering chart...")
Esempio n. 29
0
    def __init__(self, type, inpt_coord, inpt_orientation):
        clear()
        print("*" * 60)
        print("You have entered: {}\n"
              "Orientation: {}".format(inpt_coord.upper(),
                                       inpt_orientation.upper()))

        if type == 'outofbounds':
            print("Your placement choice puts the battleship out of bounds of "
              "the board")
        elif type == 'occupied':
            print("These coordinates are occupied by another ship.")
        else:
            print("Unknown Ship Placement Error")

        print("Try again...")
        print("*" * 60)
Esempio n. 30
0
 def getVelocityOptions(self, fact):
     hp.clear()
     while True:
         print("Velocity Type")
         print("1: Constant")
         opt = input("Select Velocity Type: ")
         hp.clear()
         if opt == '1':
             self.factories[fact].factoryOptions['vel'][0] = 'constant'
             vx = hp.getNum("Velocity in x direction: ")
             vy = hp.getNum("Velocity in y direction: ")
             vz = hp.getNum("Velocity in z direction: ")
             self.factories[fact].factoryOptions['vel'][1] = [vx, vy, vz]
             return
         else:
             print("Bad Input")
     return