def load_stacks(cls): """ Load the stacks from the stack file. """ for stack in cls.stacks: logging.info('Shutting down stack ' + stack[0] + ' for reload.') stack[1].stop() logging.info('Loading stacks from ' + cls.file) cls.stacks = set() stack_data = json.load(open(cls.file, 'r')) for stack in stack_data['stacks']: logging.info('Loading stack: ' + stack['name']) s = Stack(stack['name'], stack['id']) s.load_items(stack['items']) cls.add_stack(s, do_save=False) cls.list_all()
def add_stack(cls, stack, send_update=False, do_save=True): """ Does what it says. Also, autocomplete gets annoying. Put a period in and it thinks you want to add a function name.__add__() """ if type(stack) == str: stack = Stack(stack) cls.stacks.add((stack.id, stack)) stack.set_socket_handler(cls) if do_save: cls.save() if send_update: cls.send_message(stack=stack.id, command='addstack', payload=stack.dump)