No Description
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.

seopardy.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/python
  2. from __future__ import print_function
  3. import argparse
  4. import os
  5. import sys
  6. #from PySide import QtCore, QtGui
  7. from PySide import QtGui
  8. from music import MusicBox
  9. from question import Questions
  10. from gamestate import GameState
  11. from game import SeopardyGame
  12. def _parser():
  13. parser = argparse.ArgumentParser(description="Sebas jeopardy/beopardy clone")
  14. parser.add_argument("--fifo", action="store", default="/tmp/seopardy-fifo", help="Name of the fifo to create")
  15. parser.add_argument("--gamestate", action="store", default=None, help="Gamestate to load to recover a crashed game")
  16. parser.add_argument("--savedir", action="store", default="/tmp/seopardy/", help="Directory where to save the temporary gamestates to, in case of game-crash")
  17. parser.add_argument("questions", action="store", help="Path to questionfile")
  18. return parser
  19. if __name__ == '__main__':
  20. parser = _parser()
  21. args = parser.parse_args()
  22. fifo = None
  23. try:
  24. if os.path.exists(args.fifo):
  25. os.unlink(args.fifo)
  26. os.mkfifo(args.fifo)
  27. except OSError as e:
  28. print("Error: Could not create fifo: %s" % (str(e),), file=sys.stderr)
  29. sys.exit(1)
  30. questions = Questions(args.questions)
  31. # start gui
  32. app = QtGui.QApplication([])
  33. # create or load gamestate
  34. gamestate = None
  35. if args.gamestate:
  36. sstream = None
  37. try:
  38. sstream = open(args.gamestate, "r")
  39. except IOError as e:
  40. print("Error: Could not load gamestate: %s" % (str(e),), file=sys.stderr)
  41. sys.exit(1)
  42. gamestate = GameState.load(sstream, args.savedir)
  43. else:
  44. gamestate = GameState(args.savedir)
  45. # init music box
  46. MusicBox.init()
  47. # create board
  48. board = SeopardyGame(questions, gamestate)
  49. board.show()
  50. app.exec_()
  51. sys.exit()