Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Edita(user, id, idgroup, nome, home, shell):
- while(True):
- user_id = input("Digite o ID do usuario: ")
- if(user_id in id):
- aux = id.index(user_id)
- print("Usuario: ", user[aux], "\nID: ", id[aux], "\nId group: ", idgroup[aux], "\nNome: " ,nome[aux], "\nHome: ", home[aux], "\nShell: ", shell[aux])
- user[aux]= input("Novo Usuario: ")
- id[aux] = input("Novo Id: ")
- idgroup[aux] = input("Novo Id de grupo:")
- nome[aux] = input("Novo nome:")
- home[aux] = input("Nova home")
- shell[aux] = input("Novo Shell")
- break
- else:
- print("Id não encontrado")
- def Mostra(user, id, idgroup, nome, home, shell,lines):
- c = 0
- for aux in user:
- print("\nUsuario: ", user[c], "\nID: ", id[c], "\nId de grupo: ", idgroup[c], "\nNome: ", nome[c], "\nHome: ", home[c], "\nShell: ", shell[c] )
- c += 1
- def Add(user, id, idgroup, nome, home, shell):
- user.append(input("Novo Usuario"))
- id.append(input("Novo id"))
- idgroup.append(input("Novo id de grupo"))
- nome.append(input("Novo nome"))
- home.append(input("Nova home "))
- shell.append(input("Novo shell"))
- def Save(user, id, idgroup, nome, home, shell):
- new_file = open("New_file.txt", "w")
- for i in range(0, len(user)):
- new_file.write(user[i]+":x:"+id[i]+":"+idgroup[i]+":"+nome[i]+":"+home[i]+":"+shell[i]+"\n")
- arquivo = open('odin.txt', 'r')
- lines = arquivo.readlines()
- arquivo.close()
- arquivo = open('odin.txt', 'r')
- user = []
- id = []
- idgroup = []
- nome = []
- home = []
- shell = []
- for c in range(0, len(lines)):
- line = arquivo.readline()
- aux = line.split(':')
- user.append(aux[0])
- id.append(aux[2])
- idgroup.append(aux[3])
- nome.append(aux[4])
- home.append(aux[5])
- shell.append(aux[6])
- def Escolha(menssagem):
- escolha = int(input(menssagem))
- return (escolha)
- escolha = Escolha("Config PassWD Python\nEscolha uma opção:\n1-Alterar usuário\n2-Mostrar usuários\n3-Adicionar usuário\n4-Salvar e Sair\n5"
- "-Sair\n")
- while(True):
- if escolha == 1:
- Edita(user, id, idgroup, nome, home, shell)
- escolha = 0
- elif escolha == 2:
- Mostra(user, id, idgroup, nome, home, shell, len(lines))
- escolha = 0
- elif escolha == 3:
- Add(user, id, idgroup, nome, home, shell)
- escolha = 0
- elif escolha == 5:
- Save(user, id, idgroup, nome, home, shell)
- break
- elif escolha == 6:
- break
- escolha = Escolha("Config PassWD Python\nEscolha uma opção:\n1-Alterar usuário\n2-Mostrar usuários\n3-Adicionar usuário\n5-Salvar e Sair\n6-Sair\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement