[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Append some stuff into a file with only the last appended line reserved.

On Tue, 03 Sep 2019 08:29:31 +1000, Cameron Simpson wrote:

> Please describe this in more detail. Present a little pycurl output and
> then explain what portion of it should land in the log file.

See the following code from here: 

## Callback function invoked when download/upload has progress
def progress(download_t, download_d, upload_t, upload_d):
    print "Total to download", download_t
    print "Total downloaded", download_d
    print "Total to upload", upload_t
    print "Total uploaded", upload_d

c = pycurl.Curl()
c.setopt(c.URL, "http://slashdot.org/";)
c.setopt(c.NOPROGRESS, False)
c.setopt(c.XFERINFOFUNCTION, progress)

If I want to print these info ( or write them into log ) only when some 
specific events occur, say:


How to do it?