forked from pyfa-org/Pyfa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprereqsCheck.py
97 lines (79 loc) · 3.24 KB
/
prereqsCheck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import platform
import re
import sys
version_block = ''
class PreCheckException(Exception):
pass
class PreCheckMessage:
def __init__(self, msg):
# wx may not be installed, in which case print to console. For all other prechecks, should pop up a MessageDialog
try:
import wx
app = wx.App(False)
wx.MessageBox(msg, 'Error', wx.ICON_ERROR | wx.STAY_ON_TOP)
app.MainLoop()
except (KeyboardInterrupt, SystemExit):
raise
except:
pass
finally:
print(msg)
def version_precheck():
global version_block
version_block += "\nOS version: {}".format(platform.platform())
version_block += "\nPython version: {}".format(sys.version)
if sys.version_info < (3, 6):
msg = "pyfa requires python 3.6"
raise PreCheckException(msg)
try:
# the way that the version string is imported in wx is odd, causing us to have to split out the imports like this. :(
from wx.__version__ import VERSION, VERSION_STRING
if VERSION[0] < 4:
raise Exception()
if VERSION[3] != '':
if VERSION[3][0] == 'b' and int(VERSION[3][-1]) < 2:
raise Exception()
import wx
version_block += "\nwxPython version: {} ({})".format(VERSION_STRING, wx.wxWidgets_version)
except (KeyboardInterrupt, SystemExit):
raise
except:
msg = "pyfa requires wxPython v4.0.0b2+. You can download wxPython from https://wxpython.org/pages/downloads/"
raise PreCheckException(msg)
try:
import sqlalchemy
saMatch = re.match("([0-9]+).([0-9]+).([0-9]+)(([b\.])([0-9]+))?", sqlalchemy.__version__)
version_block += "\nSQLAlchemy version: {}".format(sqlalchemy.__version__)
if (int(saMatch.group(1)), int(saMatch.group(2)), int(saMatch.group(3))) < (1, 0, 5):
raise Exception()
except (KeyboardInterrupt, SystemExit):
raise
except:
msg = "pyfa requires SQLAlchemy v1.0.5+. You can download SQLAlchemy from https://www.sqlalchemy.org/download.html"
raise PreCheckException(msg)
try:
import logbook
logVersion = logbook.__version__.split('.')
version_block += "\nLogbook version: {}".format(logbook.__version__)
if int(logVersion[0]) < 1:
raise Exception()
except (KeyboardInterrupt, SystemExit):
raise
except:
raise PreCheckException("pyfa requires Logbook version 1.0.0+. You can download Logbook from https://pypi.python.org/pypi/Logbook")
try:
import requests
version_block += "\nRequests version: {}".format(requests.__version__)
except (KeyboardInterrupt, SystemExit):
raise
except:
msg = "pyfa requires the requests module. You can download requests from https://pypi.python.org/pypi/requests"
raise PreCheckException(msg)
try:
import dateutil
version_block += "\nDateutil version: {}".format(dateutil.__version__)
except (KeyboardInterrupt, SystemExit):
raise
except:
msg = "pyfa requires the python-dateutil module. You can download python-dateutil form https://pypi.python.org/pypi/python-dateutil"
raise PreCheckException(msg)