Bash Script for MythTV which requires Python Dependencies
Question: I wrote a bash script which renames MythTV files based upon data it receives.
I wrote it in bash because bash has the strong points of textual data
manipulation and ease of use.  
You can see the script itself here:
<http://code.google.com/p/mythicallibrarian/source/browse/trunk/mythicalLibrarian>

I have several users which are first time Linux users. I've created an
installation script here which checks dependencies and sets things up in a
graphical manner. You can see the setup script here:
<http://code.google.com/p/mythicallibrarian/source/browse/trunk/mythicalSetup.sh>

Recently, there were some changes to MythTV which require me to migrate the
mysql database access in mythicalLibrarian to a Python bindings script. here:
<http://code.google.com/p/mythicallibrarian/source/browse/trunk/pythonBindings/MythDataGrabber>

Previously, I've tested dependencies using a system like this:

    
    
    test "`uname`" != "Darwin" && LinuxDep=1 || LinuxDep=0
    
    if which agrep >/dev/null; then
            echo "Verified agrep exists"
    else
            test "$LinuxDep" = "1" && echo "Please install 'agrep' on your system" || echo "Please obtain MacPorts and install package agrep"
            d="agrep "
    fi
     .........................
    if which agrep>/dev/null && which curl>/dev/null && which dialog>/dev/null; then
            echo "All checks complete!!!"
    else
            echo "the proper dependencies must be installed..." 
            echo "The missing dependencies are $a$b$c$d$e"
            test "$LinuxDep" = "1" && echo "Debian based users run: apt-get install $a$b$c$d$e" || echo "Please obtain MacPorts and run: port install $a$b$c"
            if [ "$LinuxDep" = "0" ]; then
                    read -n1 -p " Would you like some help on installing MacPorts? Select: (y)/n" MacPortsHelp
    

The python dependencies make it a bit more difficult. I don't know how to test
if I have the linux pacakge "libmyth-python" and "python-lxml" on the system.

How, from BASH, can I test that my Python script MythDataGrabber has its

    
    
     from MythTV import MythDB
    

requirement satisfied?


Answer: You can check the status code of:

    
    
    python -c "import MythDB.MythTV"
    

If it returns non-zero, there was an error, likely an ImportError.

