mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-08-05 07:32:25 -04:00
Fixing script commands for old python
This commit is contained in:
parent
a248ae00a0
commit
467a5a6a37
@ -45,7 +45,13 @@ Enjoy!
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import importlib
|
importlib_error = ""
|
||||||
|
|
||||||
|
try:
|
||||||
|
import importlib
|
||||||
|
except ImportError:
|
||||||
|
importlib_error = "Not available in Python 2.7"
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
@ -58,7 +64,7 @@ __version__ = "2.6"
|
|||||||
QT_BINDINGS = ['PyQt4', 'PyQt5', 'PySide', 'PySide2']
|
QT_BINDINGS = ['PyQt4', 'PyQt5', 'PySide', 'PySide2']
|
||||||
"""list: values of all Qt bindings to import."""
|
"""list: values of all Qt bindings to import."""
|
||||||
|
|
||||||
QT_ABSTRACTIONS = ['qtpy', 'pyqtgraph', 'Qt.py']
|
QT_ABSTRACTIONS = ['qtpy', 'pyqtgraph', 'Qt']
|
||||||
"""list: values of all Qt abstraction layers to import."""
|
"""list: values of all Qt abstraction layers to import."""
|
||||||
|
|
||||||
QT4_IMPORT_API = ['QtCore', 'QtGui']
|
QT4_IMPORT_API = ['QtCore', 'QtGui']
|
||||||
@ -364,9 +370,12 @@ def information():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from Qt import __binding__
|
from Qt import __binding__
|
||||||
qt_lib = __binding__
|
except Exception:
|
||||||
except (KeyError, ModuleNotFoundError):
|
# It should be (KeyError, ModuleNotFoundError, ImportError)
|
||||||
|
# but each python version have a different one, and not define others
|
||||||
qt_lib = 'Not set or nonexistent'
|
qt_lib = 'Not set or nonexistent'
|
||||||
|
else:
|
||||||
|
qt_lib = __binding__
|
||||||
|
|
||||||
try:
|
try:
|
||||||
qt_bin = os.environ['PYQTGRAPH_QT_LIB']
|
qt_bin = os.environ['PYQTGRAPH_QT_LIB']
|
||||||
@ -391,6 +400,9 @@ def information():
|
|||||||
|
|
||||||
def qt_bindings():
|
def qt_bindings():
|
||||||
"""Return a list of qt bindings available."""
|
"""Return a list of qt bindings available."""
|
||||||
|
if importlib_error:
|
||||||
|
print(importlib_error)
|
||||||
|
return []
|
||||||
|
|
||||||
bindings = QT_BINDINGS
|
bindings = QT_BINDINGS
|
||||||
for binding in bindings:
|
for binding in bindings:
|
||||||
@ -404,6 +416,10 @@ def qt_bindings():
|
|||||||
|
|
||||||
def qt_abstractions():
|
def qt_abstractions():
|
||||||
"""Return a list of qt abstraction layers available."""
|
"""Return a list of qt abstraction layers available."""
|
||||||
|
if importlib_error:
|
||||||
|
print(importlib_error)
|
||||||
|
return []
|
||||||
|
|
||||||
abstractions = QT_ABSTRACTIONS
|
abstractions = QT_ABSTRACTIONS
|
||||||
for abstraction in abstractions:
|
for abstraction in abstractions:
|
||||||
# check import
|
# check import
|
||||||
@ -416,6 +432,10 @@ def qt_abstractions():
|
|||||||
|
|
||||||
def import_qt_modules_from(use_binding='pyqt5', use_abstraction='qtpy'):
|
def import_qt_modules_from(use_binding='pyqt5', use_abstraction='qtpy'):
|
||||||
"""New approach to import modules using importlib."""
|
"""New approach to import modules using importlib."""
|
||||||
|
if importlib_error:
|
||||||
|
print(importlib_error)
|
||||||
|
return []
|
||||||
|
|
||||||
spec_binding = importlib.util.find_spec(use_binding)
|
spec_binding = importlib.util.find_spec(use_binding)
|
||||||
spec_abstraction = importlib.util.find_spec(use_abstraction)
|
spec_abstraction = importlib.util.find_spec(use_abstraction)
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ def main():
|
|||||||
help="Show available bindings for Qt")
|
help="Show available bindings for Qt")
|
||||||
parser.add_argument('-a', '--abstractions', action='store_true',
|
parser.add_argument('-a', '--abstractions', action='store_true',
|
||||||
help="Show available abstraction layers for Qt bindings")
|
help="Show available abstraction layers for Qt bindings")
|
||||||
parser.add_argument('-e', '--example', action='store_true',
|
# parser.add_argument('-e', '--example', action='store_true',
|
||||||
help="Show qdarkstyle example")
|
# help="Show qdarkstyle example")
|
||||||
parser.add_argument('-v', '--version', action='store_true',
|
parser.add_argument('-v', '--version', action='store_true',
|
||||||
help="Show qdarkstyle version")
|
help="Show qdarkstyle version")
|
||||||
parser.add_argument('--all', action='store_true',
|
parser.add_argument('--all', action='store_true',
|
||||||
@ -58,8 +58,8 @@ def main():
|
|||||||
info = __version__
|
info = __version__
|
||||||
print('\nVersion: %s' % info)
|
print('\nVersion: %s' % info)
|
||||||
|
|
||||||
if args.example:
|
# if args.example:
|
||||||
example.main()
|
# example.main()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user