Example #1
0
 def make_reservation(self, customer, rtype, date, duration):
     date_s = date.split(".")
     date = date_s[2] + "-" + date_s[1] + "-" + date_s[0]
     for i in self.customers:
         if i.get_name() == customer or customer == i:
             customer_c = i
     a = 0
     b = 0
     #Huoneen varaus/paivien testaus for-loopilla. Calendar-luokan check-dates metodissa käydään läpi huonekohtaiset varaukset.
     if "Room" in rtype:
         for room in self.get_rooms():
             a += 1
             if room.get_reservations() == []:
                 room.add_reservation(date, duration)
                 roomnumber = room.get_room_number()
                 reservation = Reservation(self, customer_c, rtype, date,
                                           str(duration), room)
                 self.reservations.append(reservation)
                 customer_c.reservations.append(reservation)
                 room.add_fullreservation(reservation)
                 self.save(reservation.__str__())
                 return reservation
             else:
                 if self.calendar.check_dates(room, date, duration) == True:
                     b += 1
                     room.add_reservation(date, duration)
                     reservation = Reservation(self, customer_c, rtype,
                                               date, str(duration), room)
                     self.reservations.append(reservation)
                     customer_c.reservations.append(reservation)
                     self.save(reservation.__str__())
                     room.add_fullreservation(reservation)
                     return reservation
                 elif a == len(self.get_rooms()) and b == 0:
                     return False
Example #2
0
def main():
    args = get_args()

    action = args['action']
    testbed = args['testbed']
    firmware = '{0}/{1}'.format(FIRMWARE, args['firmware'])

    add_private_key()

    print 'Script started'

    if action == 'check':
        print 'Checking experiment'
        Reservation(USERNAME, HOSTNAME).check_experiment()
    if action == 'reserve':
        print 'Reserving nodes'
        Reservation(USERNAME, HOSTNAME).reserve_experiment(EXP_DURATION, NODES)
    if action == 'terminate':
        print 'Terminating experiment'
        Reservation(USERNAME, HOSTNAME).terminate_experiment()
    elif action == 'otbox':
        print 'Starting OTBox'
        OTBoxStartup(USERNAME, HOSTNAME, testbed).start()
    elif action == 'otbox-flash':
        print 'Flashing OTBox'
        OTBoxFlash(firmware, BROKER, testbed).flash()
    elif action == 'ov-start':
        print 'Starting OV'
        OVStartup().start()
    elif action == 'ov-monitor':
        print 'Starting OV log monitoring'
        OVLogMonitor().start()
Example #3
0
def start_app():
    #اضافة الفنادق
    rotana_hotel = Hotel(20, "Rotana", "Abu Dhabi", 200, 40)
    sheraton_hotel = Hotel(21, "Sheraton", "Abu Dhabi", 300, 100)
    mercur_hotel = Hotel(19, "Mercure", "Nador", 100, 50)
    royalhotel = Hotel(1, 'The Royal Hotel', 'Toronto', 200, 30)
    ryadnador = Hotel(2, 'Hotel RYAD', 'Nador', 200, 1)
    mercure = Hotel(3, 'Mercure', 'Nador', 200, 10)
    print "*" * 20
    print Hotel.hotels
    print "*" * 20

    print "List hotels in Nador city"
    print mercure.list_hotels_in_city('Nador')
    #اضافة الزبناء
    mounir = Customer('Mounir AL OUALITI')
    asmae = Customer('Asmae SAKSAK')
    print "*" * 20
    #اضافة الحجوزات
    reservation2 = Reservation("Hotel RYAD", "Mohamed SAKSAK")
    reservation1 = Reservation("Hotel RYAD", "Mounir AL OUALITI")
    reservation2 = Reservation("Hotel RYAD", "Asmae SAKSAK")
    reservation3 = Reservation("Mercure", "Asmae SAKSAK")
    reservation4 = Reservation("Mercure", "Mounir AL OUALITI")
    print "*" * 20
    print "List reservations for hotel Mercure"
    print reservation1.list_reservations_for_hotel('Mercure')
    print "*" * 20
    print "List Hotels"
    print Hotel.hotels
    print "*" * 20
