Exemplo n.º 1
0
    def upgrade_game(self, game_dir, template, muddery_lib):
        # Get first two version numbers.
        if not os.path.exists(game_dir):
            print("\nCan not find dir '%s'.\n" % game_dir)
            return

        if self.is_running(game_dir):
            print("\nThe game is still running, stop it first.\n")
            return

        # Get game config
        game_ver, game_template = launcher_utils.get_game_config(game_dir)
        ver_str = ".".join([str(v) for v in game_ver])
        print("Current game's version is %s." % ver_str)

        if not template:
            template = game_template

        # Get proper upgrader.
        upgrader = self.get_upgrader(game_ver)
        if not upgrader:
            print("\nYour game does not need upgrade.\n")
            return

        try:
            # backup current game dir
            utils.make_backup(game_dir)

            # do upgrade
            upgrader.upgrade_game(game_dir, template, muddery_lib)
            print("\nYour game has been upgraded to muddery version %s.\n" %
                  muddery.__version__)

            # create config file
            launcher_utils.create_config_file(game_dir, template)

        except MudderyError as e:
            if e.code != ERR.can_not_upgrade:
                traceback.print_exc()
                print("\nUpgrade failed: %s\n" % e)
        except Exception as e:
            traceback.print_exc()
            print("\nUpgrade failed: %s\n" % e)

        return
Exemplo n.º 2
0
    def upgrade_game(self, game_dir, template, muddery_lib):
        # Get first two version numbers.
        if not os.path.exists(game_dir):
            print("\nCan not find dir '%s'.\n" % game_dir)
            return
            
        if self.is_running(game_dir):
            print("\nThe game is still running, stop it first.\n")
            return

        # Get game config
        game_ver, game_template = launcher_utils.get_game_config(game_dir)
        ver_str = ".".join([str(v) for v in game_ver])
        print("Current game's version is %s." % ver_str)

        if not template:
            template = game_template

        # Get proper upgrader.
        upgrader = self.get_upgrader(game_ver)
        if not upgrader:
            print("\nYour game does not need upgrade.\n")
            return

        try:
            # backup current game dir
            utils.make_backup(game_dir)

            # do upgrade
            upgrader.upgrade_game(game_dir, template, muddery_lib)
            print("\nYour game has been upgraded to muddery version %s.\n" % muddery.__version__)

            # create config file
            launcher_utils.create_config_file(game_dir, template)

        except Exception, e:
            traceback.print_exc()
            print("\nUpgrade failed: %s\n" % e)