def test_status_with_history(self): """test getting cluster status with history""" health_status = self.health_status.copy() self.pcmk.cluster_status.return_value = health_status actions.status([]) self.function_get.assert_has_calls([ mock.call("resources"), mock.call("history")]) self.function_set.assert_called_once_with( {"result": json.dumps(health_status)})
def test_status_raise_error(self): self.pcmk.cluster_status.side_effect = subprocess.CalledProcessError( returncode=1, cmd=["crm", "status", "xml", "--inactive"]) actions.status([]) self.function_get.assert_has_calls([ mock.call("resources"), mock.call("history")]) self.function_set.assert_called_once_with({"result": "failure"}) self.function_fail.assert_called_once_with( "failed to get cluster health")
def main(): setup() print('Welcome to Jenkins CLI') while True: answer = _read_input() if answer.startswith('status'): status(answer) elif answer.startswith('build'): deploy(answer) else: print('action n0t found')
def main(): setup() try: print('Welcome to Jenkins CLI') while True: answer = _read_input() if answer.startswith('status'): status(answer) elif answer.startswith('build'): deploy(answer) elif answer.startswith('stop'): stop(answer) elif answer.startswith('exit'): raise ValueError('Seeya :)') else: print('action n0t found') except (KeyboardInterrupt, SystemExit, ValueError): print('Bye :)')
def userinput(player, room): do = input("What do I want to do?") if do == "move": actions.move(player, room) elif do == "break": actions.destroy(player, room) elif do == "status": actions.status(player) elif do == "quit": actions.quit(player) else: print("I don't know how to do that.")
def prompt(player, room): """ Desc: Main game prompt. Called by: main game loop Notes: returns either a room or None. If returning None, all necessary actions are taken within the called function. """ command = None while not command: commandFull = raw_input(player.showHP() + ">") parts = commandFull.lower().split(' ') command = parts[0] args = parts[1:] if command in ('1','2','3','4','enter'): if command in ('1','2','3','4'): command = int(command) #this seems hacky, but actions are classes and must return themselves. Making the new room a variable of the action instance allows it to return a room. return actions.enter(command, room, player).newRoom elif command == "enter": try: args = int(args) return actions.enter(args, room, player).newRoom except: print "That is not a valid door." elif command == 'help': #need to extend this to look at other commands gamehelp = actions.ghelp() print gamehelp.helpTxt return None elif command in ('l', 'look'): action = actions.look(room) return None elif command in ('quit', 'exit'): action = actions.quit(player) return None elif command in ('stat','stats','status'): action = actions.status(player) return None else: return None
def prompt(player, room): """ Desc: Main game prompt. Called by: main game loop Notes: returns either a room or None. If returning None, all necessary actions are taken within the called function. """ command = None while not command: commandFull = raw_input(player.showHP() + ">") parts = commandFull.lower().split(' ') command = parts[0] args = parts[1:] if command in ('1', '2', '3', '4', 'enter'): if command in ('1', '2', '3', '4'): command = int(command) #this seems hacky, but actions are classes and must return themselves. Making the new room a variable of the action instance allows it to return a room. return actions.enter(command, room, player).newRoom elif command == "enter": try: args = int(args) return actions.enter(args, room, player).newRoom except: print "That is not a valid door." elif command == 'help': #need to extend this to look at other commands gamehelp = actions.ghelp() print gamehelp.helpTxt return None elif command in ('l', 'look'): action = actions.look(room) return None elif command in ('quit', 'exit'): action = actions.quit(player) return None elif command in ('stat', 'stats', 'status'): action = actions.status(player) return None else: return None
def traverse(self): self.find_all_rooms() while True: curr_exits = self.player.current_room.get_exits() rand_direction = curr_exits[random.randint(0, len(curr_exits) - 1)] self.last_room = self.player.current_room self.player.travel(rand_direction) self.player.current_room = self.rooms[self.player.current_room_data['room_id']] playerDict = {} playerDict = actions.status() # If player's encumbrance is over 1 try and sell to the shop, it seems like you can only sell one item at a time with how we have it setup if playerDict["encumbrance"] >= 1: self.findRoom(1) # If room id is 1, sell to vendor if self.player.current_room_data["room_id"] == 1: actions.sell() # If player has less than an 8 encumbrance and there are items in the room pick them up if playerDict["encumbrance"] < 8 and len(self.player.current_room_data['items']) > 0: actions.pickup()
def basePrompt(player, room): """ Desc: Main game prompt. Called by: main game loop Notes: returns either a room or None. If returning None, all necessary actions are taken within the called function. """ command = None while not command: commandFull = raw_input(player.showHP() + ">") parts = commandFull.lower().split(" ") command = parts[0] args = parts[1:] if command in ("1","2","3","4","enter"): if command in ("1","2","3","4"): command = int(command) return actions.enter(command, room, player) elif command == "enter": try: args = int(args) return actions.enter(args, room, player) except: print "That is not a valid door." elif command == "help": #need to extend this to look at other commands if len(args) == 0: actions.ghelp() else: actions.ghelp(args[0]) return elif command in ("l", "look"): if len(args) == 0: actions.look(room) else: actions.examine(player, args[0]) return elif command in ("quit", "exit"): actions.quit(player) return elif command in ("stat","stats","status"): actions.status(player) return elif command == "use": if len(args) == 0: print "That command requires a target.\n" else: actions.use(player, args[0]) return elif command in ("i", "inv", "inven", "inventory"): actions.inventory(player) return elif command in ("e", "eq", "equip"): if len(args) == 0: actions.worn(player) else: actions.equipCommand(player, args[0]) return elif command == "worn": actions.worn(player) return elif command in ("un", "une", "uneq", "unequip"): if len(args) == 0: print "That command requires a target.\n" else: actions.unequipCommand(player, args[0]) return elif command == "get": if len(args) == 0: print "That command requires a target.\n" else: actions.get(player, room, args[0]) elif command == "drop": if len(args) == 0: print "That command requires a target.\n" else: actions.drop(player, room, args[0]) elif command in ("ex", "exam", "examine"): if len(args) == 0: print "That command requires a target.\n" else: actions.examine(player, args[0]) elif command == "set": if len(args) == 0: actions.set(player) elif len(args) == 1: print "Set command requires a hotkey and a skill.\n" elif len(args) == 2: actions.set(player, args[0], args[1]) else: actions.set(player, args[0], args[1], args[2]) else: return