sc2reader icon indicating copy to clipboard operation
sc2reader copied to clipboard

Trouble when Parsing Editor Replays

Open aaliyah-art opened this issue 5 years ago • 14 comments

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

aaliyah-art avatar Nov 21 '19 04:11 aaliyah-art

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

cclauss avatar Nov 21 '19 14:11 cclauss

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

aaliyah-art avatar Nov 24 '19 10:11 aaliyah-art

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.

Talv avatar Nov 24 '19 13:11 Talv

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

StoicLoofah avatar Nov 24 '19 20:11 StoicLoofah

It works, thank you sc2reader github community

aaliyah-art avatar Nov 25 '19 05:11 aaliyah-art

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

Talv avatar Nov 26 '19 00:11 Talv

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.

cclauss avatar Nov 26 '19 05:11 cclauss

thank you Talvert, that patch worked for me

aaliyah-art avatar Nov 26 '19 06:11 aaliyah-art

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

Really!?!

cclauss avatar Nov 26 '19 06:11 cclauss

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

Really!?!

what does this mean? what should it say

aaliyah-art avatar Nov 26 '19 13:11 aaliyah-art

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

cclauss avatar Nov 26 '19 13:11 cclauss

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

Talv avatar Nov 27 '19 11:11 Talv

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?

StoicLoofah avatar Nov 28 '19 07:11 StoicLoofah

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.

cclauss avatar Nov 28 '19 07:11 cclauss