ElemenTree错误,prestashop - openerp连接器模块

时间:2013-11-24 08:10:50

标签: python xml parsing openerp prestashop

我正在使用prestashop-openerp连接器launchpad site

可以安装Everyhting,没有错误,但是当我尝试connect使用我的远程prestashop网站界面时会抛出此错误:

ParseError: mismatched tag: line 13, column 2

服务器回溯:

Server Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 89, in send
return openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 292, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 626, in dispatch
res = fn(db, uid, *params)
File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 188, in execute_kw
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 131, in wrapper
return f(self, dbname, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 197, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/usr/lib/pymodules/python2.7/openerp/osv/osv.py", line 185, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/usr/prestaconnect/prestashoperpconnect/prestashoperpconnect/prestashop_model.py", line 103, in synchronize_metadata
import_batch(session, model, backend_id)
File "/usr/prestaconnect/prestashoperpconnect/prestashoperpconnect/unit/import_synchronizer.py", line 663, in import_batch
importer.run(filters=filters, **kwargs)
File "/usr/prestaconnect/prestashoperpconnect/prestashoperpconnect/unit/import_synchronizer.py", line 176, in run
record_ids = self._run_page(filters)
File "/usr/prestaconnect/prestashoperpconnect/prestashoperpconnect/unit/import_synchronizer.py", line 184, in _run_page
record_ids = self.backend_adapter.search(filters)
File "/usr/prestaconnect/prestashoperpconnect/prestashoperpconnect/unit/backend_adapter.py", line 126, in search
return api.search(self._prestashop_model, filters)
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 494, in search
search(resource, options=options)
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 348, in search
return self.get(resource, options=options)
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 516, in get
response = super(PrestaShopWebServiceDict, self).get(resource, resource_id=resource_id, options=options)
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 366, in get
return self.get_with_url(full_url)
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 536, in get_with_url
response = super(PrestaShopWebServiceDict, self).get_with_url(url)
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 375, in get_with_url
r = self._execute(url, 'GET')
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 206, in _execute
self._check_status_code(r.status_code, r.content)
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 144, in _check_status_code
ps_error_code, ps_error_msg = self._parse_error(content)
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 116, in _parse_error
error_answer = self._parse(xml_content)
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 619, in _parse
parsed_content = super(PrestaShopWebServiceDict, self)._parse(content)
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 227, in _parse
parsed_content = ElementTree.fromstring(unicode_encode.unicode2encoding(content))
File "<string>", line 124, in XML

我已经搜索了一些答案,看到了question here on SO,但仍然没有线索。

IDK,如果这实际上是模块或prestapyt库的错误,我真的不知道,或者在我的prestashop安装中有一些xml错误。

有人使用过这个模块,或者对此有任何线索?

提前致谢!

修改

这是prestapyt的过时版本,现在我有最后一个版本,并且回溯错误更明确:

  parsed_content = super(PrestaShopWebServiceDict, self)._parse(content)
  File "/usr/local/lib/python2.7/dist-packages/prestapyt-0.6.0-py2.7.egg/prestapyt/prestapyt.py", line 214, in _parse
raise PrestaShopWebServiceError('HTTP XML response is not parsable : %s. %s' % (e, content[:512]))
  PrestaShopWebServiceError: 'HTTP XML response is not parsable : mismatched tag: line 13, column 2. <HTML>\n<HEAD>\n<TITLE>404 Not Found</TITLE>\n</HEAD>\n<BODY>\n<H1>Not Found</H1>\nThe requested document was not found on this server.\n<P>\n<HR>\n<ADDRESS>\nWeb Server at taxco.com.ve\n</ADDRESS>\n</BODY>\n</HTML>\n\n<!--\n   - Unfortunately, Microsoft has added a clever new\n   - "feature" to Internet Explorer. If the text of\n   - an error\'s message is "too small", specifically\n   - less than 512 bytes, Internet Explorer returns\n   - its own error message. You can turn that off,\n   - but it\'s pretty tricky to find switch'

这是404错误,但我不知道应该在那里添加哪个文件,有经验实现此连接的人?

1 个答案:

答案 0 :(得分:1)

您已经(几乎)有错误消息和回溯中的所有线索:prestapit正在获取一些格式错误/损坏的XML。缺少的线索是:哪个url确实返回格式错误的XML以及这个破坏的XML是什么样的。

如果你看一下你的追溯,那么你可以在一个显而易见的地方找到你的追踪网址和回复:

File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 375, in get_with_url
r = self._execute(url, 'GET')
File "/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py", line 206, in _execute
self._check_status_code(r.status_code, r.content)

所以从/usr/prestaconnect/prestashoperpconnect/src/prestapyt/prestapyt/prestapyt.py的第= ~205行,您可以打印或记录网址和响应以进行检查,或者只是添加一个断点进入调试器(如果没有明确地在守护进程模式下运行。)