Utilities/__init__.py

changeset 2319
116c547dedce
parent 2302
f29e9405c851
child 2525
8b507a9a2d40
child 2553
2ef00ee163a8
equal deleted inserted replaced
2318:3a3ee7cc2ad6 2319:116c547dedce
1500 1500
1501 def checkPyside(): 1501 def checkPyside():
1502 """ 1502 """
1503 Module function to check the presence of PySide. 1503 Module function to check the presence of PySide.
1504 1504
1505 @return flag indicating the presence of PySide (boolean) 1505 @return tuple of two flags indicating the presence of PySide for Python2
1506 """ 1506 and PySide for Python3 (boolean, boolean)
1507 """
1508
1507 try: 1509 try:
1508 # step 1: try Python3 variant of PySide 1510 # step 1: try Python3 variant of PySide
1509 import PySide # __IGNORE_EXCEPTION__ 1511 import PySide # __IGNORE_EXCEPTION__
1510 del PySide 1512 del PySide
1511 return True 1513 py3 = True
1512 except ImportError: 1514 except ImportError:
1513 # step 2: check for a Python2 variant 1515 py3 = False
1514 interpreter = Preferences.getDebugger("PythonInterpreter") 1516
1515 if interpreter == "" or not isinpath(interpreter): 1517 # step 2: check for a Python2 variant
1516 return False 1518 interpreter = Preferences.getDebugger("PythonInterpreter")
1517 1519 if interpreter == "" or not isinpath(interpreter):
1520 py2 = False
1521 else:
1522 py2 = False
1518 checker = os.path.join(getConfig('ericDir'), 1523 checker = os.path.join(getConfig('ericDir'),
1519 "UtilitiesPython2", "PySideImporter.py") 1524 "UtilitiesPython2", "PySideImporter.py")
1520 args = [checker] 1525 args = [checker]
1521 proc = QProcess() 1526 proc = QProcess()
1522 proc.setProcessChannelMode(QProcess.MergedChannels) 1527 proc.setProcessChannelMode(QProcess.MergedChannels)
1523 proc.start(interpreter, args) 1528 proc.start(interpreter, args)
1524 finished = proc.waitForFinished(30000) 1529 finished = proc.waitForFinished(30000)
1525 if finished: 1530 if finished:
1526 if proc.exitCode() == 0: 1531 if proc.exitCode() == 0:
1527 return True 1532 py2 = True
1528 1533
1529 return False 1534 return py2, py3
1530 1535
1531 ################################################################################ 1536 ################################################################################
1532 # Other utility functions below 1537 # Other utility functions below
1533 ################################################################################ 1538 ################################################################################
1534 1539

eric ide

mercurial