Overhauled dependency check

This commit is contained in:
Paweł Jastrzębski committed 2015-01-05 08:43:15 +01:00
1 parent 5c2c6ed825
commit 5de492ffb6
3 files changed
+19 -17

No files matched your search

+2 -2
View File
@@ -44,10 +44,10 @@ You can find the latest released binary at the following links:
### For running from source: ### For running from source:
- Python 3.3+ - Python 3.3+
- [PyQt5](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.2.0+ - [PyQt](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.2.0+
- [Pillow](http://pypi.python.org/pypi/Pillow/) 2.7.0+ - [Pillow](http://pypi.python.org/pypi/Pillow/) 2.7.0+
- [psutil](https://pypi.python.org/pypi/psutil) 2.0+ - [psutil](https://pypi.python.org/pypi/psutil) 2.0+
- [python-slugify](http://pypi.python.org/pypi/python-slugify) - [python-slugify](http://pypi.python.org/pypi/python-slugify) 0.1.0+
On Debian based distributions these two commands should install all dependencies: On Debian based distributions these two commands should install all dependencies:
``` ```
+4 -5
View File
@@ -37,6 +37,7 @@ from PyQt5 import QtGui, QtCore, QtWidgets, QtNetwork
from xml.dom.minidom import parse from xml.dom.minidom import parse
from psutil import Popen, Process from psutil import Popen, Process
from copy import copy from copy import copy
from distutils.version import StrictVersion
from .shared import md5Checksum, HTMLStripper from .shared import md5Checksum, HTMLStripper
from . import comic2ebook from . import comic2ebook
from . import KCC_rc_web from . import KCC_rc_web
@@ -244,7 +245,7 @@ class VersionThread(QtCore.QThread):
except Exception: except Exception:
return return
latestVersion = XML.childNodes[0].getElementsByTagName('latest')[0].childNodes[0].toxml() latestVersion = XML.childNodes[0].getElementsByTagName('latest')[0].childNodes[0].toxml()
if tuple(map(int, (latestVersion.split(".")))) > tuple(map(int, (__version__.split(".")))): if StrictVersion(latestVersion) > StrictVersion(__version__):
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
self.newVersion = latestVersion self.newVersion = latestVersion
self.md5 = XML.childNodes[0].getElementsByTagName('WindowsMD5')[0].childNodes[0].toxml() self.md5 = XML.childNodes[0].getElementsByTagName('WindowsMD5')[0].childNodes[0].toxml()
@@ -1045,11 +1046,9 @@ class KCCGUI(KCC_ui.Ui_KCC):
line = line.decode("utf-8") line = line.decode("utf-8")
if 'Amazon kindlegen' in line: if 'Amazon kindlegen' in line:
versionCheck = line.split('V')[1].split(' ')[0] versionCheck = line.split('V')[1].split(' ')[0]
if tuple(map(int, (versionCheck.split(".")))) < tuple(map(int, ('2.9'.split(".")))): if StrictVersion(versionCheck) < StrictVersion('2.9'):
self.addMessage('Your <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&docId=' self.addMessage('Your <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&docId='
'1000765211">KindleGen</a> is outdated! Creating MOBI might fail.' '1000765211">KindleGen</a> is outdated! MOBI conversion might fail.', 'warning')
' Please update <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&docId='
'1000765211">KindleGen</a> from Amazon\'s website.', 'warning')
break break
else: else:
self.KindleGen = False self.KindleGen = False
+13 -10
View File
@@ -23,6 +23,7 @@ __docformat__ = 'restructuredtext en'
import os import os
from hashlib import md5 from hashlib import md5
from html.parser import HTMLParser from html.parser import HTMLParser
from distutils.version import StrictVersion
class HTMLStripper(HTMLParser): class HTMLStripper(HTMLParser):
@@ -81,25 +82,27 @@ def dependencyCheck(level):
missing = [] missing = []
if level > 2: if level > 2:
try: try:
from PyQt5 import QtCore, QtNetwork, QtWidgets from PyQt5.QtCore import qVersion as qtVersion
if tuple(map(int, ('5.2.0'.split(".")))) > tuple(map(int, (QtCore.qVersion().split(".")))): if StrictVersion('5.2.0') > StrictVersion(qtVersion()):
missing.append('PyQt5 5.2.0+') missing.append('PyQt 5.2.0+')
except ImportError: except ImportError:
missing.append('PyQt5 5.2.0+') missing.append('PyQt 5.2.0+')
if level > 1: if level > 1:
try: try:
import psutil from psutil import __version__ as psutilVersion
if tuple(map(int, ('2.0.0'.split(".")))) > tuple(map(int, psutil.version_info)): if StrictVersion('2.0.0') > StrictVersion(psutilVersion):
missing.append('psutil 2.0.0+') missing.append('psutil 2.0.0+')
except ImportError: except ImportError:
missing.append('psutil 2.0.0+') missing.append('psutil 2.0.0+')
try: try:
import slugify from slugify import __version__ as slugifyVersion
if StrictVersion('0.1.0') > StrictVersion(slugifyVersion):
missing.append('python-slugify 0.1.0+')
except ImportError: except ImportError:
missing.append('python-slugify') missing.append('python-slugify 0.1.0+')
try: try:
import PIL from PIL import PILLOW_VERSION as pillowVersion
if tuple(map(int, ('2.7.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))): if StrictVersion('2.7.0') > StrictVersion(pillowVersion):
missing.append('Pillow 2.7.0+') missing.append('Pillow 2.7.0+')
except ImportError: except ImportError:
missing.append('Pillow 2.7.0+') missing.append('Pillow 2.7.0+')