This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Problem with Kross scripting and file.flush() file.close()

Tags: None
(comma "," separated)
malibu
Registered Member
Posts
1
Karma
0
Hi there. I'm trying to write a Kross script that will simply take regular expressions and match them to a torrent when it closes, and move to a destination all defined in a yaml file. I want to have a separate log file to monitor the activity in this script. Everything seems to be working, but my log file does not seem to be getting contents until I close Ktorrent. This is what I have done:

Code: Select all
import KTorrent
import Kross

def torrentEnded(ih):
    f = open("logfile","a")
    (do stuff)
    f.write("I am here")
    (do stuff)
    f.write("I am done")
    f.flush()
    f.close()

KTorrent.connect("finished(const QString &)",torrentEnded)


Can anyone tell me why I don't see line by line logging and how I fix it? Thanks.
George
Moderator
Posts
5421
Karma
1
Flush ought to write everything pending to disk. Maybe you can force it by calling del on the file object, that should force python to clean it up and write everything to disk.


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Google [Bot], Sogou [Bot]