condition = arg if(condition != "gold" and condition != "gnew"): print("The condition has to be either 'gold' or 'gnew'") sys.exit() elif opt in ("-p", "--part"): part = int(arg) if(part != 0 and part != 1 and part != 2 and part != 1 and part != 4 and part != 12 and part != 34): print("The session has to be either '1', '2', '3' or '4'") sys.exit() if (id == 0 or condition == ""): print(usage) sys.exit() if part == 0: songName, song = getSongs(id, condition) else: songName, song = getSongPart(id, condition, part) print(songName) print(song) KEYDOWN = 144 KEYUP = 128 midi.init() try: output = midi.Output(2) except Exception as e: print("Problem with keyboard output") print(e) exit()
os.killpg(os.getpgid(self.x.pid), signal.SIGTERM) usage = 'game.py -i <id> -p <phase>' ident = 0 phase = '' try: opts, args = getopt.getopt(sys.argv[1:], "hi:p:", ["id=", "phase="]) except getopt.GetoptError: print(usage) sys.exit(2) for opt, arg in opts: if opt == '-h': print(usage) sys.exit() elif opt in ("-i", "--id"): try: ident = int(arg) except Exception as e: print("id was not an integer") elif opt in ("-p", "--phase"): phase = arg if (ident == 0 or phase == ''): print(usage) sys.exit() songName, song = getSongs(ident, "passive") gameController = GameController() gameController.startGame(song, songName, phase, ident)