dulajshare123 / munki

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

Munki 2: UnicodeDecodeError on MunkiItems.py setting icon_path #289

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I had an item in my repo whose display_name contained a non-ASCII character:

Adobe® Integrated Runtime

Traceback:

Traceback (most recent call last):
  File "/Users/test/Library/Developer/Xcode/DerivedData/Managed_Software_Center-ggwcjffoisuknifuamzcmgnpypni/Build/Products/Debug/Managed Software Center.app/Contents/Resources/MSUAppDelegate.py", line 77, in applicationDidFinishLaunching_
    self.mainWindowController.loadInitialView()
  File "/Users/test/Library/Developer/Xcode/DerivedData/Managed_Software_Center-ggwcjffoisuknifuamzcmgnpypni/Build/Products/Debug/Managed Software Center.app/Contents/Resources/MSUMainWindowController.py", line 145, in loadInitialView
    if MunkiItems.getEffectiveUpdateList():
  File "/Users/test/Library/Developer/Xcode/DerivedData/Managed_Software_Center-ggwcjffoisuknifuamzcmgnpypni/Build/Products/Debug/Managed Software Center.app/Contents/Resources/MunkiItems.py", line 154, in getEffectiveUpdateList
    optional_item_names = [item['name'] for item in getOptionalInstallItems()]
  File "/Users/test/Library/Developer/Xcode/DerivedData/Managed_Software_Center-ggwcjffoisuknifuamzcmgnpypni/Build/Products/Debug/Managed Software Center.app/Contents/Resources/MunkiItems.py", line 64, in getOptionalInstallItems
    for item in getInstallInfo().get('optional_installs', [])]
  File "/Users/test/Library/Developer/Xcode/DerivedData/Managed_Software_Center-ggwcjffoisuknifuamzcmgnpypni/Build/Products/Debug/Managed Software Center.app/Contents/Resources/MunkiItems.py", line 514, in __init__
    super(OptionalItem, self).__init__(*arg, **kw)
  File "/Users/test/Library/Developer/Xcode/DerivedData/Managed_Software_Center-ggwcjffoisuknifuamzcmgnpypni/Build/Products/Debug/Managed Software Center.app/Contents/Resources/MunkiItems.py", line 276, in __init__
    self['icon'] = self.getIcon()
  File "/Users/test/Library/Developer/Xcode/DerivedData/Managed_Software_Center-ggwcjffoisuknifuamzcmgnpypni/Build/Products/Debug/Managed Software Center.app/Contents/Resources/MunkiItems.py", line 341, in getIcon
    icon_path = os.path.join(msulib.html_dir(), name + '.png')
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/posixpath.py", line 70, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 6: ordinal 
not in range(128)
2014-03-05 11:47:30.920 Managed Software Center[4809:303] <type 
'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xc2 in 
position 6: ordinal not in range(128)

Code here:

https://code.google.com/p/munki/source/browse/code/Managed%20Software%20Center/M
anaged%20Software%20Center/MunkiItems.py?name=Munki2#340

I can resolve this by changing:

                name = self[key]
to
                name = self[key].decode('utf-8')

Original issue reported on code.google.com by t...@synthist.net on 5 Mar 2014 at 7:49

GoogleCodeExporter commented 9 years ago
This change prevents the exception, but at a cost of not finding a file with 
the expected name!

Original comment by gregnea...@mac.com on 5 Mar 2014 at 10:52

GoogleCodeExporter commented 9 years ago
Accepted the proposed fix here: 
http://code.google.com/p/munki/source/detail?r=7726bca3234e

Not convinced this is actually the right fix, but the getIcon method will be 
radically changed when downloading icons from the Munki web server is 
supported, so no point in spending a bunch of time on this right now.

Original comment by gregnea...@mac.com on 22 Mar 2014 at 5:24