'dump device window and pull to local file.'

def dump(self, filename=None, compressed=True, pretty=True):

    content = self.server.jsonrpc.dumpWindowHierarchy(compressed, None)
    if filename:
        with open(filename, 'wb') as f:
            f.write(content.encode('utf-8'))
    if (pretty and ('\n    ' not in content)):
        xml_text = xml.dom.minidom.parseString(content.encode('utf-8'))
        content = U(xml_text.toprettyxml(indent='        '))
    return content
