mewlo.mpacks.core.pack.mpack module

mpack.py Works with packmanager.py to support our pack/extension/addon system

class mewlo.mpacks.core.pack.mpack.MewloPack(packmanager, filepath)[source]

Bases: object

The MewloPack class represents a mewlo “pack” aka extension/plugin/addon/component. It is not the same as a Python “pack”. All code (both core builtin code and 3rd party extensions/plugins) is always represented/supervised/versioned by one and only one mewlo pack. The MewloPack class exposes author and version info about a pack, supports online, version checking, database updating, dependency chains, etc.

It is actually a fairly light-weight structure that:
  • loads a json info file with information about the “addon pack”.
  • dynamically loads(imports) a python code module specified by the json info file.
  • dynamically instantiates a PackWorker object from the above python code module.

It is actually the PackWorker object that, once instantiated, does the work of the addon. So, the right way to think of a Pack is as the bridge middleman responsible for instantiating a PackWorker addon. One reason we use this middleman object is so that we can instantiate (just) the middleman wrapper around the json info file, even when the addon is DISABLED. In this way, we can have instantiated MewloPack objects even for missing/disabled MewloPackWorkers. Additional features that the Pack class provides:

  • displaying addon info, version info, update checking, etc.
  • handles dependency checking, etc.

A MewloPack also keeps an eventlist of any warnings or errors encountered while trying to instantiate the PackWorker. If an addon cannot be located/loaded/etc., the error information will be stored in this eventlist, and the addon will be disabled.

add_outside_replacement_mirror_dirs_for_pack()[source]

Each pack informs the assetmanager that it may have static files that need replacing/overiding.

appendevent(event)[source]
clear_eventlist()[source]
clear_updateinfo()[source]
create_packworker(packpay_class)[source]

Create an appropriate child pack; subclasses will reimplement this to use their preferred child class.

do_enabledisable(mewlosite, flag_enable, reason, eventlist)[source]

Set the disabled flag for the pack. If False than the code for the pack will not be loaded and run. return None on success, or failure on error.

download_versioninfodict()[source]

Download and parse web info file :return: tuple (webdictionary, failure)

dumps(indent=0)[source]

Return a string (with newlines and indents) that displays some debugging useful information about the object.

get_aninfofile_property(infodict, propertyname, defaultval=None)[source]

Lookup property in an info dict and return it, or defaultval if not found.

get_eventlist()[source]
get_hasfailedstartup()[source]

Return true if the pack has failed to startup for any reason (needs update, etc.).

get_homedirpath()[source]

Get home directory of pack.

get_infofilepath()[source]
get_mewlosite()[source]
get_ourinfofile_property(propertyname, defaultval=None)[source]

Lookup property in our info dict and return it, or defaultval if not found.

get_pathtocodemodule()[source]

The info file for the pack should tell us what module file to import; we default to same name as info file but with .py

get_uniqueid()[source]
instantiate_packworker()[source]

Assuming we have imported the dynamic pack module, now create the pack object that we invoke to do work

load_codemodule()[source]

Import the codemodule associated with this pack. Return None on success or failure on error

load_infofile()[source]

Load the info file (json data) for this pack.

shutdown()[source]

Do any shutdown stuff.

sitecomp_assetmanager()[source]
startup(mewlosite, eventlist)[source]

Do any startup stuff.

update_database_check()[source]

Check if there needs to be a database update for this module.

update_download_and_install(mergedinfodict, remotedownloadurl)[source]

Download update file and install it.

update_nicestring(msg='')[source]

Return a warning with info about pack id.

updatecheck()[source]

Check pack for updates. Note this covers not just web updates available, but database updates needed. Division of labor:

We (the MewloPack wrapper) can do a web check but we have to ask the MewloPackWorker to do the database check.
updatecheck_checkfornewfiles()[source]

Check web for new files available, and check our download staging directory for these? The different components here are:

  1. web check at url specified in our info file for an online version check
  2. web check at some central repository based on uniqueid
  3. check in local “to-install” folder
  4. identification of the file to download
Returns:tuple (isneweravail, isupdatecritical, webdictionary, failure)
updatemessage(msg)[source]

Return a warning with info about pack id.

updaterun()[source]

Check pack for updates. Note this covers not just web updates available, but database updates needed. Division of labor:

We (the MewloPack wrapper) can do a web check but we have to ask the MewloPackWorker to do the database check.
Returns:tuple (didupdate, failure)

Table Of Contents

Previous topic

mewlo.mpacks.core.pack package

Next topic

mewlo.mpacks.core.pack.mpackmanager module

This Page