AttributeError: 'NoneType' object has no attribute 'split'

0

I wrote a python script to configure Weblogic Domain. I can see there is an error when im trying to execute with the below lines. I tried debugging with different options and still it is throwing the same error. Please help me out here.

AttributeError: 'NoneType' object has no attribute 'split'

Exporting the Properties to variables.. Problem invoking WLST - Traceback (innermost last): File "/test/wls_domain_creation.py", line 304, in ? File "/test/wls/wls_domain_creation.py", line 61, in export_properties

Here are the lines 61 and 304

machines = _dict.get("machines").split(',') export_properties()

Thanks in advance

Your NoneType object has no attribute ‘split’ error typically means your provided key is not in the dictionary. The split method would be applied to the string returned from the dictionary. Can you test “machines “ is a key in your _dict?

The function call:

_dict.get("machines") return the special Python value None instead of a string (meaning the key machine is not in _dict as @johnmattgrogan said.)

You need to do something like:

value = _dict.get("machines")
if value is None:
    # do something reasonable such as:
    machines = [ ] # empty list
else:
   machines = value.split(',')
export_properties()

(Assuming the code downstream can handle an empty list!)