ggtracker / sc2reader

Extracts gameplay information from Starcraft II replay files
http://pypi.python.org/pypi/sc2reader
MIT License
146 stars 143 forks source link

Trouble when Parsing Editor Replays #103

Open aaliyah-art opened 4 years ago

aaliyah-art commented 4 years ago

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

cclauss commented 4 years ago

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

aaliyah-art commented 4 years ago

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 4 years ago

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 https://github.com/Dentosal/sc2reader/commit/e5543558577afd1fdd05c5a89197910cbfe5fc75 partially solves (or rather works around) these issues.

StoicLoofah commented 4 years ago

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

aaliyah-art commented 4 years ago

It works, thank you sc2reader github community

Talv commented 4 years ago

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

cclauss commented 4 years ago

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.

aaliyah-art commented 4 years ago

thank you Talvert, that patch worked for me

cclauss commented 4 years ago

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

Really!?!

aaliyah-art commented 4 years ago

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

Really!?!

what does this mean? what should it say

cclauss commented 4 years ago

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 4 years ago

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 https://github.com/Talv/sc2reader/commit/e6c58895327120bfc19010bbfae62b11d7051e9d

StoicLoofah commented 4 years ago

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?

cclauss commented 4 years ago

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.