Esempio n. 1
0
    def test_add_cook(self):
        self.myKitchen.add_cook("Efah", 23, 14, "morning", "Grill")
        self.assertNotIn(Cook("Efah", 23, 14, "morning", "E0h", "Grill"),
                         self.myKitchen.get_cooks())

        self.myKitchen.add_station("Grill")
        self.myKitchen.add_cook("Efah", 23, 14, "morning", "Grill")
        self.assertIn(Cook("Efah", 23, 14, "morning", "E0h", "Grill"),
                      self.myKitchen.get_cooks())
        self.myKitchen.add_cook("Kwasi", 23, 14, "night", "Grill")

        self.assertIn(Cook("Kwasi", 23, 14, "night", "K1i", "Grill"),
                      self.myKitchen.get_cooks())
    def __init__(self):
        self.__version__ = '3.1.3'

        logger_format = '%(asctime)s %(message)s'
        logging.basicConfig(format=logger_format, level=logging.INFO,
                            datefmt="%H:%M:%S", filename='./logfile.log', filemode='w')
        logging.getLogger().addHandler(SysLogHandler(facility=SysLogHandler.LOG_DAEMON, address='/dev/log'))

        self._SIGKILL = False
        self.logging = logging
        self.config = DB('./config.json')

        self.network = Network(self)
        self.display = DisplayContent()
        self.detector = Detector()
        self.ultrasound = Ultrasound(self)
        self.temp = Temp()
        self.server = SimpleWebSocketServer('', 8069, WebSocketServer, self)
        self.cook = Cook(self)
        self.energy = Energy(self)
        self.history = History(self)
        self.audio = Audio(self)
        self.users = Users(self)
        self.automations = Automations(self)

        signal.signal(signal.SIGTERM, self.sig_handler)
        signal.signal(signal.SIGINT, self.sig_handler)

        self.log("Boot: v" + self.__version__)
Esempio n. 3
0
    def test_find_cook(self):
        self.myKitchen.add_station("Saute")
        self.myKitchen.add_cook("Kwasi", 23, 14, "swing", "Saute")

        testingCook = self.myKitchen.find_cook("K0i")
        self.assertEqual(testingCook,
                         Cook("Kwasi", 23, 14, "swing", "K0i", "Saute"))

        self.assertFalse(self.myKitchen.find_cook("GFDG435435"))
Esempio n. 4
0
def main():
    queue_inside = []
    queue_outside = []
    main_queue = {'inside': queue_inside, 'outside': queue_outside}
    saloon = []

    client_generator = Generator(main_queue,
                                 saloon,
                                 EvenDistribution(1, 3),
                                 max_inside_len=15,
                                 max_outside_len=4,
                                 saloon_capacity=50)

    queue_cook = []

    cashiers = [
        Cashier(queue_inside, queue_cook, EvenDistribution(2, 6)),
        Cashier(queue_outside, queue_cook, EvenDistribution(2, 6))
    ]

    cooks = [
        Cook(queue_cook, NormalDistribution(7, 1)),
        Cook(queue_cook, NormalDistribution(7, 1))
    ]

    total_requests = 10000

    t_start = time()
    res = modeling(saloon, client_generator, cashiers, cooks, total_requests)

    print('time seconds', time() - t_start)
    for key in res.keys():
        print(key, res[key])

    print('lost', (res['lost inside'] + res['lost outside'] +
                   res['lost saloon is full']) / total_requests)
Esempio n. 5
0
def main(number_nodes):
    # logger for the main
    logger = logging.getLogger('Restaurant')

    # list with all the nodes
    ring = []

    # socket
    tsocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    tsocket.settimeout(3)

    # create Restaurant
    restaurant = Restaurant()
    restaurant.start()
    ring.append(restaurant)
    logger.info(restaurant)

    # create Cook
    cook = Cook()
    cook.start()
    ring.append(cook)
    logger.info(cook)

    # create Receptionist
    receptionist = Receptionist()
    receptionist.start()
    ring.append(receptionist)
    logger.info(receptionist)

    # create Employee
    employee = Employee()
    employee.start()
    ring.append(employee)
    logger.info(employee)

    #     # Await for DHT to get stable
    #     time.sleep(5)

    #     # Print the ring order for debug
    #     msg = { 'method' : 'PRINT_RING' }
    #     tsocket.sendto(pickle.dumps(msg), ('localhost', 5000))

    #     # Start building the table from the root node
    #     msg = { 'method' : 'NODE_DISCOVERY', 'args' : { 'table' : {} , 'rounds' : 0 } }
    #     tsocket.sendto(pickle.dumps(msg), ('localhost', 5000))

    #     # Await for DHT to get stable
    #     time.sleep(5)

    #     # Print the ring order for debug
    #     msg = { 'method' : 'PRINT_TABLE' }
    #     tsocket.sendto(pickle.dumps(msg), ('localhost', 5000))

    time.sleep(5)

    subprocess.run(['python3', 'client.py'], check=True)
    subprocess.run(['python3', 'client.py'], check=True)

    for node in ring:
        node.join()

    return 0
Esempio n. 6
0
from Read_File import Read_File
from Calc_Score import Calc_Score
from Div_Team import Div_Team
from Cook import Cook
from Result import Result
# 입력받기
Team, pizzaCount, ingredient, ingredientNum = Read_File(
    "b_little_bit_of_everything.in")

teamList = Div_Team(pizzaCount, Team)  # 분배가능한 팀 리스트

dividedTeam, scoreResult = Cook(teamList, ingredient)  # 팀을 확정

print("점수: ", scoreResult)
Result(dividedTeam)  # 결과 출력, 저장 함수
"""
입력  형식
----------------------------
5 1 2 1 
3 onion pepper olive 
3 mushroom tomato basil 
3 chicken mushroom pepper 
3 tomato mushroom basil 
2 chicken basil
"""
"""
출력 형식         | 설명
----------------------------------------------------
2               # 배달에 성공한 팀 수
2 1 4           # 2명 팀에게 배달 성공한 1, 4번 피자
3 0 2 3         # 3명 팀에게 배달 성공한 0, 2, 3번 피자
Esempio n. 7
0
 def test_to_string(self):
     myCook = Cook("Kwasi", 23, 14, "morning", 20, "apps")
     self.assertEqual("Name: Kwasi\nID: 20\nAge: 23\nWage: 14\nShift: morning\nStation: apps", myCook.to_string())