| Author | 
		  Message
		 | 
		
		  | bobbee | 
		  
		    
			  
				 Posted: Mon Apr 11, 2022 9:54 am    Post subject: pyqi channel type | 
				     | 
			   
			 
		   | 
		
		
		    Knight
 
 Joined: 20 Sep 2001 Posts: 546 Location: Tampa 
  | 
		  
		    
			  
				I have the following lines of code.
 
 
   
	| Code: | 
   
  
	 channel_type = channel_info[pymqi.CMQCFC.MQIACH_CHANNEL_TYPE]
 
                print('Channel type = ', type(channel_type)) | 
   
 
 
 
 
How do I do a lookup to get the string value for the returned channel type INT? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | gbaddeley | 
		  
		    
			  
				 Posted: Mon Apr 11, 2022 3:21 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Knight
 
 Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia 
  | 
		  
		    
			  
				In C/C++, the header file cmqstrc.h contains functions for converting a multitude of MQ constants to their string names. MQCHT_STR returns the channel type string. I don't know if this is available for Phython. You may need to copy the code into your type() function. _________________ Glenn | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | hughson | 
		  
		    
			  
				 Posted: Mon Apr 11, 2022 10:29 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Padawan
 
 Joined: 09 May 2013 Posts: 1967 Location: Bay of Plenty, New Zealand 
  | 
		  
		    
			  
				You should do something like this. You might need some extra import statements at the top of your program for this to work, but this was good for me.
 
 
   
	| Code: | 
   
  
	d = _MQConst2String(CMQXC, 'MQCHT_')
 
if channel_type in d:
 
  print('Channel type = ', d[channel_type])
 
else:
 
  print('Channel type = ', channel_type) | 
   
 
 
Cheers,
 
Morag _________________ Morag Hughson @MoragHughson
 
IBM MQ Technical Education Specialist
 
Get your IBM MQ training here!
 
MQGem Software | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | bobbee | 
		  
		    
			  
				 Posted: Tue Apr 12, 2022 4:12 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Knight
 
 Joined: 20 Sep 2001 Posts: 546 Location: Tampa 
  | 
		  
		    
			  
				I found a sample using _MQConst2String, that is what I was looking for. I am assuming it is buried in pymqe. My import for that does not work. Trying to figure it out. Linux environment.
 
 
   
	| Code: | 
   
  
	try:
 
    from . import pymqe # type: ignore
 
except ImportError:
 
    import pymqe # type: ignore # Backward compatibility | 
   
 
 
 
UPDATE:
 
Interesting I see the code in GITHUB. pymqi/code/pymqi/__init__.py. Don't know why I am not getting to it. I am at PYTHON3 v3.8
 
 
   
	| Code: | 
   
  
	[mqm@fibbing1 scripts]$ python3 --version
 
Python 3.6.8 | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | bobbee | 
		  
		    
			  
				 Posted: Tue Apr 12, 2022 6:58 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Knight
 
 Joined: 20 Sep 2001 Posts: 546 Location: Tampa 
  | 
		  
		    
			  
				Thank you Morag, again!! That line was what I was looking for. Little modification and it worked!!!
 
 
d - pymqi._MQConst2String(CMQXC, 'MQCHT_')
 
 
Needed a little direction!!! | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | hughson | 
		  
		    
			  
				 Posted: Tue Apr 12, 2022 3:09 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Padawan
 
 Joined: 09 May 2013 Posts: 1967 Location: Bay of Plenty, New Zealand 
  | 
		  
		    
			  
				I have an import statement at top of my file thus:-
 
 
   
	| Code: | 
   
  
	| from pymqi import _MQConst2String | 
   
 
 
 
which is what makes my line work.
 
 
Without that import statement you need to fully qualify the line as you have. And P.S. you need an equal sign!
 
 
   
	| Code: | 
   
  
	| d = pymqi._MQConst2String(CMQXC, 'MQCHT_') | 
   
 
 
 
Cheers,
 
Morag _________________ Morag Hughson @MoragHughson
 
IBM MQ Technical Education Specialist
 
Get your IBM MQ training here!
 
MQGem Software | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | bobbee | 
		  
		    
			  
				 Posted: Wed Apr 13, 2022 2:42 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Knight
 
 Joined: 20 Sep 2001 Posts: 546 Location: Tampa 
  | 
		  
		    
			  
				It's these little things that make one's day sunny.
 
 
I looked and looked and did not see examples and the the 'pymqi' full qualification hit me. I actually thought at one time I did try an IMPORT like that. Must have had it slightly different. I will adjust the code. Thanks from the peanut gallery!!
 
 
I am writing a MQ Healthcheck/Hardening script at someone's request. It is actually an interesting script. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |