Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble when Parsing Editor Replays #103

Open
aaliyah-art opened this issue Nov 21, 2019 · 14 comments · Fixed by #104
Open

Trouble when Parsing Editor Replays #103

aaliyah-art opened this issue Nov 21, 2019 · 14 comments · Fixed by #104
Labels

Comments

@aaliyah-art
Copy link

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

@cclauss
Copy link
Collaborator

cclauss commented Nov 21, 2019

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

@aaliyah-art
Copy link
Author

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
Copy link
Contributor

Talv commented Nov 24, 2019

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.

cclauss added a commit to cclauss/sc2reader that referenced this issue Nov 24, 2019
@StoicLoofah
Copy link
Collaborator

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

@aaliyah-art
Copy link
Author

It works, thank you sc2reader github community

@Talv
Copy link
Contributor

Talv commented Nov 26, 2019

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
Copy link
Collaborator

cclauss commented Nov 26, 2019

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
Copy link
Author

aaliyah-art commented Nov 26, 2019

thank you Talvert, that patch worked for me

@cclauss
Copy link
Collaborator

cclauss commented Nov 26, 2019

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

Really!?!

@aaliyah-art
Copy link
Author

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

Really!?!

what does this mean? what should it say

@cclauss
Copy link
Collaborator

cclauss commented Nov 26, 2019

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 added a commit to Talv/sc2reader that referenced this issue Nov 27, 2019
@Talv
Copy link
Contributor

Talv commented Nov 27, 2019

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

@StoicLoofah StoicLoofah reopened this Nov 28, 2019
@StoicLoofah
Copy link
Collaborator

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
Copy link
Collaborator

cclauss commented Nov 28, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants