← Back to team overview

ubuntu-tour team mailing list archive

Progression requirements

 

Hi, at the moment any progression requirements or notices are being hard
coded into ubuntu-tour.py which means that for a new tour to have a
progression requirement they have to edit the main program file. It also
means that we could get very cluttered there, and have a load of stuff
stored in ubuntu-tour which is tour specific.

I have created a system where the program reads the requirements from the
html file. For example look at the new firefox_0.html page.
<!-- "Requirements"
cancontinue = ("firefox-bin" in os.popen("ps aux | grep firefox").read())
elsemessage = ["Firefox is not running.", "We recommend you to start it
before continuing."]
justwarning = True
"Requirements" -->

Basically you can write a few lines of Python code between <!--
"Requirements" and "Requirements" --> . This code needs to set 3 variables.
cancontinue, this is a boolean, True of False, (or 1 or 0 as an integer if
you really want). If it is true, the tour, will progress as normal with
nothing happening. If it is false, then it will show the message elsewarning
in a notification like it does at the moment.
Once if has displayed this message, if just warning is True, then it will
carry onto the next page anyway, if justwarning is False it will stay on the
current page.

You can write as much code as you like in here, you don't even have to
declare all the variables. The default values for the variables are.
cancontinue = True
elsemessage = ["Progression Warning", "We recommend you run the relevant
program before continuing."]
justwarning = True

For example this would be acceptable.

<!-- "Requirements"
file = open("/home/file.txt")
cancontinue = ("firefox-bin" in file.read())
elsemessage = ["Firefox is not running.", "We recommend you to start it
before continuing."]
"Requirements" -->

It is important that that it starts <!-- "Requirements" and ends "Requirements"
-->.
Only the code within these blocks will be run. And it will only try and run
the code if both of those strings exist in the right order.
If you have 2 declarations, only the first one will be used.

At the moment it only works in html files, files that end .html as plain
text files have the script messed up when they are formatted.

To see this in action, pull the latest revision, and try the firefox page.
(English only at the moment)
You shouldn't notice any difference.

Regards

Anthony


ps. What is the address of the ppa?

Follow ups