File get_firmware.py of Package dvb-firmware-installer
#!/usr/bin/python
import os
import shutil
import tempfile
filename = "dvb-firmwares.tar.bz2"
fwdir= "/lib/firmware"
fwurl = "http://www.linuxtv.org/downloads/firmware" \
+ "/" + filename
dlCommand = "wget --progress=dot -e dotbytes=20k " + fwurl + " -O " + filename
extractCommand = "tar xjf " + filename
installCommand = "mv $(ls dvb-ttpci-01.fw-* -X1|tail -n1) dvb-ttpci-01.fw;" \
"install -m 0755 " \
"*.fw " \
"*.inp " \
"*.hex -t " + fwdir
temp_dir = tempfile.mkdtemp()
os.chdir(temp_dir)
os.system(dlCommand)
os.system(extractCommand)
if not os.path.exists(fwdir):
os.makedirs( fwdir, 0755 )
os.system(installCommand)
shutil.rmtree(temp_dir)