jdiazbb / rfxcmd

Automatically exported from code.google.com/p/rfxcmd
1 stars 0 forks source link

Print to file #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Currently, the script prints to stdout.
But redirecting output to a file produces empty output in file.

eg. rfxcmd -c -d /dev/ttyUSBx > /tmp/rfxcmd.csv
then, wait a while then Ctrl-C to exit rfxcmd.
the /tmp/rfxcmd.csv is a zero size file (even if frames have been received).

This is due to python buffered output.
To cope with this, buffer have to be flushed before exitting.

In shutdown() function, add sys.stdout.flush() call to force flushing.

def shutdown():
    # clean up PID file after us
    logdebug("Shutdown")
    if cmdarg.createpid:
        logdebug("Removing PID file " + str(config.pidfile))
        os.remove(config.pidfile)

    logdebug("Exit 0")
        sys.stdout.flush() <<<<<<<<<<<<<<<<<< code to add
    os._exit(0)

Original issue reported on code.google.com by skim...@gmail.com on 17 Jan 2013 at 10:53

GoogleCodeExporter commented 8 years ago
Thanks for the input, I will fix this.

Original comment by sebastia...@gmail.com on 18 Jan 2013 at 4:02

GoogleCodeExporter commented 8 years ago
Fixed in v0.23 and the v0.3 Alpha branch

Original comment by sebastia...@gmail.com on 21 Jan 2013 at 6:43

GoogleCodeExporter commented 8 years ago
version 0.23 is now released.

Original comment by sebastia...@gmail.com on 9 Feb 2013 at 3:21