Beispiel #1
0
    def download(server, addon, temp_dir, wescamp_dir, password, stamp=None):

        logging.debug(
            "download addon from wescamp server = '%s' addon = '%s' " +
            "temp_dir = '%s' wescamp_dir = '%s' password is not shown", server,
            addon, temp_dir, wescamp_dir)

        # update the wescamp checkout for the translation,
        addon_obj = libgithub.GitHub(wescamp,
                                     git_version,
                                     userpass=git_userpass).addon(addon)

        # The result of the update can be ignored, no changes when updating
        # doesn't mean no changes to the translations.
        addon_obj.update()

        # test whether the checkout has a translations dir, if not we can stop
        if (os.path.isdir(wescamp + "/" + addon + "/" + addon +
                          "/translations") == False):

            logging.info(
                "Wescamp has no translations directory so we can stop.")
            if (stamp == None):
                return
            else:
                return True

        # Export the entire addon data dir.
        source = os.path.join(wescamp, addon, addon)
        dest = os.path.join(temp_dir, addon)
        shutil.copytree(source, dest)

        # If it is the old format with the addon.cfg copy that as well.
        wescamp_cfg = wescamp + "/" + addon + "/" + addon + ".cfg"
        temp_cfg = temp_dir + "/" + addon + ".cfg"
        if (os.path.isfile(wescamp_cfg)):
            logging.debug("Found old format config file")
            shutil.copy(wescamp_cfg, temp_cfg)

        # We don't test for changes, just upload the stuff.
        # NOTE wml.put_campaign tests whether the addon.cfg exists so
        # send it unconditionally.
        wml = libwml.CampaignClient(server, quiet_libwml)
        ignore = {}
        stuff = {}
        stuff["passphrase"] = password
        if (stamp == None):
            wml.put_campaign(addon, temp_dir + "/" + addon + "/_main.cfg",
                             temp_dir + "/" + addon + "/", ignore, stuff)

            logging.info("New version of addon '%s' downloaded.", addon)
        else:
            if (stamp == get_timestamp(server, addon)):
                wml.put_campaign(addon, temp_dir + "/" + addon + "/_main.cfg",
                                 temp_dir + "/" + addon + "/", ignore, stuff)
                logging.info("New version of addon '%s' downloaded.", addon)
                return True
            else:
                return False
Beispiel #2
0
    def checkout(wescamp, wesnoth_version, userpass=None):

        logging.debug(
            "checking out add-ons from wesnoth version = '%s' to directory '%s'",
            wesnoth_version, wescamp)

        github = libgithub.GitHub(wescamp, git_version, userpass=git_userpass)

        for addon in github.list_addons():
            addon_obj = github.addon(addon)
            addon_obj.update()
Beispiel #3
0
    def erase(addon, wescamp_dir):

        logging.debug(
            "Erase addon from wescamp addon = '%s' wescamp_dir = '%s'", addon,
            wescamp_dir)

        addon_obj = libgithub.GitHub(wescamp_dir,
                                     git_version,
                                     userpass=git_userpass).addon(addon)

        # Note: this is probably not implemented, as it would destroy a repository, including the history.
        addon_obj.erase()
Beispiel #4
0
    def upload(server, addon, temp_dir, wescamp_dir, build_sys_dir=None):
        """Upload a addon from the server to wescamp.

        server              The url of the addon server eg
                            add-ons.wesnoth.org:15005.
        addon               The name of the addon.
        temp_dir            The directory where the unpacked campaign can be stored.
        wescamp_dir         The directory containing a checkout of wescamp.
        build_sys_dir       Possible directory containing a checkout of build-system.
        """

        logging.debug(
            "upload addon to wescamp server = '%s' addon = '%s' " +
            "temp_dir = '%s' wescamp_dir = '%s'", server, addon, temp_dir,
            wescamp_dir)

        # Is the addon in the list with campaigns to be translated.
        campaigns = list_addons(server, True)
        if ((addon in campaigns) == False):
            logging.info(
                "Addon '%s' is not marked as translatable " +
                "upload aborted.", addon)
            return

        github = libgithub.GitHub(wescamp_dir,
                                  git_version,
                                  authorization=git_auth)

        has_updated = False

        # If the checkout doesn't exist we need to create it.
        if not os.path.isdir(os.path.join(wescamp_dir, addon)):

            logging.info("Checking out '%s'.",
                         os.path.join(wescamp_dir, addon))

            if not github.addon_exists(addon):
                github.create_addon(addon)

        # Update the directory
        addon_obj = github.addon(addon)
        addon_obj.update()

        has_updated = update_addon(addon_obj, addon, server, temp_dir)

        has_build_system = update_build_system(addon_obj, addon, wescamp_dir,
                                               build_sys_dir)

        if has_updated and has_build_system:
            pot_update(addon_obj, addon)
