예제 #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
예제 #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)
예제 #3
0
    def upgrade_game(self, game_dir, game_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 version
        game_ver = utils.get_data_version(game_dir)
        print("Game version: %s" % (game_ver, ))

        # 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, game_template)
            print("\nYour game has been upgraded to muddery version %s.\n" %
                  muddery.__version__)

            # copy version file
            version_src = os.path.join(muddery_lib, "VERSION.txt")
            version_dest = os.path.join(game_dir, "muddery_version.txt")
            shutil.copy2(version_src, version_dest)

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