コード例 #1
0
ファイル: main.py プロジェクト: mrmuli/amity-space-allocator
 def do_allocate_room_type(self, arg):
     """Usage: allocate_room_type <room_name> <room_type>"""
     room = Room()
     room_name = arg['<room_name>']
     room_type = arg['<room_type>']
     status = room.allocate_room_type(room_name, room_type)
     print(status)
コード例 #2
0
    def retieve_data_from_db_for_all_rooms(self):
        #Collect data to store in allocated. { Names }

        self.openDB()
        try:
            new_room_name = ""
            new_room_type = ""
            room = None
            self.cursor.execute('''
				SELECT * FROM Rooms 
			''')

            data = self.cursor.fetchall()
            Storage.list_of_all_rooms = []
            for rows in data:
                new_room_name = rows[0]
                new_room_type = rows[1]
                MyList = [rows[2], rows[3], rows[4], rows[5], rows[6], rows[7]]

                room = Room(new_room_name, new_room_type)
                for mem in range(len(MyList)):
                    if MyList[mem] != "":
                        room.Room_instance.current_members.append(
                            str(MyList[mem]))

                Storage.list_of_all_rooms.append(room)

            #print "\n",Storage.list_of_allocated_people
        except Exception as e:
            raise e
        self.closeDB()
コード例 #3
0
    def createRoom(self, room_name=""):
        self.room_name = room_name.upper()
        result = False
        Result = ""

        for rooms in range(len(Storage.list_of_all_rooms)):
            if self.room_name == Storage.list_of_all_rooms[rooms].Room_name:
                #Check that the room already exist.
                result = True

        if self.room_name != "" and result != True:  #:
            #Create instance of room class
            room_type = random.choice(["OFFICE", "LIVINGSPACE"])
            self.room = Room(self.room_name, room_type)

            #Save instance of room in list of all rooms

            Storage.list_of_all_rooms.append(self.room)

            value = "\t{}\t\t[ {} ]\tcreated successfully!!".format(
                self.room.Room_name, self.room.Room_type)
            Result = "Room created successfully!!"
        else:
            value = "Room called {} failed to create.".format(
                self.room.Room_name)
        print value
        return Result
コード例 #4
0
ファイル: main.py プロジェクト: mrmuli/amity-space-allocator
 def do_print_allocations(self, arg):
     '''Usage: print_allocations [--o=filename]'''
     room = Room()
     file = arg['--o']
     if file is not None:
         room.print_allocations(file)
     else:
         room.print_allocations()
コード例 #5
0
    def do_reallocate_person(self, arg):
        """Usage: reallocate_person <person_name> <room_name>"""

        person_name = arg['<person_name>']
        room_name = arg['<room_name>']

        print(Room().reallocate_room(person_name, room_name))
        print('=' * 75)
コード例 #6
0
    def do_create_room(self, arg):
        """Usage: create_room <room_name>"""

        data = {}
        elements = arg['<room_name>'].replace(',', ' ').split(' ')
        for elem in elements:
            room_type = input(
                'Type(O/L): "O" -> Office or "L" -> Living Space\n %s :' %
                elem)
            if 'o' in room_type.lower():
                data[elem] = 'office'
            else:
                data[elem] = 'livingspace'

        # Save each at a go and  display messages
        for key, value in data.items():
            print(Room().create_room(room_name=key, room_type=value))
        print('=' * 75)
コード例 #7
0
 def test_raises_error_if_non_string_paremeters_passed(self):
     ''' Test that room captures only strings'''
     with self.assertRaises(TypeError):Room(123456)
コード例 #8
0
 def test_room_error_for_empty_parameters(self):
     '''test if error is raise when empty value is passed in Room'''
     with self.assertRaises(TypeError):
         Room()
コード例 #9
0
 def setUp(self):
     self.room = Room("Hogwards")
コード例 #10
0
 def test_office_is_instance_of_room(self):
     blue_office = Room('blue', 'office')
     self.assertIsInstance(blue_office, Room)
コード例 #11
0
 def __init__(self):
     self.room = Room()
コード例 #12
0
        self.rooms = {}
        self.start_room = None
        self.end_room = None

    def random_room(self):
        return random.choice(self.rooms.values())


app.game = Game()
maze = generate_braid_maze(20, 20)
maze.render_text()

rooms = [[None for x in range(maze.width)] for y in range(maze.height)]
for y in range(maze.height):
    for x in range(maze.width):
        room = Room('x%dy%d' % (x, y), x, y)
        rooms[y][x] = room
        if x > 0 and not maze.is_wall_left(x, y):
            room.connect(rooms[y][x - 1], 'w')
        if y > 0 and not maze.is_wall_up(x, y):
            room.connect(rooms[y - 1][x], 'n')

app.game.start_room = rooms[2][2]
app.game.end_room = rooms[maze.height - 3][maze.width - 3]

# Breadth first search the dungeon, marking distance to the exit
rooms_found = set([app.game.end_room])
room_queue = [(app.game.end_room, 0)]
while len(room_queue) > 0:
    (room, distance) = room_queue[0]
    room_queue = room_queue[1:]
コード例 #13
0
    def create(name, max_occupancy):
        room = Room(name, max_occupancy)

        return room
コード例 #14
0
 def setUp(self):
     self.room = Room()
     self.person = Person()
コード例 #15
0
ファイル: main.py プロジェクト: mrmuli/amity-space-allocator
 def do_print_room(self, arg):
     """Usage: print_room <room_name>"""
     room = Room()
     room.print_room(arg['<room_name>'])
コード例 #16
0
ファイル: config.py プロジェクト: vladimir1284/pi
        "UpperTank": "Tanque elevado",
        "Pump": "Bomba",
        "Pir": "Sensor de movimiento",
        "Ldr": "Sensor de luminosidad",
        "Light": "Luminaria",
        "Door": "Sensor de puerta"
    }


port1 = Serial(port="/dev/tty2", baudrate=19200)
ports = [port1]

slave1 = Slave("Taller", "taller", 1, 0, 18, 18, 7, port1)
slaves = [slave1]

cameras = Room('Camaras', 'cameras')
taller = Room('Taller', 'taller')
rooms = [cameras, taller]

tanque = UpperTank("Tanque",
                   "upperTank0",
                   taller,
                   slave1,
                   18,
                   0,
                   min_level=25,
                   capacity=500)
cisterna = LowerTank("Cisterna",
                     "lowerTank0",
                     taller,
                     slave1,
コード例 #17
0
ファイル: main.py プロジェクト: mrmuli/amity-space-allocator
 def do_create_room(self, arg):
     """Usage: create_room <room_name>..."""
     room = Room()
     rooms = arg['<room_name>']
     for rm in rooms:
         status = room.create_room(rm)
コード例 #18
0
 def setUp(self):
     self.room = Room()
コード例 #19
0
 def setUp(self):
     self.room = Room("nairobi")
コード例 #20
0
 def test_livingquaters_is_instance_of_room(self):
     blue_living = Room('red', 'living Quaters')
     self.assertIsInstance(blue_living, Room)