ggtracker/sc2reader

Trouble when Parsing Editor Replays

aaliyah-art opened this issue · 14 comments

Under Documents > Starcraft II > Replays, I am unable to parse replays

What error messages do you get? Which replays are you trying to parse?

Navigating to : PC>Documents >StarCraft II > Replays> Multiplayer , you will find your replays of you playing a game offline (like from the editor).

I get an error for KeyError: 'Game Speed'

`Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Aaliyah\Desktop\Replay Scan>Parser.py > output.txt
Traceback (most recent call last):
File "C:\Users\Aaliyah\Desktop\Replay Scan\Parser.py", line 2, in
replay = sc2reader.load_replay('sest.SC2Replay')
File "C:\Users\Aaliyah\AppData\Local\Programs\Python\Python38-32\lib\site-packag
es\sc2reader\factories\sc2factory.py", line 85, in load_replay
return self.load(Replay, source, options, **new_options)
File "C:\Users\Aaliyah\AppData\Local\Programs\Python\Python38-32\lib\site-packag
es\sc2reader\factories\sc2factory.py", line 143, in load
return self._load(cls, resource, filename=filename, options=options)
File "C:\Users\Aaliyah\AppData\Local\Programs\Python\Python38-32\lib\site-packag
es\sc2reader\factories\sc2factory.py", line 152, in _load
obj = cls(resource, filename=filename, factory=self, **options)
File "C:\Users\Aaliyah\AppData\Local\Programs\Python\Python38-32\lib\site-packag
es\sc2reader\resources.py", line 302, in init
self.load_all_details()
File "C:\Users\Aaliyah\AppData\Local\Programs\Python\Python38-32\lib\site-packag
es\sc2reader\resources.py", line 444, in load_all_details
self.load_attribute_events()
File "C:\Users\Aaliyah\AppData\Local\Programs\Python\Python38-32\lib\site-packag
es\sc2reader\resources.py", line 374, in load_attribute_events
self.speed = self.attributes[16]["Game Speed"]
KeyError: 'Game Speed'

C:\Users\Aaliyah\Desktop\Replay Scan>`

I'm not sure why anyone would want to Parse an editor replay, but I just thought I'd cash in on the bug bounty (gimme gimme) since it's a bug. Let me know if you have any more questions

Talv commented

I just thought I'd cash in on the bug bounty (gimme gimme) since it's a bug

Excuse me, what?

I'm not sure why anyone would want to Parse an editor replay

That's the exact reason why it doesn't work - no one needed that.
Replays from offline games don't have attributes section from which the library is trying to determine the game speed. And that's what the error refers to.

There's also more than that. This commit Dentosal@e554355 partially solves (or rather works around) these issues.

@aaliyah-art can you verify if #104 fixes your issue? I will merge if so

It works, thank you sc2reader github community

Talv commented

No, it doesn't... I doubt OP even tested the patch. Because it just addressed one of the problems. I don't need this functionality myself, but for clarification: reported issue hasn't been solved.

====================================================================== FAILURES ======================================================================
___________________________________________________________ TestReplays.test_editor_replay ___________________________________________________________

self = <test_replays.TestReplays testMethod=test_editor_replay>

    def test_editor_replay(self):
        for replayfilename in ["test_replays/Acropolis LE (2).SC2Replay"]:
            factory = sc2reader.factories.SC2Factory()
>           replay = factory.load_replay(replayfilename, load_level=3)

test_replays/test_replays.py:707:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sc2reader/factories/sc2factory.py:85: in load_replay
    return self.load(Replay, source, options, **new_options)
sc2reader/factories/sc2factory.py:143: in load
    return self._load(cls, resource, filename=filename, options=options)
sc2reader/factories/sc2factory.py:152: in _load
    obj = cls(resource, filename=filename, factory=self, **options)
sc2reader/resources.py:302: in __init__
    self.load_all_details()
sc2reader/resources.py:444: in load_all_details
    self.load_details()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <sc2reader.resources.Replay object at 0x7f9756ad0640>

    def load_details(self):
        if "replay.details" in self.raw_data:
            details = self.raw_data["replay.details"]
        elif "replay.details.backup" in self.raw_data:
            details = self.raw_data["replay.details.backup"]
        else:
            return

        self.map_name = details["map_name"]
>       self.region = details["cache_handles"][0].server.lower()
E       IndexError: list index out of range

sc2reader/resources.py:389: IndexError

If anyone actually needs it working, see my previous comment. I've also attached the replay.

Acropolis LE (2).SC2Replay.zip

Nice catch @Talv Thanks. Is there any way that we could add the reading of this file to our automated tests at https://github.com/ggtracker/sc2reader/blob/upstream/.circleci/config.yml ?

@StoicLoofah Please reopen this issue.

thank you Talvert, that patch worked for me

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

Really!?!

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

Really!?!

what does this mean? what should it say

Maybe like Windows 10 or even Windows 7. Are you running Windows Vista?
https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions#Personal_computer_versions

Talv commented

Is there any way that we could add the reading of this file to our automated tests at https://github.com/ggtracker/sc2reader/blob/upstream/.circleci/config.yml ?

Sure. Assuming you mean just test case? Should I submit it as PR?
For now it can be cherry-picked from Talv@e6c5889

Issue re-opened.

Makes sense to add the test case but only if we actually have a fix for it. And that test and fix should be in the same PR. Is someone working on that?

If someone can author a Work In Progress PR that runs a failing test then I can create a second PR that fixes the failing test.