def main(argv): """Pythonic entry point.""" barsdir = os.environ['BARSDIR'] etcdir = "%s/etc" % barsdir fname = None rv = 0 if len(argv) < 1: usage() for opt in argv: if opt == '-h' or opt == '--help': usage() elif opt == '-v': logger.setLevel(logging.INFO) elif opt == '-V': logger.setLevel(logging.DEBUG) else: fname = str(opt) if fname is None or len(fname) == 0: print("No input file specified") return 1 cfg = BarsConfig('%s/bars.cfg' % etcdir) # Open connection to database conn = OpenDb(cfg.dbname, cfg.dbuser, cfg.dbhost) YaccFile(fname) ssm = read_ssm_data() ssm.display() rv = ProcData(conn, ssm, 'OASIS', 'SSM') conn.commit() conn.close() logger.info("Disconnected") return rv
# More API examples for controllers: # # >>> db.mytable.insert(myfield='value') # >>> rows = db(db.mytable.myfield == 'value').select(db.mytable.ALL) # >>> for row in rows: print row.id, row.myfield # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- # after defining tables, uncomment below to enable auditing # ------------------------------------------------------------------------- # auth.enable_record_versioning(db) logger.setLevel(logging.DEBUG) logger.info("Start") db = DAL('postgres://postgres@localhost/barsdb') #db.define_table('register', #Field('first_name', requires=IS_NOT_EMPTY()), #Field('last_name', requires=IS_NOT_EMPTY()), #Field('email', requires=IS_NOT_EMPTY()))g barsdir = os.environ['BARSDIR'] etcdir = "%s/etc" % barsdir cfg = BarsConfig('%s/bars.cfg' % etcdir) # Open connection to database conn = OpenDb(cfg.dbname, cfg.dbuser, cfg.dbhost)
def main(argv): """Entry point.""" rv = 0 showPnl = True flightNumber = '' boardDate = None departAirport = '' barsdir = os.environ['BARSDIR'] if barsdir is None: barsdir = "/opt/bars" etcdir = "%s/etc" % barsdir if len(argv) < 1: usage() try: opts, args = getopt.getopt(argv, "ahvVD:F:P:", ["help"]) except getopt.GetoptError: print("Error in options") sys.exit(1) for opt, arg in opts: if opt == '-h' or opt == '--help': usage() elif opt == '-v': # Debug output logger.setLevel(logging.INFO) elif opt == '-V': # Debug output logger.setLevel(logging.DEBUG) elif opt == "-a": showPnl = False elif opt == "-D": boardDate = ReadDate(arg) logger.debug("Board date set to %s" % boardDate) elif opt == "-F": flightNumber = arg logger.debug("Flight number set to %s" % flightNumber) elif opt == "-P": departAirport = arg logger.debug("Departure airport set to %s" % departAirport) else: print("Unknown input '%s'" % arg) usage() cfg = BarsConfig('%s/bars.cfg' % etcdir) # Open connection to database conn = OpenDb(cfg.dbname, cfg.dbuser, cfg.dbhost) if flightNumber == '': print("No value for flight number") usage() if boardDate is None: print("No value for board date\n") usage() # Read current passengers paxData = PaxList(conn, cfg.AirlineNo, flightNumber, boardDate, cfg.SellingClasses) # Process input file rv = paxData.ReadDb(flightNumber, boardDate, departAirport) PrintPnl(paxData) # Commit transaction and close connection CloseDb(conn) return rv
def main(argv): """Pythonic entry point.""" barsdir = os.environ['BARSDIR'] etcdir = "%s/etc" % barsdir # Option values dt1 = None dt2 = None arriveAirport = None departAirport = None flightNumber = None flightNumber2 = None departTerm = 'A' arriveTerm = 'B' bn = None departTime = None arriveTime = None paxNames = [] paxDobs = [] payAmount = None payAmount2 = 0 sellClass = None vTimeLimit = datetime.now() + timedelta(days=2) vDocNum = None paxCount = 0 groupName = '' reqCode = None reqText = None # Option flags doavail = False dochk = False dodetail = False doprice = False dobook = False dopay = False dossr = False dohtml = False if len(argv) < 1: usage(os.path.basename(sys.argv[0])) opts, args = getopt.getopt(argv, "cfhivyVB:C:D:E:F:G:I:K:L:M:N:P:Q:R:S:T:U:X:Y:", ["help", "avail", "book", "detail", "price", "pay", "chk", "ssr", "html", "bn=", "dob=", "card=", "req=", "date=", "edate=", "flight=", "rflight="]) for opt, arg in opts: if opt == '-h' or opt == '--help': usage(os.path.basename(sys.argv[0])) elif opt == '-v': logger.setLevel(logging.INFO) elif opt == '-V': logger.setLevel(logging.DEBUG) elif opt == '--html': dohtml = True elif opt == '--avail': doavail = True elif opt == '--book': dobook = True elif opt == '--chk': logger.debug("Check booking") dochk = True elif opt == '--detail': dodetail = True elif opt == '--price': doprice = True elif opt == '--pay': dopay = True elif opt == '--ssr': dossr = True elif opt in ('-B', '--bn'): bn = int(arg) logger.debug("Booking number %d" % bn) elif opt in ("-C", "--class"): sellClass = str(arg).upper() elif opt in ("-D", "--date"): dt1 = ReadDate(arg) logger.info("\t flight date %s" % dt1.strftime("%Y-%m-%d")) elif opt in ("-E", "--edate"): logger.info("\t end date %s" % dt1.strftime("%Y-%m-%d")) dt2 = ReadDate(arg) elif opt in ("-F", "--flight"): if ',' in arg: fndata = arg.split('/') flightNumber = fndata[0] dt1 = ReadDate(fndata[1]) else: flightNumber = arg logger.debug("Flight number set to %s" % flightNumber) elif opt in ("-G", "--rflight"): if ',' in arg: fndata = arg.split('/') flightNumber2 = fndata[0] dt2 = ReadDate(fndata[1]) else: flightNumber2 = arg logger.debug("Flight number set to %s" % flightNumber) elif opt == "-K": groupName = str(arg) elif opt == "-L": paxCount = int(arg) elif opt in ("-M", "--dob"): paxDobs = str(arg).upper().split(',') elif opt in ("-N", "--name"): paxNames = str(arg).upper().split(',') elif opt in ("-P", "--depart"): departAirport = str(arg).upper() logger.info("\t depart %s" % departAirport) elif opt in ("-Q", "--arrive"): arriveAirport = str(arg).upper() logger.info("\t arrive %s" % arriveAirport) elif opt in ("-R", "--amount"): payAmount = float(arg) elif opt in ("-S", "--ramount"): payAmount2 = float(arg) elif opt in ("-T", "--card"): vDocNum = str(arg) elif opt in ("-U", "--req"): vSsr = str(arg).split(':') reqCode = vSsr[0] reqText = vSsr[1] elif opt == "-X": departTime = arg elif opt == "-Y": arriveTime = arg else: pass if bn is not None: pnr = int2base20(bn) print("Booking %d PNR %s" % (bn, pnr)) cfg = BarsConfig('%s/bars.cfg' % etcdir) # Open connection to database conn = OpenDb(cfg.dbname, cfg.dbuser, cfg.dbhost) if sellClass is None: sellClass = cfg.SellingClass if dochk: print("Check booking %d" % bn) GetPreBookingInfo(conn, bn) return 0 if dt1 is None and bn is None: print("No departure date or booking number specified") return 1 if dt2 is None: dt2 = dt1 selling_classes = get_selling_conf(conn, cfg.CompanyCode) if doavail: cityPairNo = GetCityPair(conn, departAirport, arriveAirport) GetAvail(conn, dt1, dt2, cityPairNo, departAirport, arriveAirport, selling_classes, cfg.CompanyCode) elif dodetail: GetFlightDetails(conn, flightNumber, dt1, departAirport, arriveAirport) if flightNumber2 is not None and dt2 is not None: GetFlightDetails(conn, flightNumber2, dt2, departAirport, arriveAirport) elif doprice: if dohtml: msg = GetPriceHtml(conn, cfg.CompanyCode, departAirport, arriveAirport, dt1, dt1, sellClass, cfg.OnwReturnIndicator, cfg.FareCategory, cfg.AuthorityLevel) print("%s\n" % msg) else: GetPrice(conn, cfg.CompanyCode, departAirport, arriveAirport, dt1, dt2, sellClass, # cfg.SellingClass, cfg.OnwReturnIndicator, cfg.FareCategory, cfg.AuthorityLevel) elif dobook: bn = DoBook(conn, cfg, paxCount, groupName, paxNames, paxDobs, flightNumber, dt1, departAirport, arriveAirport, sellClass, vTimeLimit, payAmount) if dopay: DoPay(conn, cfg, bn,departAirport, arriveAirport, payAmount, payAmount2, vDocNum, sellClass) elif dopay: DoPay(conn, cfg, bn,departAirport, arriveAirport, payAmount, payAmount2, vDocNum, sellClass) elif dossr: DoRequest(conn, cfg, bn, paxCount, reqCode, reqText, None, None) elif bn is not None: GetPassengers(conn, bn) GetItinerary(conn, bn) ReadPayments(conn, bn) else: print("Nothing to do") CloseDb(conn) return 0
def main(argv): """Pythonic entry point.""" barsdir = os.environ['BARSDIR'] etcdir = "%s/etc" % barsdir flight_number = None dt1 = None dt2 = None asm_ssm = False ssm_data = False ssm_book = False ssm_tim = False ssmdir = None ssmfile = None departure_time = "11:00" arrival_time = "13:00" departure_airport = None arrival_airport = None aircraft_code = None if len(argv) < 1: usage() try: opts, args = getopt.getopt( argv, "cfhivyV" "A:B:C:D:E:F:I:K:L:M:N:P:Q:R:S:T:X:Y:", [ "help", "date=", "edate=", "flight=", "period=", "seats=", "days=", "class=", "locator=", "bookno=", "depart=", "arrive=", "aircraft=", "freq=", "cfgtable=", 'msg', 'ssm', 'tim', 'error', 'success', 'cfg', 'contact', 'ssmdata', 'ssmbook' ]) except getopt.GetoptError: print("Error in options") sys.exit(1) for opt, arg in opts: if opt == '-h' or opt == '--help': usage() elif opt == '--ssm': asm_ssm = True elif opt == '--ssmdata': ssm_data = True elif opt == '--tim': ssm_tim = True elif opt == '--ssmbook': ssm_book = True elif opt == '-A': aircraft_code = str(arg) elif opt in ("-D", "--date"): dt1 = ReadDate(arg) logger.info("\t flight date %s" % dt1.strftime("%Y-%m-%d")) elif opt in ("-E", "--edate"): dt2 = ReadDate(arg) elif opt in ("-F", "--flight"): if '/' in arg: fndata = arg.split('/') flight_number = fndata[0] dt1 = ReadDate(fndata[1]) else: flight_number = arg ssm_data = True elif opt in ("-P", "--depart"): departure_airport = str(arg).upper() logger.info("\t depart %s" % departure_airport) elif opt in ("-Q", "--arrive"): arrival_airport = str(arg).upper() logger.info("\t arrive %s" % arrival_airport) elif opt == '-S': ssmfile = arg elif opt == '-T': ssmdir = arg elif opt == '-v': # Debug output logger.setLevel(logging.INFO) elif opt == '-V': # Debug output logger.setLevel(logging.DEBUG) elif opt == '-X': departure_time = str(arg) elif opt == '-Y': arrival_time = str(arg) else: print("Unknown option %s" % opt) return 1 procssm = "%s/support/bin/procssm" % os.environ['BARSDIR'] cfg = BarsConfig('%s/bars.cfg' % etcdir) # Open connection to database conn = OpenDb(cfg.dbname, cfg.dbuser, cfg.dbhost) if ssmfile is not None: check_ssm_file(procssm, ssmfile) elif flight_number is None: pass else: if ssm_tim and dt1 is not None and dt2 is not None: flight = FlightData(cfg.SellingClass, flight_number, dt1, departure_time, arrival_time, departure_airport, arrival_airport, 0, company_code, aircraft_code) n = ReadSsmTim(conn, flight, dt1, dt2, frequency_code) if n == 0: CheckSsmTim(conn, flight, dt1, dt2, frequency_code, aircraft_code) elif ssm_data and dt1 is not None: flight = FlightData(cfg.SellingClass, flight_number, dt1, departure_time, arrival_time, departure_airport, arrival_airport, 0, company_code, aircraft_code) ReadSsmFlightData(conn, flight, dt2) elif ssm_book and flight_number is not None and dt1 is not None: flight = FlightData(cfg.SellingClass, flight_number, dt1, departure_time, arrival_time, departure_airport, arrival_airport, 0, company_code, aircraft_code) ReadSsmBookData(conn, flight, schedule_period_no) elif asm_ssm: if aircraft_code is None: print("No value for aircraft code") conn.close() return 1 if dt1 is None or dt2 is None: print("No value for start and/or end dates") conn.close() return 1 if frequency_code is None: print("No value for frequency code") conn.close() return 1 ConfigTableNo, NoOfSeats = ReadConfigNumberOfSeats( conn, aircraft_code) viaCities = "%3s#%3s" % (departure_airport, arrival_airport) ReadSchedPeriod(conn, dt1, dt2, frequency_code, flight_number, frequency_code, viaCities, ConfigTableNo) n = GetFlightDataSsm(conn, flight_number, dt1, dt2, frequency_code) if n == 0: CheckSsmTim(conn, flight, dt1, dt2, frequency_code, aircraft_code) else: print("Say again?") # Commit transaction and close connection conn.commit() conn.close() return 0
def main(argv): barsdir = os.environ['BARSDIR'] etcdir = "%s/etc" % barsdir fname = None rv = 0 if len(argv) < 1: usage() opts, args = getopt.getopt(argv, "cfhivyVA:B:C:D:E:F:I:K:L:M:N:P:Q:R:S:T:X:Y:", ["help", "date=", "edate=", "flight="]) dt1 = None dt2 = None arrive_airport = None depart_airport = None for opt, arg in opts: if opt == '-h' or opt == '--help': usage() elif opt == '-v': logger.setLevel(logging.INFO) elif opt == '-V': logger.setLevel(logging.DEBUG) # elif opt in ("-C", "--class"): # selling_cls = str(arg).upper() elif opt in ("-D", "--date"): dt1 = ReadDate(arg) logger.info("\t flight date %s" % dt1.strftime("%Y-%m-%d")) # elif opt in ("-E", "--edate"): # dt2 = ReadDate(arg) elif opt in ("-F", "--flight"): if ',' in arg: fndata = arg.split('/') flight_number = fndata[0] dt1 = ReadDate(fndata[1]) else: flight_number = arg logger.debug("Flight number set to %s" % flight_number) # elif opt in ("-P", "--depart"): # depart_airport = str(arg).upper() # logger.info("\t depart %s" % depart_airport) # elif opt in ("-Q", "--arrive"): # arrive_airport = str(arg).upper() # logger.info("\t arrive %s" % arrive_airport) else: pass if dt1 is None: print("No departure date specified") return 1 if dt2 is None: dt2 = dt1 cfg = BarsConfig('%s/bars.cfg' % etcdir) # Open connection to database conn = OpenDb(cfg.dbname, cfg.dbuser, cfg.dbhost) GetFlightDetails(conn, flight_number, dt1, depart_airport, arrive_airport) conn.commit() conn.close() logger.info("Disconnected") return 0
def main(argv): """Pythonic entry point.""" verbose = 0 status_flag = None bookno = None dt1 = None dt2 = None flight_pattrn = None flight_number = None PassengerName = None agency_code = None dest_id = None action_codes_arg = None locator = None recCount = None ext_locator = None bci_new = False bci_trl = False chk_paid = False bci_msk = 0 origin_address = None summ_code = None hist_code = None chk_rem = False doSsr = False doPay = False doSeat = False doItenary = False showTty = False doBook = False doBsXml = False doFaresPayment = False payment_form = None if len(argv) < 1: usage() try: opts, args = getopt.getopt( argv, "1234ghnprtvV" "A:B:C:D:E:F:G:I:J:K:L:N:P:T:U:X:", [ "help", "ssr", "tty" "book", "pay", "seat", "itinerary", "origin=", "bookno=", "end=", "start=", "create=", "action=", "flight=", "ext=", "pax=", "pay=", "dest=", "field=", "locator=", "count=", "depart=", "delim=", "agency" ]) except getopt.GetoptError: print("Error in options") # usage() sys.exit(1) barsdir = os.environ['BARSDIR'] etcdir = "%s/etc" % barsdir lstfiles = {} lstfiles['pay'] = [ '%s/pay.book_no.lst' % etcdir, '%s/pay.locator.lst' % etcdir ] lstfiles['tty'] = [ '%s/tty.book_no.lst' % etcdir, '%s/tty.locator.lst' % etcdir ] lstfiles['book'] = [ '%s/book.book_no.lst' % etcdir, '%s/book.locator.lst' % etcdir ] lstfiles['seat'] = [ '%s/seat.book_no.lst' % etcdir, '%s/seat.locator.lst' % etcdir ] lstfiles['itinerary'] = ['%s/itinerary.book_no.lst' % etcdir] for opt, arg in opts: if opt == '-h' or opt == '--help': usage() elif opt == '-n': bci_new = True elif opt == '-p': chk_paid = True elif opt == '-r': chk_rem = True elif opt == "--book": doBook = True elif opt == "--itinerary": doItenary = True elif opt == "--pay": doPay = True elif opt == "--seat": doSeat = True elif opt == "--ssr": doSsr = True # logger.debug("Check SSR") elif opt == '-t': bci_trl = True elif opt == '-1': bci_msk += 1 elif opt == '-2': bci_msk += 2 elif opt == '-3': bci_msk += 4 elif opt == '-4': bci_msk += 8 elif opt == '-v': # Debug output logger.setLevel(logging.INFO) elif opt == '-V': # Debug output logger.setLevel(logging.DEBUG) elif opt in ("-A", "--origin"): origin_address = arg # logger.debug("origin %s" % origin_address) elif opt in ("-B", "--bookno"): bookno = int(arg) # logger.debug("\t bookno %d" % bookno) elif opt in ("-C", "--create"): # Create date dt1 = ReadDate(arg) # logger.debug("\t start %s" % dt1.strftime("%Y-%m-%d")) elif opt in ("-D", "--start", "--depart"): # Depart date dt1 = ReadDate(arg) # logger.debug("\t start %s" % dt1.strftime("%Y-%m-%d")) elif opt in ("-E", "--end"): dt2 = ReadDate(arg) # logger.debug("end %s" % dt2.strftime("%Y-%m-%d")) elif opt in ("-F", "--flight"): if '%' in arg or '_' in arg or len(arg) == 0: flight_pattrn = arg # logger.debug("\t flight wildcard %s" % flight_number) else: flight_number = arg # logger.debug("flight number %s" % flight_number) elif opt in ("-G", "--agency"): agency_code = arg # logger.debug("agency %s" % agency_code) elif opt in ("-I", "--dest"): dest_id = str(arg) # logger.debug("dest id %s" % dest_id) elif opt in ("-K", "--pay"): payment_form = arg elif opt in ("-L", "--locator"): locator = arg ## logger.debug("locator %s" % locator) elif opt in ("-N", "--count"): recCount = int(arg) # logger.debug("count %d" % recCount) elif opt in ("-P", "--pax"): PassengerName = arg elif opt in ("-X", "--ext"): ext_locator = str(arg) elif opt == "--tty": showTty = True else: print("Unknown option %s" % opt) cfg = BarsConfig('%s/bars.cfg' % etcdir) # Open connection to database conn = OpenDb(cfg.dbname, cfg.dbuser, cfg.dbhost) if locator is not None: # logger.debug("Read locator %s" % locator) bookno = ReadLocator(conn, locator) elif bookno is not None: # logger.debug("Read booking number %d" % bookno) locator = ReadBookNo(conn, bookno) if bci_msk == 0: bci_msk = 0xf if doSsr and bookno is not None: if dt1 is None: pnr, dt1 = ReadBooking(conn, bookno) irecs = ReadItinerary(conn, bookno, None, None, fnumber=None, start_date=None, end_date=None) for irec in irecs: irec.display() flights = \ ReadDeparture(conn, cfg.CompanyCode, 'Y', irec.flight_number, dt1) if len(flights) == 0: print("Could not find flight %s on %s" % (irec.flight_number, dt1.strftime("%Y-%m-%d"))) return 1 ssrs = ReadRequestsPnl(conn, bookno, cfg.CompanyCode, flights[0].departure_airport, dt1, PassengerName) for ssr in ssrs: ssr.display() elif bci_new and origin_address is not None and ext_locator is not None \ and locator is not None: check_bci_new(conn, origin_address, ext_locator, locator, bci_msk) elif bci_trl and origin_address is not None and ext_locator is not None \ and locator is not None: check_bci_trl(conn, origin_address, ext_locator, locator) elif origin_address is not None and ext_locator is not None \ and locator is not None: check_bci(conn, origin_address, ext_locator, locator, bci_msk) elif chk_paid and bookno is not None: ReadBooking(conn, bookno) rv = BookingIsPaid(conn, bookno) if rv: print("Booking %d is paid up" % bookno) else: print("Booking %d is not paid up" % bookno) elif chk_rem and bookno is not None: ReadBookSummary(conn, bookno, summ_code) ReadBookSummaryHistory(conn, bookno, hist_code) elif doPay and bookno is not None and locator is not None: ReadBookingData(conn, lstfiles['pay'], bookno, locator) elif showTty and bookno is not None and locator is not None: ReadBookingData(conn, lstfiles['tty'], bookno, locator) elif doBook and bookno is not None: ReadBookingData(conn, lstfiles['book'], bookno, None) elif doSeat and bookno is not None: ReadBookingData(conn, lstfiles['seat'], bookno, None) elif doItenary and bookno is not None: ReadBookingData(conn, lstfiles['itinerary'], bookno, None) elif bookno is not None and locator is not None: ReadBookingData(conn, lstfiles['pay'], bookno, locator) else: print("Nothing to do!") # Commit transaction and close connection CloseDb(conn) sys.exit(0)
def main(argv): """Pythonic entry point.""" barsdir = os.environ['BARSDIR'] if barsdir is None: barsdir = "/opt/bars" etcdir = "%s/etc" % barsdir docity = False dofare = False dofaredel = False donew = False doeqt = False dopax = False dopnl = False dotax = False docontact = False departDate = None arriveDate = None payAmount = 0 departAirport = '' arriveAirport = '' flightNumber = '' codeShare = '' departTime = None arriveTime = None frequencyCode = '1234567' aircraftCode = '' configTable = '' tailNumber = '' cabinClasses = [] seatCapacities = [] aircraftName = None if len(argv) < 1: usage() try: opts, args = getopt.getopt(argv, "cfhivxyVA:D:E:F:G:I:J:K:N:P:Q:R:T:U:X:Y:", ["help", "city", "fare", "faredel", "new", "eqt", "cnl", "tim", "rpl", "utc", "pax", "contact", "tax", "pnl", "date=", "edate=", "flight=", "depart=", "arrive=", "name=", "share=", "cfg=", "aircraft=", "freq=", "cfgtable=" ]) except getopt.GetoptError: print("Error in options") sys.exit(1) for opt, arg in opts: if opt == '-h' or opt == '--help': usage() elif opt == '-v': # Debug output logger.setLevel(logging.INFO) elif opt == '-V': # Debug output logger.setLevel(logging.DEBUG) elif opt == "--city": docity = True elif opt == "--fare": dofare = True elif opt == "--faredel": dofaredel = True elif opt == "--eqt": doeqt = True elif opt == "--new": donew = True elif opt == "--pax": dopax = True elif opt == "--pnl": dopnl = True elif opt == "--tax": dotax = True elif opt == "--contact": docontact = True elif opt == "-A" or opt == "--aircraft": aircraftCode = str(arg).upper() logger.debug("aircraft code %s" % aircraftCode) elif opt in ("-D", "--date"): departDate = ReadDate(arg) logger.debug("start date %s" % departDate.strftime("%Y-%m-%d")) elif opt in ("-E", "--edate"): arriveDate = ReadDate(arg) logger.debug("end date %s" % departDate.strftime("%Y-%m-%d")) elif opt in ("-F", "--flight"): flightNumber = arg elif opt in ("-G", "--share"): codeShare = arg elif opt in ("-I", "--cabin"): cabinClasses = str(arg).split(',') logger.debug("classes %s" % cabinClasses) elif opt in ("-J", "--seat"): seatCapacities = str(arg).split(',') logger.debug("seats %s" % seatCapacities) elif opt in ("-K", "--freq"): frequencyCode = str(arg) elif opt in ("-N", "--name"): aircraftName = str(arg) elif opt in ("-P", "--depart"): departAirport = str(arg).upper() logger.debug("depart %s" % departAirport) elif opt in ("-Q", "--arrive"): arriveAirport = str(arg).upper() logger.debug("arrive %s" % arriveAirport) elif opt in ("-R", "--amount"): payAmount = int(arg) logger.debug("payment %d" % payAmount) elif opt in ("-T", "--tail"): tailNumber = str(arg) logger.debug("tail number %s" % tailNumber) elif opt in ("-U", "--cfg"): configTable = str(arg) logger.debug("configuration %s" % configTable) elif opt == "-X": departTime = ReadTime(arg) logger.debug("depart time %s" % departTime) elif opt == "-Y": arriveTime = ReadTime(arg) logger.debug("arrive time %s" % arriveTime) else: print("Unknown option '%s'" % opt) return 1 files = [] for arg in args: files.append(arg.strip()) cfg = BarsConfig('%s/bars.cfg' % etcdir) # Open connection to database conn = OpenDb(cfg.dbname, cfg.dbuser, cfg.dbhost) if donew and flightNumber != '' \ and departDate is not None \ and arriveDate is not None \ and departTime is not None \ and arriveTime is not None \ and departAirport != '' \ and arriveAirport != '' \ and frequencyCode != '' \ and tailNumber != '': NewFlight(conn, cfg.Address, cfg.Sender, cfg.TimeMode, flightNumber, departDate, arriveDate, departAirport, departTime, arriveAirport, arriveTime, frequencyCode, codeShare, tailNumber, cfg.User, cfg.Group) elif donew and len(cabinClasses) > 0 \ and len(seatCapacities) > 0 \ and aircraftCode != '' \ and tailNumber != '' \ and configTable != '': cfgt = CheckAircraftConfig(conn, cfg.CompanyCode, aircraftCode, cabinClasses, seatCapacities) if cfgt is None: WriteEquipmentConfig(conn, cfg.CompanyCode, aircraftCode, tailNumber, configTable, cabinClasses, seatCapacities, cfg.User, cfg.Group) AddAircraftConfig(conn, cfg.CompanyCode, aircraftCode, configTable, cabinClasses, seatCapacities, cfg.User, cfg.Group) else: print("Found configuration %s" % cfgt) eqt = ReadEquipmentConfig(conn, tailNumber) if eqt is None: WriteEquipmentConfig(conn, cfg.CompanyCode, aircraftCode, tailNumber, cfgt, cabinClasses, seatCapacities, cfg.User, cfg.Group) else: eqt.display() elif donew and aircraftCode != '' \ and aircraftName != '': AddAircraft(conn, aircraftCode, aircraftName) elif docity and departAirport != '' \ and arriveAirport != '': NewCityPair(conn, departAirport, arriveAirport, cfg.User, cfg.Group) elif dopax and flightNumber != '' and departDate is not None: ReadFlightBookings(conn, flightNumber, departDate) elif dopnl and flightNumber != '' and departDate is not None: ReadFlightBookings(conn, flightNumber, departDate, "A") elif docontact and flightNumber != '' and departDate is not None: ReadFlightContacts(conn, flightNumber, departDate) elif docity: ReadCityPairs(conn) elif dofare and departAirport != '' \ and arriveAirport != '' and departDate is not None \ and arriveDate is not None: city_pair = GetCityPair(conn, departAirport, arriveAirport) if city_pair > 0: AddFareSegments(conn, cfg.CompanyCode, departAirport, arriveAirport, city_pair, departDate, arriveDate, payAmount, cfg.User, cfg.Group) AddFares(conn, cfg.CompanyCode, departAirport, arriveAirport, cfg.SellingClasses, cfg.User, cfg.Group) elif dofaredel and departAirport != '' \ and arriveAirport != '' \ and departDate is not None \ and arriveDate is not None: DelFareSegments(conn, cfg.CompanyCode, departAirport, arriveAirport, departDate, arriveDate) elif doeqt and tailNumber != '': ReadEquipment(conn, tailNumber) elif dofare: ReadFareCodes(conn) ReadFareSegments(conn) elif dotax and departAirport != '' and departDate is not None: GetTaxes(conn, cfg.CompanyCode, departDate, arriveDate, departAirport) else: print("Huh?") # Commit transaction and close connection CloseDb(conn) return 0