I am using the followng wordpress xmlrpc module written in python:
But when I run the program I get the following error.You have any idea of how to solve this program??Here is the error that I get
Traceback (most recent call last):
File "<pyshell#28>", line 1, in <module>
wp.call(NewPost(post, True))
File "C:\Python27\lib\site-packages\wordpress_xmlrpc\base.py", line 27, in call
raw_result = server_method(*args)
File "C:\Python27\lib\xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "C:\Python27\lib\xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "C:\Python27\lib\xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Python27\lib\xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "C:\Python27\lib\xmlrpclib.py", line 1467, in parse_response
p.feed(data)
File "C:\Python27\lib\xmlrpclib.py", line 557, in feed
self._parser.Parse(data, 0)
ExpatError: junk after document element: line 2, column 0
This error usually occurs when the response to your call is not valid XML. For example, if it begins with a newline, like this:
\n<?xml version="1.0"?>\n<methodResponse>\n<params>\n<param>\n<value>\n
<array><data>\n <value><string>wp.getUsersBlogs</string></value>
Some versions of WordPress (or some installed plugins) seem to have this issue. Unfortunately, that means the issue is not in your code but with the WordPress instance you are communicating with.
Related
I am following an article and creating my first project,
while i try the below command; the process gets into a loop and starts a server and kills it and again starts a server and kills and it keeps doing this continuously without breaking the loop and exiting.
pserve development.ini --reload
Below is the log
//---------------------------------------------------------
Starting monitor for PID 11912.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "D:\Others\Python\myBlog\lib\site-packages\hupper\ipc.py", line 322, in spawn_main
func(**kwargs)
File "D:\Others\Python\myBlog\lib\site-packages\hupper\worker.py", line 237, in worker_main
func(*spec_args, **spec_kwargs)
File "D:\Others\Python\myBlog\lib\site-packages\pyramid\scripts\pserve.py", line 32, in main
return command.run()
File "D:\Others\Python\myBlog\lib\site-packages\pyramid\scripts\pserve.py", line 229, in run
app = loader.get_wsgi_app(app_name, config_vars)
File "D:\Others\Python\myBlog\lib\site-packages\plaster_pastedeploy\__init__.py", line 131, in get_wsgi_app
global_conf=defaults)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 271, in loadobj
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 450, in get_context
global_additions=global_additions)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 562, in _pipeline_app_context
for name in pipeline[:-1]]
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 562, in <listcomp>
for name in pipeline[:-1]]
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 406, in get_context
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 620, in get_context
object_type, name=name)
File "d:\others\python\myblog\lib\site-packages\paste\deploy\loadwsgi.py", line 646, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "D:\Others\Python\myBlog\lib\site-packages\pkg_resources\__init__.py", line 2405, in load
return self.resolve()
File "D:\Others\Python\myBlog\lib\site-packages\pkg_resources\__init__.py", line 2411, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "D:\Others\Python\myBlog\lib\site-packages\weberror-0.13.1-py3.6.egg\weberror\evalexception.py", line 127
except ValueError, ve:
^
SyntaxError: invalid syntax
Killing server with PID 11912.
Starting monitor for PID 4564.
Traceback (most recent call last):
It looks like the library you're trying to use isn't built for Python 3. The except SomeException, v: syntax is only valid in Python 2. In Python 3 you must use except SomeException as v:. Try running this with Python 2 or finding a newer version of this library that supports Python 3.
Python try...except comma vs 'as' in except
I just installed pootle and I'm having this messagge "Some data on this page is currently being calculated, and the page will be refreshed automatically x seconds". Upon going to the admin page, I found out that there is a failed job so I run on my command line pootle retry_failed_jobs.
And this is what it says :/
`DoesNotExist: Directory matching query does not exist.
Traceback (most recent call last):
File "/var/www/pootle/env/local/lib/python2.7/site-packages/rq/worker.py", line 568, in perform_job
rv = job.perform()
File "/var/www/pootle/env/local/lib/python2.7/site-packages/rq/job.py", line 495, in perform
self._result = self.func(*self.args, **self.kwargs)
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 683, in update_cache_job
instance._update_cache_job(keys, decrement)
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 534, in _update_cache_job
create_update_cache_job_wrapper(p, keys_for_parent, decrement)
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 693, in create_update_cache_job_wrapper
connection.on_commit(_create_update_cache_job)
File "/var/www/pootle/env/local/lib/python2.7/site-packages/transaction_hooks/mixin.py", line 31, in on_commit
func()
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 692, in _create_update_cache_job
create_update_cache_job(queue, instance, keys, decrement=decrement)
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 707, in create_update_cache_job
last_job_key = instance.get_last_job_key()
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 299, in get_last_job_key
key = self.get_cachekey()
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_translationproject/models.py", line 373, in get_cachekey
return self.directory.pootle_path
File "/var/www/pootle/env/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 572, in __get__
rel_obj = qs.get()
File "/var/www/pootle/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 357, in get
self.model._meta.object_name)
DoesNotExist: Directory matching query does not exist.
Traceback (most recent call last):
File "/var/www/pootle/env/local/lib/python2.7/site-packages/rq/worker.py", line 568, in perform_job
rv = job.perform()
File "/var/www/pootle/env/local/lib/python2.7/site-packages/rq/job.py", line 495, in perform
self._result = self.func(*self.args, **self.kwargs)
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 683, in update_cache_job
instance._update_cache_job(keys, decrement)
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 534, in _update_cache_job
create_update_cache_job_wrapper(p, keys_for_parent, decrement)
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 693, in create_update_cache_job_wrapper
connection.on_commit(_create_update_cache_job)
File "/var/www/pootle/env/local/lib/python2.7/site-packages/transaction_hooks/mixin.py", line 31, in on_commit
func()
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 692, in _create_update_cache_job
create_update_cache_job(queue, instance, keys, decrement=decrement)
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 707, in create_update_cache_job
last_job_key = instance.get_last_job_key()
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/core/mixins/treeitem.py", line 299, in get_last_job_key
key = self.get_cachekey()
File "/var/www/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_translationproject/models.py", line 373, in get_cachekey
return self.directory.pootle_path
File "/var/www/pootle/env/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 572, in __get__
rel_obj = qs.get()
File "/var/www/pootle/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 357, in get
self.model._meta.object_name)
DoesNotExist: Directory matching query does not exist.
`
This actually happened when I deleted the language of the project using the admin panel, then suddenly somewhat deleted the folder of that language in the system. What I did is to create a new project and copy the translation files. So I didn't resolve the problem but I was able to remove the refreshing of data.
The stats in Pootle are managed by Redis. Pootle can sometimes get into a state where the stats are broken. Issues like broken files can cause this. You can clean up the stats using this guide.
I'd also report the situation and any tracebacks to the Pootle developers so that they can make the stats calculations more robust.
We've been getting this very frequently lately, on various queries that have worked fine until recently. Here's the full traceback:
...
File "/base/data/home/apps/s~hebkhan/16.370010861782528881/models.py", line 2548, in search_tree
contentItems = db.get(contentKeys)
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1533, in get
return get_async(keys, **kwargs).get_result()
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 844, in get_result
result = rpc.get_result()
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 612, in get_result
return self.__get_result_hook(self)
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1482, in __get_hook
self.check_rpc_success(rpc)
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1234, in check_rpc_success
rpc.check_success()
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 578, in check_success
self.__rpc.CheckSuccess()
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 133, in CheckSuccess
raise self.exception
Error: An error occurred for the API request datastore_v3.Get().
I've seen similar issues being mentioned but nowhere was there any hint to the source of the problem.
I should also mention that this app is using python2.5 and we've yet to make the transition to python2.7. However, I don't think the could be related since the error comes from an RPC call that occurs in the Datastore.
I am using lxml to scrape html. This code works.
lxml.html.parse( "http://google.com/" )
This code does not.
lxml.html.parse( "http://google.com" )
Why does the slash at the end of the URL matter? Thank you.
To be clear, here is the error log that python is giving me from the latter code.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/davidfaux/epd-7.2-2-rh5-x86/lib/python2.7/site-packages/lxml/html/__init__.py", line 692, in parse
return etree.parse(filename_or_url, parser, base_url=base_url, **kw)
File "lxml.etree.pyx", line 2953, in lxml.etree.parse (src/lxml/lxml.etree.c:56204)
File "parser.pxi", line 1533, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:82287)
File "parser.pxi", line 1562, in lxml.etree._parseDocumentFromURL (src/lxml/lxml.etree.c:82580)
File "parser.pxi", line 1462, in lxml.etree._parseDocFromFile (src/lxml/lxml.etree.c:81619)
File "parser.pxi", line 1002, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/lxml.etree.c:78528)
File "parser.pxi", line 569, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:74472)
File "parser.pxi", line 650, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:75363)
File "parser.pxi", line 588, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:74665)
IOError: Error reading file 'http://google.com': failed to load HTTP resource
Because without the slash, Google isn't sending you a page, it's sending you a redirect. In fact, it's redirecting you to the URL with the slash! The body of the redirect is probably empty.
i try to test pyapns.
There is a mention of the hexlified_token_str in the documentation.
My token is stored in base64 format.
I try to do this
>>> notify('myapp', base64.decodestring('Sl96FJtZbZDZECSP3EedQJbsXdtlV+LXWd4+jbzvbHM='), {'aps':{'alert': 'Hello!'}})
But I'm wrong.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-i686/egg/pyapns/client.py", line 54, in notify
File "build/bdist.linux-i686/egg/pyapns/client.py", line 76, in _xmlrpc_thread
File "/usr/lib/python2.5/xmlrpclib.py", line 1147, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.5/xmlrpclib.py", line 1437, in __request
verbose=self.__verbose
File "/usr/lib/python2.5/xmlrpclib.py", line 1201, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib/python2.5/xmlrpclib.py", line 1340, in _parse_response
return u.close()
File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 8002: "Can't deserialize input: not well-formed (invalid token): line 9, column 18">
How do I do hexlified it correctly ?
It was too late yesterday ...
It did the job :
binascii.hexlify(base64.decodestring('Sl96FJtZbZDZECSP3EedQJbsXdtlV+LXWd4+jbzvbHM='))
It was just an obsolete token !