-
Notifications
You must be signed in to change notification settings - Fork 90
/
fOutputVersionInformation.py
186 lines (176 loc) · 7.43 KB
/
fOutputVersionInformation.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import math, platform, sys;
import mProductDetails;
from foConsoleLoader import foConsoleLoader;
from mColorsAndChars import \
COLOR_ERROR, CHAR_ERROR, \
COLOR_LIST, CHAR_LIST, \
COLOR_OK, CHAR_OK, \
COLOR_WARNING, CHAR_WARNING, \
COLOR_HILITE, COLOR_INFO, COLOR_NORMAL, \
CONSOLE_UNDERLINE;
oConsole = foConsoleLoader();
try:
from fOutputLogo import fOutputLogo as f0OutputLogo;
except ModuleNotFoundError as oException:
if oException.args[0] != "No module named 'fOutputLogo'":
raise;
f0OutputLogo = None;
def fOutputProductDetails(oProductDetails, bIsMainProduct, bShowInstallationFolders, bCheckForUpdates, bCheckForUpdatesSuccessful):
oConsole.fOutput(*(
[
"│ ", (
[COLOR_WARNING, CHAR_WARNING] if (
(
bCheckForUpdates and (
not bCheckForUpdatesSuccessful or
(not oProductDetails.bVersionIsUpToDate and not oProductDetails.bVersionIsPreRelease)
)
) or (
oProductDetails.bHasTrialPeriod and oProductDetails.bInTrialPeriod
)
) else
[COLOR_LIST, CHAR_LIST] if bCheckForUpdates and bCheckForUpdatesSuccessful and oProductDetails.bVersionIsPreRelease else
[COLOR_OK, CHAR_OK] if oProductDetails.o0License or not oProductDetails.bRequiresLicense else
[COLOR_ERROR, CHAR_ERROR]
), " ", (
COLOR_INFO if (not oProductDetails.bRequiresLicense or oProductDetails.o0License) else
COLOR_WARNING if (oProductDetails.bHasTrialPeriod and oProductDetails.bInTrialPeriod) else
COLOR_ERROR
) + (CONSOLE_UNDERLINE if oProductDetails.o0License else 0),
oProductDetails.sProductName, COLOR_NORMAL, " version: ", (
COLOR_WARNING if (
bCheckForUpdates and (
not bCheckForUpdatesSuccessful or
(not oProductDetails.bVersionIsUpToDate and not oProductDetails.bVersionIsPreRelease)
)
) else
COLOR_HILITE
), str(oProductDetails.oProductVersion),
] + (
bShowInstallationFolders and [
COLOR_NORMAL, " installed at ", COLOR_HILITE, oProductDetails.s0InstallationFolderPath,
] or [ ]
) + (
[] if (not oProductDetails.bRequiresLicense or oProductDetails.o0License) else
[COLOR_NORMAL, " ", COLOR_WARNING, "(in trial period)"] if (oProductDetails.bHasTrialPeriod and oProductDetails.bInTrialPeriod) else
[COLOR_NORMAL, " ", COLOR_ERROR, "(no valid license found)"]
) + (
[] if not bCheckForUpdates else
[COLOR_NORMAL, " ", COLOR_WARNING, "(no respository)"] if oProductDetails.o0Repository is None else
[COLOR_NORMAL, " ", COLOR_ERROR, "(cannot check for updates)"] if not bCheckForUpdatesSuccessful else
[COLOR_NORMAL, " ", COLOR_INFO, "(pre-release, last release version is ", str(oProductDetails.oLatestProductVersion), ")"]
if oProductDetails.bVersionIsPreRelease else
[COLOR_NORMAL, " ", COLOR_WARNING, "(old, latest release version is ", str(oProductDetails.oLatestProductVersion), ")"]
if not oProductDetails.bVersionIsUpToDate else
[]
) + [
COLOR_NORMAL, ".",
]
));
def fOutputVersionInformation(bCheckForUpdates, bShowInstallationFolders, dsAdditionalVersion_by_sName = {}):
# Read product details for rs and all modules it uses.
aoProductDetails = mProductDetails.faoGetProductDetailsForAllLoadedModules();
o0MainProductDetails = mProductDetails.fo0GetProductDetailsForMainModule();
oConsole.fLock();
try:
aoProductDetailsCheckedForUpdates = [];
aoProductDetailsSuccessfullyCheckedForUpdates = [];
if bCheckForUpdates:
for oProductDetails in aoProductDetails:
if oProductDetails.o0Repository is None:
continue;
aoProductDetailsCheckedForUpdates.append(oProductDetails);
oConsole.fProgressBar(
len(aoProductDetailsCheckedForUpdates) * 1.0 / len(aoProductDetails),
"Checking %s for updates..." % oProductDetails.sProductName,
);
try:
oProductDetails.foGetLatestProductDetailsFromRepository();
except mProductDetails.mExceptions.cProductDetailsException as oException:
oConsole.fOutput(
COLOR_ERROR, CHAR_ERROR,
COLOR_NORMAL, " Version check for ",
COLOR_INFO, oProductDetails.sProductName,
COLOR_NORMAL, " failed: ",
COLOR_INFO, str(oException),
);
else:
aoProductDetailsSuccessfullyCheckedForUpdates.append(oProductDetails);
if len(aoProductDetailsSuccessfullyCheckedForUpdates) == 0:
oConsole.fOutput(
COLOR_WARNING, CHAR_WARNING,
COLOR_NORMAL, "Failed to get any product version information.",
);
oConsole.fOutput(
" (This often indicates you are running a ",
COLOR_INFO, "pre-release",
COLOR_NORMAL, " version, or a version that is very ",
COLOR_INFO, "out of date",
COLOR_NORMAL, ").",
);
oConsole.fOutput(
" To try and resolve this issue, please update this product to the latest",
);
oConsole.fOutput(
" version and try again.",
);
if f0OutputLogo:
f0OutputLogo();
oConsole.fOutput(
COLOR_NORMAL, "┌───[",
COLOR_HILITE, " Version information ",
COLOR_NORMAL, "]", sPadding = "─",
);
# Output the main product information first, then its dependencies alphabetically:
if o0MainProductDetails:
fOutputProductDetails(
o0MainProductDetails,
bIsMainProduct = True,
bShowInstallationFolders = bShowInstallationFolders,
bCheckForUpdates = bCheckForUpdates,
bCheckForUpdatesSuccessful = o0MainProductDetails in aoProductDetailsSuccessfullyCheckedForUpdates,
);
doRemainingProductDetails_by_sName = dict([
(oProductDetails.sProductName, oProductDetails)
for oProductDetails in aoProductDetails
if oProductDetails != o0MainProductDetails
]);
for sProductName in sorted(doRemainingProductDetails_by_sName.keys()):
oProductDetails = doRemainingProductDetails_by_sName[sProductName];
fOutputProductDetails(
oProductDetails,
bIsMainProduct = False,
bShowInstallationFolders = bShowInstallationFolders,
bCheckForUpdates = bCheckForUpdates,
bCheckForUpdatesSuccessful = oProductDetails in aoProductDetailsSuccessfullyCheckedForUpdates,
);
oConsole.fOutput(
COLOR_NORMAL, "│ ",
COLOR_LIST, CHAR_LIST,
COLOR_NORMAL, " ", COLOR_INFO, "Platform",
COLOR_NORMAL, " OS: ", COLOR_INFO, platform.platform(),
COLOR_NORMAL, " on ", COLOR_INFO, platform.machine(),
COLOR_NORMAL, " processor.",
);
uProcessISABits = math.log(sys.maxsize + 1, 2) + 1;
oConsole.fOutput(
COLOR_NORMAL, "│ ",
COLOR_LIST, CHAR_LIST,
COLOR_NORMAL, " ", COLOR_INFO, "Python",
COLOR_NORMAL, " version: ", COLOR_INFO, str(platform.python_version()),
COLOR_NORMAL, ", ", COLOR_INFO, "%d" % uProcessISABits, " bit",
COLOR_NORMAL, ".",
);
for (sName, sVersion) in dsAdditionalVersion_by_sName.items():
oConsole.fOutput(
COLOR_NORMAL, "│ ",
COLOR_LIST, CHAR_LIST,
COLOR_NORMAL, " ", COLOR_INFO, sName,
COLOR_NORMAL, " version: ", COLOR_INFO, sVersion,
COLOR_NORMAL, ".",
);
oConsole.fOutput(
COLOR_NORMAL, "└", sPadding = "─",
);
finally:
oConsole.fUnlock();