1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +00:00

Overhauled dependency check

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

View File

@@ -44,10 +44,10 @@ You can find the latest released binary at the following links:
### For running from source:
- 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+
- [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:
```

View File

@@ -37,6 +37,7 @@ from PyQt5 import QtGui, QtCore, QtWidgets, QtNetwork
from xml.dom.minidom import parse
from psutil import Popen, Process
from copy import copy
from distutils.version import StrictVersion
from .shared import md5Checksum, HTMLStripper
from . import comic2ebook
from . import KCC_rc_web
@@ -244,7 +245,7 @@ class VersionThread(QtCore.QThread):
except Exception:
return
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'):
self.newVersion = latestVersion
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")
if 'Amazon kindlegen' in line:
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='
'1000765211">KindleGen</a> is outdated! Creating MOBI might fail.'
' Please update <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&docId='
'1000765211">KindleGen</a> from Amazon\'s website.', 'warning')
'1000765211">KindleGen</a> is outdated! MOBI conversion might fail.', 'warning')
break
else:
self.KindleGen = False

View File

@@ -23,6 +23,7 @@ __docformat__ = 'restructuredtext en'
import os
from hashlib import md5
from html.parser import HTMLParser
from distutils.version import StrictVersion
class HTMLStripper(HTMLParser):
@@ -81,25 +82,27 @@ def dependencyCheck(level):
missing = []
if level > 2:
try:
from PyQt5 import QtCore, QtNetwork, QtWidgets
if tuple(map(int, ('5.2.0'.split(".")))) > tuple(map(int, (QtCore.qVersion().split(".")))):
missing.append('PyQt5 5.2.0+')
from PyQt5.QtCore import qVersion as qtVersion
if StrictVersion('5.2.0') > StrictVersion(qtVersion()):
missing.append('PyQt 5.2.0+')
except ImportError:
missing.append('PyQt5 5.2.0+')
missing.append('PyQt 5.2.0+')
if level > 1:
try:
import psutil
if tuple(map(int, ('2.0.0'.split(".")))) > tuple(map(int, psutil.version_info)):
from psutil import __version__ as psutilVersion
if StrictVersion('2.0.0') > StrictVersion(psutilVersion):
missing.append('psutil 2.0.0+')
except ImportError:
missing.append('psutil 2.0.0+')
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:
missing.append('python-slugify')
missing.append('python-slugify 0.1.0+')
try:
import PIL
if tuple(map(int, ('2.7.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))):
from PIL import PILLOW_VERSION as pillowVersion
if StrictVersion('2.7.0') > StrictVersion(pillowVersion):
missing.append('Pillow 2.7.0+')
except ImportError:
missing.append('Pillow 2.7.0+')