question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

--stats output can not be redirect

See original GitHub issue

the following command creates a blank file py heroprotocol.py --stats "Blackheart's Bay.StormReplay" > output.txt

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
WhatIsACorecommented, Jun 3, 2017

Here is the code block that controls the --stats flag in heroprotocol.py:

    # Print stats
    if args.stats:
        logger.log_stats(sys.stderr)

and here is the code for log_stats:

    def log_stats(self, output):
        for name, stat in sorted(self._event_stats.iteritems(), key=lambda x: x[1][1]):
            print >> output, '"%s", %d, %d,' % (name, stat[0], stat[1] / 8)

In short, when that argument is passed, a coded-in exception is thrown and nothing happens.

Compare this with the working code for the trackerevents flag, which actually reads the replay file and decodes the contents:

    # Print tracker events
    if args.trackerevents:
        if hasattr(protocol, 'decode_replay_tracker_events'):
            contents = archive.read_file('replay.tracker.events')
            for event in protocol.decode_replay_tracker_events(contents):
                logger.log(sys.stdout, event)

and you can see why this issue exists.

heroprotocol.py

0reactions
VashSancommented, Aug 21, 2017

I found out what “stats” actually does. And it works actually fine, however in another way you might think

Please Blizz: add this to the documentation! Without investigating the code you will never guess what happens here.

Explanation It works only together with one of the event parsing arguments. Test it like this: heroprotocol --trackerevents --stats "xxx.StormReplay"

It will then print (to the error stream as observed). Here a shortened example:

'NNet.Replay.Tracker.SUnitRevivedEvent':	[29, 5208]	
'NNet.Replay.Tracker.SUnitDiedEvent':	[2808, 834968]	
'NNet.Replay.Tracker.SPlayerSetupEvent':	[10, 1920]	
'NNet.Replay.Tracker.SScoreResultEvent':	[1, 140656]

That means it is not at all about game stats as displayed in the final screen. Its more about some internal stats of the event parser. I believe it is the number of events and the time it took to process, thats just a guess though.

Why is it printed to the error stream? Because it is no content of the actual replay, but generated values which can change (depending on heroprotocol version, in cas of fixes) and are for debugging or optimizing purpose maybe (check if the events processed match the real events in the game).

So you can still process the original output of the standard stream. And if really wanted you may get stats from error stream. No big deal. And for most of us pretty useless?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Perf output cannot be redirected to file - Stack Overflow
I have tried different combinations of commands, such as: perf stat -o hhe.txt -e minor-faults,major-faults,cs -p 14615; perf stat -- ...
Read more >
How to redirect shell command output | Enable Sysadmin
Learn how to process the output of shell commands within a script and send it to files, devices, or other commands or scripts....
Read more >
re: r(601) "server says file temporarily redirected to [URL]" - st
I would like to download a file from the web with Stata's -copy- command. The server that provides the data uses redirection.
Read more >
Q: problem with redirection and google analytics
I use http://my.statcounter.com/register.php for statistics - I embed the code into my iWeb site on my iDisk after I publish. (This is important ......
Read more >
Identify if output goes to the terminal or is being redirected, in ...
We want to redirect the stdout , identified with the file descriptor 1 . If we don't specify the file descriptor on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found