Example #4
0
 def updateReservation(self, reservation):
     self.reservations[reservation["id"]] = Reservation(
         reservation["id"], reservation["payload"],
         self.services[reservation["payload"]["serviceID"]])
     self.writeJsonFile(
         self.RESERVATIONPATH,
         json.dumps(self.createJsonFromDict(self.reservations)))
Example #5
0
    def __init__(self, name, address, cuisine_type, sections=None, id=DEFAULT_TEST_UUID if DEMO_MODE else None):
        super().__init__(True, id)
        self._json['name'] = name
        self._json['address'] = address
        self._json['cuisineType'] = cuisine_type

        if sections is not None:
            self._json['sections'] = sections
        elif DEMO_MODE:
            print(self.post())
            section = Section('booths', id)
            print(section.post())
            table = Table(3, 25, 25, 0, section.section_id)
            print(table.post())
            reservation = Reservation(table.table_id, id)
            print(reservation.post())
            account = Account()
            print(account.post())
            shift = Shift(None, section.id)
            print(shift.post())
            visit = Visit(shift.id, id)
            print(visit.post())
            order = Order(Status.COOK, 10, account.id,
                          'Steak was undercooked last time.', shift.id, visit.id)
            print(order.post())
            order_two = Order(Status.PREP, 30, account.id,
                              'Less pie flavor please.', shift.id, visit.id)
            print(order_two.post())
Example #6
0
  def add_reservation(self):
    customer_name = input('Enter customer name: ')
    check_in_date = input('Enter check-in-date (d/m/yyyy or dd/mm/yyyy): ')
    check_out_date = input('Enter check-out-date (d/m/yyyy or dd/mm/yyyy): ')
    status = input('Has customer paid? (y/n): ')
    room_size = input('Enter room size: ')
    number_of_people = input('Enter number of people in a room: ')
    price = input('Enter price allocated to each customer: ')
    if self.validate_date(check_in_date) and self.validate_date(check_out_date):
      check_in = time.strptime(check_in_date, "%d/%m/%Y")
      check_out = time.strptime(check_out_date, "%d/%m/%Y")
      params = {
        'Reference Number': self.get_max_reference_number() + 1,
        'Customer Name': customer_name,
        'Check-in-date': str(check_in.tm_mday) + "/" + str(check_in.tm_mon) + "/" + str(check_in.tm_year),
        'Check-out-date': str(check_out.tm_mday) + "/" + str(check_out.tm_mon) + "/" + str(check_out.tm_year),
        'Status': status,
        'Room Size': room_size,
        'Number of people': number_of_people,
        'Price': price
      }

      reservation_object = Reservation(params)
      self.reservations[reservation_object.params['Reference Number']] = reservation_object.params
      print ('\n================================================================================\nReservation with Reference Number %d added succesfully\n================================================================================\n' % reservation_object.params['Reference Number'])
    else:
      print ('\n================================================================================\nWrong Date Format')
    self.continue_or_stop()
Example #7
0
    def __init__(self):
        print("Initializing Location")

        # Services initialisieren
        servicesDict = self.readJsonFile(self.SERVICEPATH)
        for service in servicesDict:
            self.services[service] = Service(service,
                                             servicesDict[service]["category"],
                                             servicesDict[service]["gpioPin"])

        # Reservierungen initialisieren‚
        if not self.services == {}:
            reservationDict = self.readJsonFile(self.RESERVATIONPATH)
            for reservation in reservationDict:
                self.reservations[reservation] = Reservation(
                    reservation, reservationDict[reservation],
                    self.services[reservationDict[reservation]["serviceID"]])

        # Shares initialisieren
        if not self.reservations == {}:
            sharesDict = self.readJsonFile(self.SHAREPATH)
            for share in sharesDict:
                self.shares[share] = Share(
                    share, sharesDict[share],
                    self.reservations[sharesDict[share]["reservationID"]])