Beispiel #5
0
    def checkout(wescamp, auth=None, readonly=False):
        """Checkout all add-ons of one wesnoth version from wescamp.

        wescamp             The directory where all checkouts should be stored.
        auth                Authentication data. Shouldn't be needed.
        readonly            Makes a read-only checkout that doesn't require authentication.
        """

        logging.debug("checking out add-ons from wesnoth version = '%s' to directory '%s'", git_version, wescamp)

        github = libgithub.GitHub(wescamp, git_version, authorization=git_auth)

        for addon in github.list_addons():
            addon_obj = github.addon(addon, readonly=readonly)
            addon_obj.update()
Beispiel #6
0
    def upload(server, addon, temp_dir, wescamp_dir):

        logging.debug(
            "upload addon to wescamp server = '%s' addon = '%s' " +
            "temp_dir = '%s' wescamp_dir = '%s'", server, addon, temp_dir,
            wescamp_dir)

        # Is the addon in the list with campaigns to be translated.
        campaigns = list_addons(server, True)
        if ((addon in campaigns) == False):
            logging.info(
                "Addon '%s' is not marked as translatable " +
                "upload aborted.", addon)
            return

        # Download the addon.
        extract(server, addon, temp_dir)

        github = libgithub.GitHub(wescamp_dir,
                                  git_version,
                                  userpass=git_userpass)

        # If the checkout doesn't exist we need to create it.
        if (os.path.isdir(wescamp_dir + "/" + addon) == False):

            logging.info("Checking out '%s'.", wescamp_dir + "/" + addon)

            if not github.addon_exists(addon):
                github.create_addon(addon)

        # Update the directory
        addon_obj = github.addon(addon)
        addon_obj.update()
        # Translation needs to be prevented from the campaign to overwrite
        # the ones in wescamp.
        # The other files are present in wescamp and shouldn't be deleted.
        ignore_list = [
            "translations", "po", "campaign.def", "config.status", "Makefile"
        ]
        if (addon_obj.sync_from(temp_dir, ignore_list)):

            addon_obj.commit("wescamp_client: automatic update of addon '" +
                             addon + "'")
            logging.info("New version of addon '%s' uploaded.", addon)
        else:
            logging.info("Addon '%s' hasn't been modified, thus not uploaded.",
                         addon)
Beispiel #7
0
    def erase(addon, svn_dir):

        logging.debug("Erase addon from wescamp addon = '%s' svn_dir = '%s'",
                      addon, svn_dir)

        if use_git:
            addon_obj = libgithub.GitHub(svn_dir,
                                         git_version,
                                         userpass=git_userpass).addon(addon)

            # Note: this is probably not implemented, as it would destroy a repository, including the history.
            addon_obj.erase()
        else:
            svn = libsvn.SVN(svn_dir)

            svn.update(None, [addon])

            svn.remove(addon)

            svn.commit("Erasing addon " + addon)
Beispiel #8
0
    def upload(server, addon, temp_dir, svn_dir):

        logging.debug(
            "upload addon to wescamp server = '%s' addon = '%s' " +
            "temp_dir = '%s' svn_dir = '%s'", server, addon, temp_dir, svn_dir)

        # Is the addon in the list with campaigns to be translated.
        campaigns = list_addons(server, True)
        if ((addon in campaigns) == False):
            logging.info(
                "Addon '%s' is not marked as translatable " +
                "upload aborted.", addon)
            return

        # Download the addon.
        extract(server, addon, temp_dir)

        # If the directory in svn doesn't exist we need to create and commit it.
        message = "wescamp.py automatic update"

        if use_git:
            github = libgithub.GitHub(svn_dir,
                                      git_version,
                                      userpass=git_userpass)

        if (os.path.isdir(svn_dir + "/" + addon) == False):

            logging.info("Creating directory in svn '%s'.",
                         svn_dir + "/" + addon)

            if use_git:
                if not github.addon_exists(addon):
                    github.create_addon(addon)
            else:
                svn = libsvn.SVN(svn_dir)

                # Don't update we're in the root and if we update the status of all
                # other campaigns is lost and no more updates are executed.
                os.mkdir(svn_dir + "/" + addon)
                res = svn.add(addon)
                res = svn.commit(
                    "wescamp_client: adding directory for initial " +
                    "inclusion of addon '" + addon + "'", [addon])

        # Update the directory
        if use_git:
            addon_obj = github.addon(addon)
            addon_obj.update()
        else:
            svn = libsvn.SVN(svn_dir + "/" + addon)
            svn.update()
        # Translation needs to be prevented from the campaign to overwrite
        # the ones in wescamp.
        # The other files are present in wescamp and shouldn't be deleted.
        ignore_list = [
            "translations", "po", "campaign.def", "config.status", "Makefile"
        ]
        if (addon_obj.sync_from(temp_dir, ignore_list)
                if use_git else svn.copy_to_svn(temp_dir, ignore_list)):

            (addon_obj if use_git else
             svn).commit("wescamp_client: automatic update of addon '" +
                         addon + "'")
            logging.info("New version of addon '%s' uploaded.", addon)
        else:
            logging.info("Addon '%s' hasn't been modified, thus not uploaded.",
                         addon)