Quantcast Wuiup: Update script written in python aimed for developers. - WoWInterface
Thread Tools Display Modes
02-24-09, 02:41 AM   #1
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 7
Exclamation Wuiup: Update script written in python aimed for developers.


Wow User Interface UPdater or Wuiup for short is my little hack which I wrote because I had a lot addons which needed manual config/fixes each time they were updated. I builded upon it and it became modular and for some time I've been thinking about public release. It has been on github for some while now I decided to make a topic to see if people are interesting in this kind of script.

There are some points I want to outline before going on:
  1. It hasn't been tested much. It works on my windows config and I've done some testing on mac. I believe it should work on linux as well.
  2. It's aimed at developers/programmers, basically people who know what they are doing.
  3. As I said it's just a hack, I haven't done much restructuring since I wrote first working version so code is ugly/not thought through.
  4. Use at your own risk.
Python 2.6 (I haven't tested it with 2.5 it might/might not work with it.)

How it works:
Wuiup downloads and keeps local version number of all addons which are in your wowinterface.com favorites. If version on wowinterface is different then local version it will download new version from wowinterface.com, delete old local copy and extract new version in wow addon directory. Of course our saved variable persist between updates.

Usually you just want to launch wuiup.py file.
There are some command-line switches. You can get more info by runing wuiup.py with with -h switch.

What are custom updaters and how they work?
By default Wuiup will only update addons in your wowinterface favorites. If you want to update addon which is not hosted in wowinterface you need to write your own custom updater. How to do that?

First you want to make a new file in ./updaters/ directory and call it something, for example wim.py (since I'm going to write custom updater for WIM).
In that file you need to import custom updater abstract class:
from updaters import Updater
Then all you need to do is make a subclass of Updater with a method called update which takes 1 parameter, local version of addon or None if there's no info about local version. This method must return newly installed/updated version or False if update failed for some reason.
def update(self,cv):
    self.current_version = cv
        last_version = False
        if self.logging:
            self.logging.info("Pretending to update WIM" if self.current_version or "Pretending to install WIM")
        last_version = self._some_method_which_actually_updates_addon()
        return last_version
        #Something bad happended
        return False
There's working example in ./updaters/wim.py

What does hooks do and how they work?
Before and after Wuiup updates addon from wowinterface.com or updates one using custom updater it checks if that addon has "before updater" and/or "after update" hooks 'installed'.

How can I 'install' / write such hooks?

All hooks are located in ./hooks/ directory. Filename of each hook is actually adddon_id + ".py" . For wowinterface.com addons, their IDs are their original wowinterface.com IDs.
To get ID of addon which is hosted on wowinterface.com you need to go to it's webpage and then look at pages url, for example:
ID is the number between info and -nameofaddon. In this case 11361.
So if you would want to write a hook which gets called when Overachiever is updated, you would make a file called 11361.py in ./hooks/ directory.
In that file you need to import hook abstract:
from hooks import AddonHookAbstract
And make an subclass of AddonHookAbstract called AddonHook, no other name will work at the moment. Now there's 2 method which you can overwrite -beforeUpdateHook() and afterUpdateHook(). Both should return True if everything worked or False if something went wrong.
Here's a small example:
class AddonHook(AddonHookAbstract):
    def afterUpdateHook(self):
        replaces = {"local bBuffs = true" : "local bBuffs = false",
            "local pBuffs = true" : "local pBuffs = false",
            "local pDebuffs = true" : "local pDebuffs = false",
            "278.5, -174)" : "278.5, -40)",
            "UIParent, 'TOPLEFT', 15, -15)" : "UIParent, 'TOPLEFT', 15, -60)"}
        file_location = os.path.join(self.wowdir,'oUF_Caellian/oUF_cMain.lua')
        return self._replace_text(file_location,replaces)
Where to get it?
It's currently hosted on GitHub and I've uploaded latest version to wowinterface:

If you can't figure out how to set it up - you are probably off with another updater.

As I said at the start, at the moment it's just a "hack-up", I'm more like presenting an idea then a good solution.

Last edited by MaikuMori : 02-24-09 at 03:11 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Dev Tools » Wuiup: Update script written in python aimed for developers.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off