Using pyblog.py, I got the following error, which I then tried to more gracefully handle:
Traceback (most recent call last):
File "C:\Python26\Lib\SITE-P~1\PYTHON~1\pywin\framework\scriptutils.py", line 325, in RunScript
exec codeObject in __main__.__dict__
File "C:\Documents and Settings\mmorisy\Desktop\My Dropbox\python\betterblogmaster.py", line 11, in <module>
date = blogurl.get_recent_posts(1)[0]['dateCreated']
File "C:\Documents and Settings\mmorisy\Desktop\My Dropbox\python\pyblog.py", line 129, in get_recent_posts
return self.execute('metaWeblog.getRecentPosts', blogid, self.username, self.password, numposts)
File "C:\Documents and Settings\mmorisy\Desktop\My Dropbox\python\pyblog.py", line 93, in execute
raise BlogError(fault.faultString)
BlogError: XML-RPC services are disabled on this blog. An admin user can enable them at http://example.com/blogname/wp-admin/options-writing.php
>>>
So I tried the following code to without crashing the script:
for blog in bloglist:
try:
blogurl = pyblog.WordPress('http://example.com' + blog + 'xmlrpc.php', 'admin', 'laxbro24')
date = blogurl.get_recent_posts(1)[0]['dateCreated']
print blog + ', ' + str(date.timetuple().tm_mon) + '/' + str(date.timetuple().tm_mday) + '/' + str(date.timetuple().tm_year)
except BlogError:
print "Oops! The blog at " + blogurl + " is not configured properly."
Only to get the following error:
Traceback (most recent call last):
File "C:\Python26\Lib\SITE-P~1\PYTHON~1\pywin\framework\scriptutils.py", line 325, in RunScript
exec codeObject in __main__.__dict__
File "C:\Documents and Settings\mmorisy\Desktop\My Dropbox\python\betterblogmaster.py", line 13, in <module>
except BlogError:
NameError: name 'BlogError' is not defined
Isn't the name blog error defined by PyBlog, since that's where I got that name in the first place? Am I using "except" wrong? Thanks for any tips!