创建文件exe后,显示以下错误。
此问题可能与 TCP/IP 协议有关。
我不太明白错误是什么。
Traceback (most recent call last):
File "list_queue.py", line 56, in <module>
File "list_queue.py", line 17, in lenth_queue
File "pymqi\__init__.py", line 3024, in connect
File "pymqi\__init__.py", line 1649, in connect_tcp_client
File "pymqi\__init__.py", line 1624, in connect_with_options
pymqi.MQMIError: MQI Error. Comp: 2, Reason 2012: FAILED: MQRC_ENVIRONMENT_ERROR
尽管在 PyCharm 中一切正常,但我输入的所有数据都可以正常工作,脚本也可以正常工作。我的代码:
def lenth_queue():
dict_queue = collections.defaultdict(dict)
queue_manager = input('Enter the name of the queue manager: ')
channel = input('Enter the name of the communication channel: ')
host = input('Enter a name for the IP address of the queue manager: ')
port = input('Enter the name of the queue manager port: ')
conn_info = '%s(%s)' % (host, port)
queue_type = pymqi.CMQC.MQQT_LOCAL
qmgr = pymqi.connect(queue_manager, channel, conn_info)
c = 0
try:
prefix = '*'
pcf = pymqi.PCFExecute(qmgr,response_wait_interval=600000)
attrs = [] # typeList[pymqi.MQOpts]
attrs.append(pymqi.CFST(Parameter=pymqi.CMQC.MQCA_Q_NAME,
String=pymqi.ensure_bytes(prefix)))
attrs.append(pymqi.CFIN(Parameter=pymqi.CMQC.MQIA_Q_TYPE,
Value=queue_type))
attrs.append(pymqi.CFIL(Parameter=pymqi.CMQCFC.MQIACF_Q_ATTRS,
Values=[pymqi.CMQC.MQIA_CURRENT_Q_DEPTH]))
object_filters = []
object_filters.append(
pymqi.CFIF(Parameter=pymqi.CMQC.MQIA_CURRENT_Q_DEPTH,
Operator=pymqi.CMQCFC.MQCFOP_GREATER,
FilterValue=0))
response = pcf.MQCMD_INQUIRE_Q(attrs, object_filters)
for queue_info in response:
queue_name = queue_info[pymqi.CMQC.MQCA_Q_NAME]
queue_depth = queue_info[pymqi.CMQC.MQIA_CURRENT_Q_DEPTH]
dict_queue[queue_name.strip().decode()] = queue_depth
c += 1
writer_queue('Queue_lenth',dict_queue)
return 'File written successfully'
except pymqi.MQMIError as e:
return 'Failed to connect'
def writer_queue(name,dict_q):
txt = io.open(name + ".txt", "w", encoding="utf-8")
for key in dict_q:
txt.write('{}: {} message(s)'.format(key, dict_q[key]) + '\n')
txt.close()
print(lenth_queue())
input('Press ENTER to exit')