Esempio n. 1
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()
Esempio n. 2
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())
 def getReservation(self):
     """Get current reservation"""
     retry_cnt = 3
     while retry_cnt > 0:
         res = self.runSgCmdWithOutput(["-r"])
         if res.result == 0:
             break
         if res.result != 6:
             log.debug("oh oh -- strange error returned: %d" % res.result)
             return None
         if retry_cnt == 1:
             log.debug("oh oh -- command failed to run after retry")
             return None
         log.debug("command returned %d so retrying" % res.result)
         retry_cnt = retry_cnt - 1
     if not res.lines:
         log.debug("No lines! FAIL")
         return None
     log.debug("Parsing %d lines of reservations:" % len(res.lines))
     for o in res.lines:
         log.debug("line=%s" % o)
     rr = Reservation()
     if "Reservation follows" in res.lines[0]:
         rr.key = res.lines[1].split("=")[1]
         rline = res.lines[2]
         ridx = rline.index("type:")
         rr.rtype = rline[ridx:].split(":")[1].strip()
         log.debug("Reservation: found key=%s type=%s" % (rr.key, rr.rtype))
     else:
         log.debug("No Reservation found")
     return rr
 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))
Esempio n. 7
0
class Application(QMainWindow):
    def __init__(self, parent=None):
        super(Application, self).__init__(parent)
        self.reservation_button = QPushButton("Reservation")
        self.reservation_button.setStyleSheet(
            u"QPushButton {\n"
            "    color: white;\n"
            "    background-color: rgb(0, 59, 76);\n"
            "    min-width: 80px;\n"
            "}")
        self.catalog_button = QPushButton("Car catalog")
        self.catalog_button.setStyleSheet(
            u"QPushButton {\n"
            "    color: white;\n"
            "    background-color: rgb(0, 59, 76);\n"
            "    min-width: 80px;\n"
            "}")
        self.history_button = QPushButton("Car history")
        self.history_button.setStyleSheet(
            u"QPushButton {\n"
            "    color: white;\n"
            "    background-color: rgb(0, 59, 76);\n"
            "    min-width: 80px;\n"
            "}")

        layout = QGridLayout()
        self.setLayout(layout)

        groupbox = QGroupBox("Menu")
        layout.addWidget(groupbox)

        vbox = QVBoxLayout()
        groupbox.setLayout(vbox)
        vbox.addWidget(self.reservation_button)
        vbox.addWidget(self.catalog_button)
        vbox.addWidget(self.history_button)

        self.setCentralWidget(groupbox)

        self.reservation_button.clicked.connect(self.showReservation)
        self.catalog_button.clicked.connect(self.showCatalog)
        self.history_button.clicked.connect(self.showHistory)
        self.reservation = Reservation()
        self.admin = Admin()

    def showReservation(self):
        self.reservation.show()

    def showCatalog(self):
        print("catalog")

    def showHistory(self):
        self.admin.show()
Esempio n. 8
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
Esempio n. 9
0
 def commnads(self, command):
     if command == "show movies":
         self.controller.list()
     elif command == "make reservation":
         Reservation.make_reservation()
     elif command.startswith("show movie projections"):
         arguments = command.split("show movie projections ")[1]
         self.controller.get_movie_id(arguments)
     elif command == "exit":
         sys.exit()
     elif command == "help":
         pass
         # self.help()
     else:
         raise ValueError("Wrong command.")
 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([])
Esempio n. 11
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()
Esempio n. 12
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)))
Esempio n. 13
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()
Esempio n. 14
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"]])
Esempio n. 15
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()
Esempio n. 16
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()
Esempio n. 17
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()
Esempio n. 19
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()
Esempio n. 20
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
Esempio n. 21
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)
Esempio n. 22
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()
Esempio n. 23
0
def main():
    config = getConfig()
    print("===================")
    print("## config section : {}".format(config_section))
    print("===================")
    reserv = Reservation(
        config_section
        ,config.getint(config_section, "loop_count")
        ,config.get(config_section, "login_id")
        ,config.get(config_section, "login_pw")
        ,config.get(config_section, "reserve_month")
        ,literal_eval(config.get(config_section, "reserve_days"))
        ,literal_eval(config.get(config_section, "seat_nominees"))
        ,config.get(config_section, "percent_str")
        ,config.get(config_section, "birth_ymd")
        ,config.get(config_section, "bank_name")
        ,config.get(config_section, "user_agent")
        )
    reserv.process_reservation()
    del reserv
