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

2019-09-03 Thread Hongyi Zhao
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: 
http://pycurl.io/docs/latest/callbacks.html#xferinfofunction


## 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)
c.perform()



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

pycurl.ABORTED_BY_CALLBACK
pycurl.OPERTATION_TIMEOUT

How to do it?


-- 
https://mail.python.org/mailman/listinfo/python-list


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

2019-09-02 Thread Cameron Simpson

On 01Sep2019 04:13, Hongyi Zhao  wrote:

I want to append some log of pycurl's downloading info to file, and I
only want to reserve the last appended line when write.  How to do this?


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


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


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

2019-08-31 Thread Hongyi Zhao
Hi:

I want to append some log of pycurl's downloading info to file, and I 
only want to reserve the last appended line when write.  How to do this?
-- 
https://mail.python.org/mailman/listinfo/python-list