A mirror of dcurooms found at https://github.com/theycallmemac/dcurooms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.8 KiB

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # import libraries
  4. import sys
  5. import datetime
  6. from optparse import OptionParser
  7. from lab_booking import LabBooking
  8. from room_booking import RoomBooking
  9. from lookup import LookUp
  10. from now import Now
  11. import utils
  12. import opts
  13. __author__ = "theycallmemac"
  14. __version__ = '2.0.0'
  15. __copyright__ = 'Copyright (c) 2018 theycallmemac'
  16. __license__ = 'GPL-3.0'
  17. def setup_options():
  18. parser = OptionParser(
  19. description='Displays info and books room around DCU.',
  20. prog='dcurooms', version='%prog ' + __version__, usage='%prog [option]')
  21. parser.add_option(
  22. "-l", "--lookup", action="store_true",
  23. help="returns information given a specific room, week, day and hour")
  24. parser.add_option(
  25. "-b", "--book", action="store_true",
  26. help="books a room by providing the room, D/M/YYYY, start, and end")
  27. parser.add_option(
  28. "-a", "--available", action="store_true",
  29. help="returns only the rooms/labs that are free in a building")
  30. parser.add_option(
  31. "-n", "--now", action="store_true",
  32. help="show the status of each room/lab as it is currently")
  33. # building options which can be passed
  34. parser.add_option(
  35. "-L", "--computing", action="store_true",
  36. help="displays the status of the labs in the School of Computing")
  37. parser.add_option(
  38. "-C", "--grattan", action="store_true",
  39. help="displays the status of rooms in the Henry Grattan building")
  40. return parser
  41. def get_data():
  42. times, c, g, details = {'0800': '1', '0830': '2', '0900': '3', '0930': '4', '1000': '5', '1030': '6', '1100': '7', '1130': '8', '1200': '9', '1230': '10', '1300': '11', '1330': '12', '1400': '13','1430': '14', '1500': '15', '1530': '16', '1600': '17', '1630': '18', '1700': '19', '1730': '20', '1800': '21', '1830': '22', '1900': '23', '1930': '24', '2000': '25', '2030': '26', '2100': '27', '2130': '28', '2200': '29', '2230': '30'}, ['LG25', 'LG26', 'LG27', 'L101', 'L114', 'L125', 'L128'], ['CG01', 'CG02', 'CG03', 'CG04', 'CG05', 'CG06', 'CG11', 'CG12', 'CG20', 'CG68', 'C166'], sys.argv[2:]
  43. return times, c, g, details
  44. def required():
  45. parser = setup_options()
  46. (options, arguments) = parser.parse_args()
  47. times, c, g, details = get_data()
  48. return parser, (options, arguments), (c, g), (times, details)
  49. def main():
  50. parser, (options, arguments), rooms, info = required()
  51. if options.book and info[1][0][0] == "L":
  52. opts.booking_lab(info)
  53. elif options.book and info[1][0][0] == "C":
  54. opts.booking_room(info)
  55. if options.lookup and (options.grattan or options.computing):
  56. opts.lookup_building(rooms, info, options)
  57. elif options.lookup:
  58. opts.lookup_room(info)
  59. if options.now:
  60. opts.now()
  61. if __name__ == "__main__":
  62. main()