Esempio n. 24
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()
Esempio n. 25
0
	def __init__(self, user, domain):
		self.user = user
		self.domain = domain

		self.socketIoHandler = SocketIoHandler()

		self.client = paramiko.SSHClient()
		self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
		self.client.load_system_host_keys()

		self.ssh_connect()

		self.booted_nodes = []
		self.active_nodes = []

		self.reservation = Reservation(user, domain)
		self.nodes = self.reservation.get_reserved_nodes(True)

                # Fetch the latest version of opentestbed software in the shared A8 director of the SSH frontend
		self.ssh_command_exec('cd A8; rm -rf opentestbed; git clone https://github.com/malishav/opentestbed.git; cd opentestbed; git checkout origin/iotlab;')
Esempio n. 26
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'}
Esempio n. 27
0
  def save_reservations(self):
    if len(self.reservations) > 0:
      with open('../csv/reservations.csv', 'w+') as csv_file:
        writer = csv.DictWriter(csv_file, fieldnames = Reservation.get_field_names(self))
        writer.writeheader()
        for reservation in self.reservations:
          writer.writerow({ 'Reference Number': reservation, 'Customer Name': self.reservations[reservation]['Customer Name'], 'Check-in-date': self.reservations[reservation]['Check-in-date'], 'Check-out-date': self.reservations[reservation]['Check-out-date'], 'Status': self.reservations[reservation]['Status'], 'Room Size': self.reservations[reservation]['Room Size'], 'Number of people': self.reservations[reservation]['Number of people'], 'Price': self.reservations[reservation]['Price'] })
      print ('Reservation records saved successfully\n================================================================================\n')
    else:
      print ('No Reservation to save at the moment\n================================================================================\n')

    self.continue_or_stop()
Esempio n. 28
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
Esempio n. 29
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
def make_reservation():
    name = input("Step 1 (User): Enter name> ")
    if name == 'give_up':
        return None

    tickets = input("Step 1 (User): Enter number of tickets> ")
    if tickets == 'give_up':
        return None
    else:
        tickets = int(tickets)

    show_movies()

    movie_id = input("Step 2 (Movie): Choose a movie> ")
    if movie_id == 'give_up':
        return
    else:
        movie_id = int(movie_id)

    show_movie_projections(movie_id)

    projection_id = input("Step 3 (Projection): Choose a projections> ")
    print(Reservation.print_occupied(conn, projection_id))
    if projection_id == 'give_up':
        return None

    projection_id = int(projection_id)

    seats = chose_seats(tickets, projection_id)
    if seats:
        reservation(movie_id, projection_id, seats)

    confirmation = input('Step 5 (Confirm - type "finalize") >')
    if confirmation == 'give_up':
        return
    if confirmation == 'finalize':
        for seat in seats:
            Reservation.reserve(conn, (name, projection_id, seat[0], seat[1]))
        print('Thanks! Enjoy the movie!')
Esempio n. 31
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
Esempio n. 32
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'}
def chose_seats(tickets, projection):
    occupied_seats = []

    for ticket in range(tickets):
        seat_occupied = False
        while not seat_occupied:
            print('Available seats(marked with dots)')
            chosen = input("Step 4 (Seats): Choose seat {}>".format(ticket+1))
            if chosen == 'give_up':
                return None

            chosen = tuple(int(x.strip()) for x in chosen.split(','))
            if Reservation.is_reserved(conn, chosen):
                print('This seat is already taken!')
                continue
            elif not is_valid_seat(chosen[0], chosen[1]):
                print('Cinema is 10x10!')
                continue
            else:
                seat_occupied = True
                occupied_seats.append(chosen)

    return occupied_seats
from movies import Movies
from projections import Projections
from reservation import Reservation

db = "cinema.db"
movies = Movies(db)
projections = Projections(db)
reservation = Reservation(db)
reservation.clear_reservation_on_stratup()


def start_mess():
    start_message = "Hello, here is the cinema. You can \
use one of the the following commands:\
\n show_movies - print all movies ordered by rating\
\n show_movie_projections <movie_id> - \
print all projections of a given movie\
\n make_reservation\
\n cancel_reservation <name> - disintegrate given person's reservation\
\n exit\
\n help"
    return start_message


def print_func(set_obj):
    for row in set_obj:
        print(row)


def print_hall(matrix):
    hall_str = "   1 2 3 4 5 6 7 8 9 10\n"
def cancel_reservation(name, projection_id):
    Reservation.delete_reservation(conn, name, projection_id)
    print('Reservation on the name of {} was canceled.'.format(name))