Example #8
0
 def add_reservation(self, username, projection_id, row, col):
     self.session.add(
         Reservation(username=username,
                     projection_id=projection_id,
                     row=row,
                     col=col))
     self.session.commit()
Example #9
0
 def add_reservation(self):
     un = input('username>')
     row = int(input('row>'))
     col = int(input('col>'))
     p_id = int(input('projection_id>'))
     new_reservation = Reservation(username=un, row=row, col=col, projection_id=p_id)
     self.__session.add(new_reservation)
     self.__session.commit()
Example #10
0
 def reservate(self, number: int) -> Reservation:
     return Reservation(
         title=self._movie.get_title(),
         number=number,
         start_time=self._start_time,
         end_time=self._start_time + self._movie.get_length(),
         fixed_price=self._movie.get_default_price() * number,
         paid_price=self._movie.get_discounted_price(self) * number)
 def add_reservation(self, current_username, current_projection_id,
                     current_row, current_col):
     reservation = Reservation(username=current_username,
                               projection_id=current_projection_id,
                               row=current_row,
                               col=current_col)
     self.__session.add(reservation)
     self.__session.commit()
Example #12
0
 def reservations(self):
     res = []
     for i in range(self.reserv_count):
         res.append(
             Reservation("{:04}".format(i), random.choice(self.flights),
                         random.choice(self.passengers),
                         random.choice(self.declined)))
     return res
Example #13
0
 def book_room(self, room_number: int, customer: object, check_in_date: date, check_out_date: date) -> None:
     if self.get_hotel(self.city, self.name) is not self:
         raise ValueError("This hotel isn't in the database!")
     self.__test_inputs(number_of_rooms=room_number, customer=customer,
                        check_in_date=check_in_date, check_out_date=check_out_date)
     if room_number not in self.get_available_rooms(check_in_date, check_out_date):
         raise ValueError("This room isn't available from {} to {}!".format(check_in_date, check_out_date))
     Reservation(customer, self, self.get_room(room_number), check_in_date, check_out_date)
Example #14
0
 def make_reservation(self, username, projection_id, seats):
     seat = ast.literal_eval(seats)
     reservation = Reservation(username=username,
                               row=seat[0],
                               col=seat[1],
                               projection_id=projection_id)
     self.__session.add(reservation)
     self.__session.commit()
Example #15
0
def main():
    engine = create_engine("sqlite:///cinema_database.db")
    Base.metadata.create_all(engine)
    session = Session(bind=engine)

    session.add_all([
        Movie(name="The Hunger Games: Catching Fire", rating=7.9),
        Movie(name="Wreck-It Ralph", rating=7.8),
        Movie(name="Her", rating=8.3)
    ])

    session.add_all([
        Projection(movie_id=1, type="3D", date="2014-04-01", time="19:10"),
        Projection(movie_id=1, type="2D", date="2014-04-01", time="19:00"),
        Projection(movie_id=1, type="4DX", date="2014-04-02", time="21:00"),
        Projection(movie_id=3, type="2D", date="2014-04-05", time="20:20"),
        Projection(movie_id=2, type="3D", date="2014-04-02", time="22:00"),
        Projection(movie_id=2, type="2D", date="2014-04-02", time="19:30")
    ])

    session.add_all([
        Reservation(username="******", projection_id=1, row=2, col=1),
        Reservation(username="******", projection_id=1, row=3, col=5),
        Reservation(username="******", projection_id=1, row=7, col=8),
        Reservation(username="******", projection_id=3, row=1, col=1),
        Reservation(username="******", projection_id=3, row=1, col=2),
        Reservation(username="******", projection_id=5, row=2, col=3),
        Reservation(username="******", projection_id=5, row=2, col=4)
    ])

    session.commit()
 def test_04_reserve_room_from_24_to_25(self):
     check_in_date = '5/24/18'
     check_out_date = '5/25/18'
     customer = Customer('Ali', '+16132614041')
     reservation = Reservation(self.hotel, customer, check_in_date,
                               check_out_date)
     self.assertTrue(reservation.reserve(),
                     msg='a room should have been reserved from %s to %s'\
                     %(check_in_date, check_out_date))
 def test_03_reserve_room_from_25_to_27(self):
     check_in_date = '5/25/18'
     check_out_date = '5/27/18'
     customer = Customer('Heba', '+12345678901')
     reservation = Reservation(self.hotel, customer, check_in_date,
                               check_out_date)
     self.assertTrue(reservation.reserve(),
                     msg='a room should have been reserved from %s to %s'\
                     %(check_in_date, check_out_date))
 def test_05_reserve_room_from_25_to_27(self):
     check_in_date = '5/25/18'
     check_out_date = '5/27/18'
     customer = Customer('Ali', '+16132614041')
     reservation = Reservation(self.hotel, customer, check_in_date,
                               check_out_date)
     # Hotel is full from 25 to 27
     self.assertFalse(reservation.reserve(),
                     msg='no room should have been reserved from %s to %s'\
                     %(check_in_date, check_out_date))
