HearthSim / UnityPack

Python deserialization library for Unity3D Asset format
https://hearthsim.info/
MIT License
721 stars 152 forks source link

Issue when trying to extract cardxml0.unity3d #7

Closed anaik-zam closed 8 years ago

anaik-zam commented 8 years ago

No data is being passed to write_to_file function when obj.type is "TextAsset", resulting in txt files containing "w". After passing d.script I get a traceback:

Traceback (most recent call last):
  File "/tools/python-unitypack-0.3/bin/unityextract", line 126, in <module>
    main()
  File "/tools/python-unitypack-0.3/bin/unityextract", line 123, in main
    exit(app.run())
  File "/tools/python-unitypack-0.3/bin/unityextract", line 54, in run
    self.handle_asset(asset)
  File "/tools/python-unitypack-0.3/bin/unityextract", line 106, in handle_asset
    self.write_to_file(filename, d.script, mode)
  File "/tools/python-unitypack-0.3/bin/unityextract", line 69, in write_to_file
    written = f.write(contents)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 572-573: ordinal not in range(128)

I'm running this on ubuntu 16.04 and python 3.5.1 d.script.encode("utf-8") with mode="wb" seems to work

jleclanche commented 8 years ago

That's cardxml0.unity3d from Hearthstone? On ubuntu with python 3.5? I'm not getting that issue at all :/

Try the version from git master.

jleclanche commented 8 years ago
(hs) [18:39:18] adys@azura ~/.local/games/Hearthstone/Data/Win % unityextract --text cardxml0.unity3d
Written 1745002 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/plPL.txt'
Written 1732881 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/enUS.txt'
Written 1647645 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/jaJP.txt'
Written 1750750 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/ptBR.txt'
Written 1765836 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/deDE.txt'
Written 1606346 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/zhTW.txt'
Written 1735577 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/thTH.txt'
Written 1732881 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/enGB.txt'
Written 1772247 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/frFR.txt'
Written 1615480 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/zhCN.txt'
Written 1758836 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/esES.txt'
Written 1761145 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/ruRU.txt'
Written 1753776 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/itIT.txt'
Written 1761209 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/esMX.txt'
Written 1646973 bytes to '/home/adys/.local/share/wineprefixes/default/drive_c/Program Files (x86)/Hearthstone/Data/Win/koKR.txt'
anaik-zam commented 8 years ago

thanks for the quick reply. I tried the master but I still get the ascii error. cardxml0.unity3d is from Hearthstone build 5.0.0.12574 (Win) I'm running this in a docker container which runs a ubuntu 16.04 base image and has python 3.5.1. What os are you using?

jleclanche commented 8 years ago

Arch Linux. There's no reason it wouldnt work :/

I'd say make sure your system encoding is utf-8 but there's just about no way it wouldn't be on Linux.

jleclanche commented 8 years ago

Triple check that it is running on Python 3.5. /usr/bin/env python --version should say 3.5.1.

anaik-zam commented 8 years ago

sys.getdefaultencoding() is 'utf-8' and python version is 3.5.1 It is working now. I was executing python3.5 /tools/python-unitypack-master/bin/unityextract ... I had to do the following

  1. create symlink to python3.5 in /usr/bin ln -s /usr/bin/python3.5 /usr/bin/python
  2. add unityextract to the path export PATH=$PATH:/tools/python-unitypack-master/bin

thanks for looking into it.