In the first part of this tutorial, we wrote a stand-alone script that generated an RSS feed based upon the files it found in a directory. We'll now convert this script into a channel plugin that Awasu can run.
Defining the plugin's parameters
We would like the directory to be monitored to be configurable by the user, so we need to set up a .PLUGIN file that defines the plugin's parameters:
[ChannelParameterDefinition-1] Name = Directory to monitor Type = string Description = The directory containing the files you want to monitor. IsRequired = 1
This is a simple INI file This file must have the same base name as the plugin script, but with a .PLUGIN extension. that contains one ChannelParameterDefinition section for each parameter the plugin has.
How Awasu invokes the plugin channel
When Awasu updates the plugin channel, it runs the script with a single argument, the path to an INI file that contains information the plugin will need to run, in particular, the configuration parameters we defined above:
[ChannelParameters] Directory to monitor = ...
Since this is just a regular INI file, scripts can use the normal WIN32 calls to retrieve the information, but since there are some subtleties in how Awasu passes information through in these INI files, awasu_tools provides a class that takes care of everything for you:
from awasu_tools.config import ConfigFile # get our parameters invocation_config = ConfigFile( sys.argv ) dir_to_monitor = invocation_config.get_string( "ChannelParameters" , "Directory to monitor" )
Instead of having a hard-coded directory path, we now instantiate a ConfigFile object using the INI file Awasu passes us (via sys.argv), then retrieve the directory the user wants to monitor from that.
And we're done, this plugin channel can now be used in Awasu. It really is that easy!
[ + ]
|1.||↵||This file must have the same base name as the plugin script, but with a .PLUGIN extension.|