Example #19
0
def main():
    print 'Script started'
    if sys.argv[1] == '-check':
        print 'Checking experiment'
        Reservation(USERNAME, HOSTNAME).check_experiment()
    if sys.argv[1] == '-reserve':
        print 'Reserving nodes'
        Reservation(USERNAME, HOSTNAME).reserve_experiment(EXP_DURATION, NODES)
    if sys.argv[1] == '-terminate':
        print 'Terminating experiment'
        Reservation(USERNAME, HOSTNAME).terminate_experiment()
    elif sys.argv[1] == '-otbox':
        print 'Starting OTBox'
        OTBoxStartup(USERNAME, HOSTNAME).start()
    elif sys.argv[1] == '-ov-start':
        print 'Starting OV'
        OVStartup().start()
    elif sys.argv[1] == '-ov-monitor':
        print 'Starting OV log monitoring'
        OVLogMonitor().start()
Example #20
0
def lambda_handler(event, context):
    records = event['Records']
    records = list(
        filter(lambda record: record['eventName'] == 'INSERT', records))
    records = list(map(lambda record: Reservation(record), records))

    for record in records:
        send_email_to_customer(record)
        send_sms_to_admin(record)

    return {'statusCode': 200, 'body': 'success'}
Example #21
0
 def import_reservation_history(self, name, adress, number, date, duration):
     for cust in self.customers:
         if name in cust.__str__() and adress in cust.__str__():
             for room in self.rooms:
                 if room.get_room_number() == int(number):
                     room.add_reservation(date, duration)
                     reservation = Reservation(self, cust, "Room", date,
                                               str(duration), room)
                     self.reservations.append(reservation)
                     cust.reservations.append(reservation)
                     room.add_fullreservation(reservation)
         else:
             pass
Example #22
0
class Test():

    rotana_hotel = hotel.Hotel(20, "Rotana", "Abu Dhabi", 200, 40)
    #sheraton_hotel = hotel.Hotel(21,"Sheraton","Abu Dhabi",300,100)

    print hotel.Hotel.hotels

    customer1 = customer.Customer("omar")
    customer1.add_customer()
    print customer.Customer.customers

    r1 = Reservation("Rotana", "omar", "+1232344332")
    print r1.add_new_reservation()
    print Reservation.reservations
Example #23
0
def lambda_handler(event, context):

    params = event['queryStringParameters']

    if params_missing_mandatory_fields(params):
        return error_response(500, 'missing mandatory fields')

    if params_contain_bad_vals(params):
        return error_response(500, 'bad vals')

    reservation = Reservation(params)
    save_to_dynamo(reservation)

    return {'statusCode': 200, 'body': 'success'}
Example #24
0
def main():
    print 'Script started'
    if sys.argv[1] == '-reserve':
        print 'Reserving nodes'
        res = Reservation(USERNAME, HOSTNAME)
        res.reserve_experiment(EXP_DURATION, NODES)
    elif sys.argv[1] == '-otbox':
        print 'Starting OTBox'
        OTBoxStartup(USERNAME, HOSTNAME).start()
    elif sys.argv[1] == '-ov-start':
        print 'Starting OV'
        OVStartup().start()
    elif sys.argv[1] == '-ov-monitor':
        print 'Starting OV log monitoring'
        OVLogMonitor().start()
