I try to import a saved project, that I created and worked, in Snap in Poppy web interface and now I have the famous cryptic error message:
""“
Load failed: Type Error: Cannot read property ‘setContents’ of undefined
”""
Any idea to remove something in the big XML files (95791 chars) !
It’s very urgent, I have to do a presentation tomorrow afternoon !
Just an idea : snap_file.xml are customized in this way :
def set_snap_server_variables(host, port, snap_extension=‘.xml’, path=None):
“”" Change dynamically port and host variable in xml Snap! project file"“”
localdir = os.getcwd()
if path is None:
os.chdir(os.path.dirname(os.path.realpath(__file__)))
else:
os.chdir(path)
xml_files = [f for f in os.listdir('.') if f.endswith(snap_extension)]
for filename in xml_files:
with open(filename, 'r') as xf:
xml = xf.read()
# Change host variable
xml = re.sub(r'''<variable name="host"><l>[\s\S]*?<\/l><\/variable>''',
'''<variable name="host"><l>{}</l></variable>'''.format(host), xml)
# Change host argument of "set $robot host"
xml = re.sub(r'''<custom-block s="set \$robot host to \%s"><l>[\s\S]*?<\/l>''',
'''<custom-block s="set $robot host to %s"><l>{}</l>'''.format(host), xml)
# Change port variable
xml = re.sub(r'''<variable name="port"><l>[\s\S]*?<\/l><\/variable>''',
'''<variable name="port"><l>{}</l></variable>'''.format(port), xml)
with open(filename, 'w') as xf:
xf.write(xml)
os.chdir(localdir)
maybe you can check the variables (host, port). Sorry to not be able to help you more, I don’t know this issue.