ImportError: No module named decoders
Cinetik opened this issue · 7 comments
Since last big commit moving protocol files into versions, I can't use it programmatically anymore.
I tried using the pip module as well.
I tried sc2_cli.py and it works no problem but however when I do the basic example in the tutorial documentation
import mpyq
# Using mpyq, load the replay file.
archive = mpyq.MPQArchive('test.SC2Replay')
contents = archive.header['user_data_header']['content']
# Now parse the header information.
from s2protocol import versions
header = versions.latest().decode_replay_header(contents)
Full trace
$ python tester.py
Traceback (most recent call last):
File "tester.py", line 15, in <module>
header = versions.latest().decode_replay_header(contents)
File "/Users/Florian/gitworkspace/s2protocol/s2protocol/versions/__init__.py", line 62, in latest
return _import_protocol(base_path, module_name)
File "/Users/Florian/gitworkspace/s2protocol/s2protocol/versions/__init__.py", line 27, in _import_protocol
return imp.load_module(protocol_module_name, fp, pathname, description)
File "/Users/Florian/gitworkspace/s2protocol/s2protocol/versions/protocol58400.py", line 21, in <module>
from decoders import *
ImportError: No module named decoders
I tried putting from s2protocol.decoders import *
instead of from decoders import *
and I didn't get the error so probably something you'd want to modify in the autogeneration
Yeah this is a known issue that I'm very close to sorting out. It has to do with how the autogen modules import the core decoders. I tried putting work arounds in the python loading code but I haven't gotten that to work satisfactorily. I've redone the auto-code gen (versions/protocolxxxxx.py) which should be rolling out over the next day or two.
Hey so I'm testing on a new branch and this code (modified the generated code) and it worked for me
In [1]: import mpyq
In [2]: archive = mpyq.MPQArchive('ggtracker_6951344.SC2Replay')
In [3]: contents = archive.header['user_data_header']['content']
In [4]: from s2protocol import versions
In [5]: header = versions.latest().decode_replay_header(contents)
In [6]: header
Out[6]:
{'m_dataBuildNum': 49716,
'm_elapsedGameLoops': 24171,
'm_ngdpRootKey': {'m_data': '!\xea-\n\x97\xa1\x9e\xe5\xa1u\x95q\xcf\xc9\x12\x84'},
'm_ngdpRootKeyIsDevData': False,
'm_replayCompatibilityHash': {'m_data': '\xdb3!91J"\xf5\xff\xd2\xed\x9a\xf9\xb9\xbf\xfe'},
'm_signature': 'StarCraft II replay\x1b11',
'm_type': 2,
'm_useScaledTime': True,
'm_version': {'m_baseBuild': 49716,
'm_build': 49716,
'm_flags': 1,
'm_major': 3,
'm_minor': 10,
'm_revision': 0}}
Worked
Any ETA of that branch being released ?