-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
77 lines (56 loc) · 2.49 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# imports do Python
import sys
sys.dont_write_bytecode = True # Usado para nao criar arquivos .pyc
import argparse
# Imports necessarios para executar as threads
from restaurant.client import Client
from restaurant.crew import Crew
from restaurant.chef import Chef
from restaurant.totem import Totem
# Importe o que achar necessario aqui
# import my_module
def definitions(argv, threads):
"""
Esse espaco e reservado para voce definir variaveis globais que serao utilizadas por todas as threads.
Lembre-se de criar as variaveis globais no arquivo restaurant/shared.py
"""
pass
def close_all(argv, threads):
"""
Esse espaco e reservado para voce fechar as coisas que voce abriu (se necessario).
"""
pass
##################################################################################################
###### Nao modifique o codigo abaixo ######
##################################################################################################
if __name__ == "__main__":
args = argparse.ArgumentParser()
# Argumentos para o programa (main.py --clients 10 --crew 5 --seats 5)
args.add_argument("--clients", type=int, default=10, help="Numero de clientes que irao ao restaurante mexicano")
args.add_argument("--crew", type=int, default=5, help="Numero de funcionarios do restaurante mexicano")
args.add_argument("--seats", type=int, default=5, help="Quantidade de assentos na grande mesa do restaurante mexicano")
# Parseando os argumentos
argv = args.parse_args()
# Verificando se os argumentos sao validos
assert argv.clients > 0, "Numero de clientes deve ser maior que 0"
assert argv.crew > 0, "Numero de funcionarios deve ser maior que 0"
assert argv.seats > 0 and argv.seats < argv.clients, "Numero de assentos deve ser maior que 0 e menor que o numero de clientes"
threads = list()
threads.append(Chef())
# Instanciando a equipe
for id in range(argv.crew):
threads.append(Crew(id))
# Instanciando os clientes
for id in range(argv.clients):
threads.append(Client(id))
# Iniciar as definições (variaveis globais)
definitions(argv, threads)
# Iniciando todas as threads
for thread in threads:
thread.start()
# Finalizando todas as threads
for thread in threads:
thread.join()
# Fechando modulos abertos
close_all(argv, threads)
print("[FIM] - Terminamos o dia! Abriremos amanha as 8:00.")