vitaliyborodin / google-blog-converters-appengine

Automatically exported from code.google.com/p/google-blog-converters-appengine
Apache License 2.0
0 stars 1 forks source link

AttributeError: Binary instance has no attribute 'replace' #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. ./livejournal2blogger.sh -u russian-knight -p ***
2.
3.

What is the expected output? What do you see instead?

I see:

Traceback (most recent call last):
  File "./../src/livejournal2blogger/lj2b.py", line 461, in <module>
    translator.Translate(sys.stdout)
  File "./../src/livejournal2blogger/lj2b.py", line 198, in Translate
    posts = self._GetPosts()
  File "./../src/livejournal2blogger/lj2b.py", line 239, in _GetPosts
    posts.append(self._TranslatePost(event['events'][0]))
  File "./../src/livejournal2blogger/lj2b.py", line 255, in _TranslatePost
    content_type='html', text=self._TranslateContent(lj_event['event']))
  File "./../src/livejournal2blogger/lj2b.py", line 354, in _TranslateContent
    return content.replace('\r\n', '<br/>')
AttributeError: Binary instance has no attribute 'replace'

What version of the product are you using? On what operating system?

Ubuntu 8.10 64bit
Python 2.5.2 (r252:60911, Oct  5 2008, 19:29:17)

Original issue reported on code.google.com by mkevac on 10 Jan 2009 at 1:57

GoogleCodeExporter commented 8 years ago
Thanks for helping me test out livejournal translations!  I'll look into this 
problem
and have a fix for it in the next release.  If you find a good fix for it, let 
me know.

Original comment by jlu...@gmail.com on 10 Jan 2009 at 7:40

GoogleCodeExporter commented 8 years ago
This happens with me too. 

Windows Vista SP1 Ultimate
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on 
win32

I've done a quick look and found that xmlrpclib treats entries with non-ASCII
characters as xmlrpclib.Binary. Thus they are not returned as String and 
replace()
will not work on them.

But if you try to use xmlrpclib.Binary.data field it will contain string and
everything will work.

The code to fix this could be this:

    if isinstance(lj_event['event'], xmlrpclib.Binary):
      evt = lj_event['event'].data
    else:
      evt = lj_event['event']

Hope this helps!

Original comment by ctpeko3a on 12 Jan 2009 at 9:40

GoogleCodeExporter commented 8 years ago
Thanks for the code snippet!   I'll add this to the next release.  Great to 
know a
little more about the LiveJournal XML-RPC communication protocol.

Original comment by jlu...@gmail.com on 12 Jan 2009 at 10:28

GoogleCodeExporter commented 8 years ago

Original comment by jlu...@gmail.com on 12 Jan 2009 at 10:38