コード例 #1
0
 def _get_money(self, payment, description=""):
     new_balance = self.balance + payment
     DB.query(
         self.UPDATE_BALANCE_QUERY.format(balance=new_balance,
                                          airline_id=self.airline_id))
     DB.query(
         self.ADD_TRANSACTION.format(value=payment,
                                     description=description,
                                     date_time=time.time(),
                                     airline_id=self.airline_id))
コード例 #2
0
 def _pay_money(self, payment, description=""):
     new_balance = self.balance - payment
     DB.query(
         self.UPDATE_BALANCE_QUERY.format(balance=new_balance,
                                          airline_id=self.airline_id))
     DB.query(
         self.ADD_TRANSACTION.format(value=-payment,
                                     description=description,
                                     date_time=time.time(),
                                     airline_id=self.airline_id))
     settings.logger.info("{}: ${}".format(description, payment))
コード例 #3
0
 def price_own_plane(cls, plane_id):
     settings.logger.info("Get price of own plane #{}".format(plane_id))
     return DB.query(cls.OWN_PLANE_PRICE_QUERY.format(id=plane_id))[0][0]
コード例 #4
0
 def price_market_plane(cls, plane_id):
     settings.logger.info("INQUIRE market price of the plane #{}".format(plane_id))
     return DB.query(cls.MARKET_PLANE_PRICE_QUERY.format(plane_id=plane_id))[0][0]
コード例 #5
0
 def flight(cls, plane_id, date_time, passengers, cargo):
     DB.query(cls.ADD_FLIGHT_QUERY.format(plane_id=plane_id, date_time=date_time, passengers=passengers, cargo=cargo))
     settings.logger.info("FLIGHT by plane #{}: passengers: {}, cargo: {} tons".format(plane_id, passengers, cargo))
コード例 #6
0
 def __init__(self):
     self.name = DB.query(
         self.GET_MANAGER_QUERY.format(id=settings.AIR_LINES))[0][0]
コード例 #7
0
 def balance(self):
     settings.logger.info("SHOW COMPANY'S BALANCE")
     return DB.query(self.BALANCE_QUERY.format(id=self.airline_id))[0][0]
コード例 #8
0
 def push_notification(self, notification):
     DB.query(
         self.ADD_NOTIFICATION.format(airline_id=self.airline_id,
                                      date_time=time.time(),
                                      text=notification))
     settings.logger.info("PUSH NOTIFICATION:  <{}>".format(notification))
コード例 #9
0
 def __init__(self):
     self.airline_id = settings.AIR_LINES
     self.name = DB.query(
         self.GET_DISPATCHER_QUERY.format(id=settings.AIR_LINES))[0][0]
コード例 #10
0
 def _add_plane(self, plane_id):
     DB.query(
         self.ADD_PLANE_QUERY.format(airline_id=self.airline_id,
                                     plane_id=plane_id))
コード例 #11
0
 def _del_plane(self, plane_id):
     DB.query(self.DELETE_PLANE_QUERY.format(id=plane_id))