Example #25
0
def get_reservations(table_id):
    resevations = []
    conn = sqlite3.connect(BOOKING_DATABASE_PATH)
    cur = conn.cursor()
    cur.execute("SELECT * FROM reservation WHERE table_ref = ?", (table_id, ))
    for reservation_sql_tpl in cur.fetchall():
        reservation = Reservation()
        reservation.id = reservation_sql_tpl[0]
        reservation.table_id = reservation_sql_tpl[1]
        reservation.date = str_to_array_date(reservation_sql_tpl[2])
        reservation._from = str_to_array_time(reservation_sql_tpl[3])
        reservation._to = str_to_array_time(reservation_sql_tpl[4])
        resevations.append(reservation)
    conn.close()
    return resevations
 def getReservations(self):
     self.connect()
     try:
         c = self.connection.cursor()
         c.execute('select * from POSHEA1."RESERVATION"')
         a = []
         for row in c:
             temp = Reservation('', '', 0)
             temp.adapt(row)
             a.append(temp.dictify())
         self.disconnect()
         return json.dumps(a)
     except:
         self.disconnect()
         return json.dumps([])
Example #27
0
    def get_by_cabin_id(self, cabin_id):
        cursor = self._connection_pool.cursor()
        sql = """
            SELECT id, start_date, end_date, user_id, cabin_id FROM reservations
            WHERE cabin_id = %s
        """
        cursor.execute(sql, (cabin_id,))
        rows = cursor.fetchall()
        cursor.close()

        reservations = []
        for row in rows:
            (id, start, end, user_id, cabin_id) = row
            reservations.append(Reservation(id, start, end, user_id, cabin_id))

        return reservations
Example #28
0
    def get_reservation(self, party_size, start_time):
        time_addition = {}
        if party_size == 1:
            time_addition = self._time_addition_blocks['1']
        elif party_size >= 2 and party_size <= 3:
            time_addition = self._time_addition_blocks['2_to_3']
        elif party_size >= 4 and party_size <= 6:
            time_addition = self._time_addition_blocks['4_to_6']
        elif party_size >= 7 and party_size <= 10:
            time_addition = self._time_addition_blocks['7_to_10']

        time_delta = dt.timedelta(hours=time_addition['hours'],
                                  minutes=time_addition['minutes'])
        end_time = (dt.datetime.combine(dt.date(1, 1, 1), start_time) +
                    time_delta).time()
        return Reservation(start=start_time,
                           end=end_time,
                           party_size=party_size)
Example #29
0
def start_app():

    rotana_hotel = Hotel(20, "Rotana", "Abu Dhabi", 200, 40)
    sheraton_hotel = Hotel(21, "Sheraton", "Abu Dhabi", 300, 100)

    print Hotel.hotels

    customer = Customer("name", "0000000000")
    customer.add_customer("name2", "phone2")
    print "Customer List : {}".format(customer.customers_list)

    reservation = Reservation(Hotel.hotels[0][1],
                              Customer.customers_list[0][0])
    reservation.add_new_reservation(Hotel.hotels[0][1],
                                    Customer.customers_list[0][0])
    print "Reservation List: {}".format(reservation.reservation_list)

    reservation.list_resevrations_for_hotel(Hotel.hotels[0][1])
Example #30
0
def fetch_reservations_tokyo(
    session: requests.Session,
    office_number: str,
    condition: str = datetime.datetime.now(
        pytz.timezone('Asia/Tokyo')).strftime("%Y/%m/%d")
) -> list:
    api = "https://bloom-tss.jp:6417/Office/OfM0004/Init?UnitCode=100"

    response = session.get(api)
    pattern = 'insertLabelTime[\s\S]*?\);'
    result = re.findall(pattern, response.text)
    reservations = list()
    for r in result:
        reservation = Reservation(r)
        if office_number == reservation.officeNumber and re.search(
                condition, reservation.date, flags=0):
            reservations.append(reservation)
        pass
    return reservations