gvacli.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:gvacli 作者: nbarrientos 项目源码 文件源码
def main():
  global args
  args = parse_arguments()

  last_sync = ""
  if not args.all:
    now = datetime.now()
    last_sync = (now - timedelta(hours=3)).strftime("%Y-%m-%d %H:%M:%S")
    last_sync = urllib.quote_plus(last_sync)

  connection = httplib.HTTPConnection(WSHOST, 80)
  uri = WSURI % last_sync
  connection.request("GET", uri)
  response = connection.getresponse()

  if response.status != httplib.OK:
    logging.error("The webservice didn't return OK :(")
    return 1

  json = response.read()
  data = anyjson.deserialize(json)
  departures = fetch_departures(data)

  cgitb.enable()

  table = PrettyTable(['Scheduled',
    'Expected', 'Destination',
    'Flight', 'Airline', 'Gate',
    'Aircraft', 'Reg', 'Status'])
  table.align = 'l'
  for departure in sorted(departures):
    table.add_row(departure)
  print table

  return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号