Rocket Terminal Emulator

 View Only

 Automate Rocket BlueZone Mainframe Display with Python 3.8

Jump to Best Answer
Michael Quinn's profile image
Michael Quinn posted 07-11-2022 09:37
I recently upgraded my Python from 3.6 to 3.8 and now I am receiving an error when running my scripts. 
BlueZone version is BlueZone Mainframe Display v7.1.4.2796 (64-bit)
Python version is 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]
My company limits what Python modules I can use. I was able to get the below code to work in Python 3.6
from comtypes.client import CreateObject

bzhao = CreateObject("BZWhll.WhllObj")
bzhao.Connect()
bzhao.WaitReady(10, 1)​
When I run the above code I now get the below error.
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\ctypes\__init__.py", line 123, in WINFUNCTYPE
    return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.HRESULT'>, (<class 'comtypes.BSTR'>, <class 'comtypes.automation.tagVARIANT'>, <class 'comtypes.automation.tagVARIANT'>), 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/PL14714/Desktop/Mike/Python/connectToMainframe/connectToMainframe.py", line 3, in <module>
    bzhao = CreateObject("BZWhll.WhllObj")
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
    return _manage(obj, clsid, interface=interface)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\__init__.py", line 188, in _manage
    obj = GetBestInterface(obj)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
    mod = GetModule(tlib)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\_generate.py", line 159, in GetModule
    mod = _CreateWrapper(tlib, pathname)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\_generate.py", line 242, in _CreateWrapper
    mod = _my_import(fullname)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\client\_generate.py", line 26, in _my_import
    return __import__(fullname, globals(), locals(), ['DUMMY'])
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\gen\_B04B8681_A2CE_11D5_903D_00105AABADD3_0_7_1.py", line 1925, in <module>
    IAutPS._methods_ = [
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\__init__.py", line 328, in __setattr__
    self._make_methods(value)
  File "C:\Users\PL14714\AppData\Roaming\Python\Python38\site-packages\comtypes\__init__.py", line 697, in _make_methods
    prototype = WINFUNCTYPE(restype, *argtypes)
  File "C:\Program Files\Python38\lib\ctypes\__init__.py", line 125, in WINFUNCTYPE
    class WinFunctionType(_CFuncPtr):
TypeError: item 2 in _argtypes_ passes a union by value, which is unsupported.

Process finished with exit code 1
​
Limei Wu's profile image
ROCKETEER Limei Wu Best Answer
Hi Michael, your code works in my Python 3.8.10.  This seems a known Python bug in Python 2.7.6 and 3.8.1 and fixed in later versions (3.7.7+ or 3.8.2+). Please see https://stackoverflow.com/questions/63007486/pywinauto-typeerror-item-2-in-argtypes-passes-a-union-by-value-which-is-unsu
https://stackoverflow.com/questions/62037461/getting-error-while-running-a-script-which-uses-pywinauto