OpenIxia / IxNetwork

A central location for IxNetwork sample scripts and utilities. Please also visit http://openixia.com
MIT License
50 stars 59 forks source link

Bad string check in connectIxChassis #2

Closed bluemeerkat closed 6 years ago

bluemeerkat commented 6 years ago

Hi, I hit a problem when invoking connectIxChassis() in IxNetRestApiPortMgmt.py from RobotFramework. This check at the top of the function is too restrictive: "if type(chassisIp) is str:" The problem is that when I invoke the function from RF the type of chassisIp passed into this is actually "unicode", which is a sub-class of string... but which fails this test. This makes this function unusable for me.

This alternative line works for string or any sub-class of string, so I request you fix up using that logic or similar. This works as basestring is a common base class of all strings: "if isinstance(chassisIp, basestring):"

I have been running with this for several months, but would be good if you could integrate the fix, so I don't have to keep manually applying the delta.

Thanks,

David

hubertgee commented 6 years ago

Fixed. Your suggestion to use basestring is for python2. These modules are written in Python3. So to accommodate both quickly, it looks for list instead. If the ixChassisIp is not in a list, then convert the str including unicode str to a list.