Update script to check openlp dependecies - catching all imports properly

This commit is contained in:
Martin Zibricky 2011-07-10 14:00:58 +02:00
parent 5951d2c2a3
commit cfb1a06bd3

View File

@ -95,6 +95,10 @@ def check_vers(version, required, text):
return False return False
def print_vers_fail(required, text):
print(' %s >= %s ... FAIL' % (text, required))
def verify_python(): def verify_python():
if not check_vers(list(sys.version_info), VERS['Python'], text='Python'): if not check_vers(list(sys.version_info), VERS['Python'], text='Python'):
exit(1) exit(1)
@ -102,15 +106,25 @@ def verify_python():
def verify_versions(): def verify_versions():
print('Verifying version of modules...') print('Verifying version of modules...')
try:
from PyQt4 import QtCore from PyQt4 import QtCore
check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'],
'PyQt4') 'PyQt4')
check_vers(QtCore.qVersion(), VERS['Qt4'], check_vers(QtCore.qVersion(), VERS['Qt4'],
'Qt4') 'Qt4')
except ImportError:
print_vers_fail(VERS['PyQt4'], 'PyQt4')
print_vers_fail(VERS['Qt4'], 'Qt4')
try:
import sqlalchemy import sqlalchemy
check_vers(sqlalchemy.__version__, VERS['sqlalchemy'], 'sqlalchemy') check_vers(sqlalchemy.__version__, VERS['sqlalchemy'], 'sqlalchemy')
except ImportError:
print_vers_fail(VERS['sqlalchemy'], 'sqlalchemy')
try:
import enchant import enchant
check_vers(enchant.__version__, VERS['enchant'], 'enchant') check_vers(enchant.__version__, VERS['enchant'], 'enchant')
except ImportError:
print_vers_fail(VERS['enchant'], 'enchant')
def check_module(mod, text='', indent=' '): def check_module(mod, text='', indent=' '):
@ -125,24 +139,31 @@ def check_module(mod, text='', indent=' '):
def verify_pyenchant(): def verify_pyenchant():
print('Enchant...') w('Enchant (spell checker)... ')
try:
import enchant import enchant
w(os.linesep)
backends = ', '.join([x.name for x in enchant.Broker().describe()]) backends = ', '.join([x.name for x in enchant.Broker().describe()])
print(' available backends: %s' % backends) print(' available backends: %s' % backends)
langs = ', '.join(enchant.list_languages()) langs = ', '.join(enchant.list_languages())
print(' available languages: %s' % langs) print(' available languages: %s' % langs)
except ImportError:
w('FAIL' + os.linesep)
def verify_pyqt(): def verify_pyqt():
print('Qt4 image formats...') w('Qt4 image formats... ')
try:
from PyQt4 import QtGui from PyQt4 import QtGui
read_f = ', '.join([unicode(format).lower() \ read_f = ', '.join([unicode(format).lower() \
for format in QtGui.QImageReader.supportedImageFormats()]) for format in QtGui.QImageReader.supportedImageFormats()])
write_f= ', '.join([unicode(format).lower() \ write_f= ', '.join([unicode(format).lower() \
for format in QtGui.QImageWriter.supportedImageFormats()]) for format in QtGui.QImageWriter.supportedImageFormats()])
w(os.linesep)
print(' read: %s' % read_f) print(' read: %s' % read_f)
print(' write: %s' % write_f) print(' write: %s' % write_f)
from PyQt4 import phonon except ImportError:
w('FAIL' + os.linesep)
def main(): def main():
@ -157,7 +178,7 @@ def main():
for m in OPTIONAL_MODULES: for m in OPTIONAL_MODULES:
check_module(m[0], text=m[1]) check_module(m[0], text=m[1])
if sys.platform.startswith('win'): if is_win:
print('Checking for Windows specific modules...') print('Checking for Windows specific modules...')
for m in WIN32_MODULES: for m in WIN32_MODULES:
check_module(m) check_module(m)