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

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

        # update the wescamp checkout for the translation, 
        svn = libsvn.SVN(wescamp + "/" + addon)

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

        # test whether the svn 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.
        svn_addon = libsvn.SVN(wescamp + "/" + addon + "/" + addon)
        svn_addon.export(temp_dir + "/" + addon)

        # If it is the old format with the addon.cfg copy that as well.
        svn_cfg = wescamp + "/" + addon + "/" + addon + ".cfg"
        temp_cfg = temp_dir + "/" + addon + ".cfg"
        if(os.path.isfile(svn_cfg)):
            logging.debug("Found old format config file")
            shutil.copy(svn_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)
        if(stamp == None):
            wml.put_campaign("", addon, "", password, "", "", "",  
                temp_dir + "/" + addon + ".cfg", temp_dir + "/" + addon + "/")
            logging.info("New version of addon '%s' downloaded.", addon)
        else:
            if(stamp == get_timestamp(server, addon)):
                wml.put_campaign("", addon, "", password, "", "", "",  
                    temp_dir + "/" + addon + ".cfg", temp_dir + "/" + addon + "/")
                logging.info("New version of addon '%s' downloaded.", addon)
                return True
            else:
                return False
Beispiel #2
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(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(os.path.isdir(svn_dir + "/" + addon) == False):
            
            logging.info("Creating directory in svn '%s'.", 
                svn_dir + "/" + addon)

            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
        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.
        if(svn.copy_to_svn(temp_dir, ["translations", "po", "campaign.def", 
            "config.status", "Makefile"])):

            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)
Beispiel #3
0
    def erase(addon, svn_dir):

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

        svn = libsvn.SVN(wescamp)

        svn.update(None, addon) 

        svn.remove(addon)

        svn.commit("Erasing addon " + addon)
Beispiel #4
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 #5
0
        help=
        "do action only for selected files (only in combination with update/checkout)"
    )

    optionparser.add_option(
        "-e",
        "--exclude",
        help="exclude selected files (only in combination with sync)")

    optionparser.add_option("-t", "--stat", help="gives the status of a file")

    options, args = optionparser.parse_args()
    if (len(args) != 1):
        optionparser.error("incorrect number of arguments")

    svn = libsvn.SVN(args[0])

    ### checkout
    if (options.checkout != None):

        # print debug info
        if (options.verbose):
            print "checkout " + options.checkout + " to " + args[0]

        # fire command
        res = svn.checkout(options.checkout)

        # evaluate result
        evaluate(res)

### update