mytyft / phoshare

Automatically exported from code.google.com/p/phoshare
Other
0 stars 0 forks source link

UnicodeEncodeError with AlbumData.xml contains Japanese #36

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. create events, albums, keywords, etc with Japanese letters in iPhoto
2. run Phoshare.app

What is the expected output? What do you see instead?
Phoshare dies with UnicodeEncodeError.

What version of the product are you using? On what operating system?
Mountain Lion 10.8
Phoshare v1.4.7 

Please provide any additional information below.
I got UnicodeEncodeError with Phoshare v1.4.7.
Here are the log:
(start of log)
% /Applications/Phoshare.app/Contents/MacOS/Phoshare --events='2002' 
--iphoto='~/Pictures/iPhoto Library' --export='SOMEWHERE' --link --faces --gps 
--iptcall
Reading iPhoto database from /Users/ori/Pictures/iPhoto Library...
Traceback (most recent call last):
  File "/Applications/Phoshare.app/Contents/Resources/__boot__.py", line 31, in <module>
    _run('Phoshare.py')
  File "/Applications/Phoshare.app/Contents/Resources/__boot__.py", line 28, in _run
    execfile(path, globals(), globals())
  File "/Applications/Phoshare.app/Contents/Resources/Phoshare.py", line 35, in <module>
    main()
  File "/Applications/Phoshare.app/Contents/Resources/Phoshare.py", line 32, in main
    phoshare.phoshare_main.main()
  File "/Applications/Phoshare.app/Contents/Resources/lib/python2.7/phoshare/phoshare_main.py", line 924, in main
    run_phoshare(sys.argv[1:])
  File "/Applications/Phoshare.app/Contents/Resources/lib/python2.7/phoshare/phoshare_main.py", line 904, in run_phoshare
    data = iphotodata.get_iphoto_data(album_xml_file, verbose=options.verbose)
  File "/Applications/Phoshare.app/Contents/Resources/lib/python2.7/appledata/iphotodata.py", line 705, in get_iphoto_data
    data = IPhotoData(album_xml, is_aperture, aperture_data)
  File "/Applications/Phoshare.app/Contents/Resources/lib/python2.7/appledata/iphotodata.py", line 118, in __init__
    self.root_album, aperture_data)
  File "/Applications/Phoshare.app/Contents/Resources/lib/python2.7/appledata/iphotodata.py", line 625, in __init__
    data, images, aperture_data)
  File "/Applications/Phoshare.app/Contents/Resources/lib/python2.7/appledata/iphotodata.py", line 510, in __init__
    print 'No album type for %s.' % name
UnicodeEncodeError: 'ascii' codec can't encode characters in position 18-19: 
ordinal not in range(128)
(end of log)

I think this is because my AlbumData.xml contains Japanese characters in event 
names, album names, etc.
I made a quick patch to fix this problem.
Would you see the patch below and adopt it to Phoshare if you like?

(start of diff)
% diff -u iphotodata.py.orig iphotodata.py
--- iphotodata.py.orig  2012-07-29 00:42:27.000000000 +0900
+++ iphotodata.py       2012-08-08 17:03:38.000000000 +0900
@@ -468,6 +468,9 @@
     """Base class for IPhotoAlbum and IPhotoRoll."""

     def __init__(self, name, albumtype, data, images, aperture_data=None):
+        name = su.fsenc(name)
+        albumtype = su.fsenc(albumtype)
+
         self.name = name
         self._date = None
         self.uuid = None
@@ -528,6 +531,7 @@
         if not self.isfolder() and data and data.has_key("KeyList"):
             keylist = data.get("KeyList")
             for key in keylist:
+                key = su.fsenc(key)
                 image = images.get(key)
                 if image:
                     self.images.append(image)
(end of diff)

Thanks in advance.

Original issue reported on code.google.com by Manabu....@gmail.com on 8 Aug 2012 at 8:14

GoogleCodeExporter commented 8 years ago
Thanks for the fix. I'll roll that into the next update.

Original comment by tsporkert on 10 Aug 2012 at 4:03

GoogleCodeExporter commented 8 years ago
I will include a different fix for this with Phoshare 1.5.0, to be published 
later today. 

Original comment by tsporkert on 30 Sep 2012 at 10:55

GoogleCodeExporter commented 8 years ago

Original comment by tsporkert on 1 Oct 2012 at 2:00