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

tor.totalSize() returns negative number

Tags: None
(comma "," separated)
morr
Registered Member
Posts
3
Karma
0
Hi,
here is my script code:
Code: Select all
#!/usr/bin/env kross
# -*- coding: utf-8 -*-
import KTorrent
import KTScriptingPlugin
import Kross

f = open("/tmp/krottent.script", "w")
tors = KTorrent.torrents()

for t in tors:
   tor = KTorrent.torrent(t)
   if tor.totalSize() != tor.bytesDownloaded():
      f.write("%s\t%u\n" % (tor.name(), tor.totalSize()))
f.close()

This code works but for some torrents it prints negative totalSize. Same situation happens with tor.bytesDownloaded().
Am i doing something wrong or it is a bug?
George
Moderator
Posts
5421
Karma
1
It's a bug in krosspython which appears to be handling 64bit integers badly when it passes them to python. It seems to threat them as 32bit integers.
morr
Registered Member
Posts
3
Karma
0
Ah it appears there is no way to retrieve torrent progress information in script now :(

Any chances that you will fix plugin api in future releases? For example to change returning value from integer to string in these functions, or to add extra functions which returns torrent progress in megabytes, or function which shows percentage of download, which is done.
George
Moderator
Posts
5421
Karma
1
morr wrote:Ah it appears there is no way to retrieve torrent progress information in script now :(

Any chances that you will fix plugin api in future releases? For example to change returning value from integer to string in these functions, or to add extra functions which returns torrent progress in megabytes, or function which shows percentage of download, which is done.


There is a very big chance this is going to happen, with this one included, I have reported 3 krosspython bugs, the first 2 of them haven't been fixed yet, and they have been reported quite some time ago.

In fact one of them (a memory leak), has forced me to change the API to avoid the memory leak.
morr
Registered Member
Posts
3
Karma
0
> In fact one of them (a memory leak), has forced me to change the API to avoid the memory leak.
Is memmory leak already fixed in KTorrent 3.3.4? It's KTorrent version in Ubuntu 10.04 repository
Because this script eats all my memmory in minutes
Code: Select all
#!/usr/bin/env kross
# -*- coding: utf-8 -*-
import KTorrent
import KTScriptingPlugin
import Kross
import json

class ActiveTorrentsDump:
   def __init__(self):
      self.timer = KTScriptingPlugin.createTimer(True)
      self.timer.connect('timeout()', self.timerFired)

   def load(self):
      self.timer.start(50) # 50ms interval is for test purposes

   def timerFired(self):
      print 'timerFired'
      tors = KTorrent.torrents()
      data = []
      for t in tors:
         tor = KTorrent.torrent(t)
         if tor.totalSize() != tor.bytesDownloaded():
            data.append({'name': tor.name(), 'totalSize': tor.totalSize(), 'bytesDownloaded': tor.bytesDownloaded(), 'bytesUploaded': tor.bytesUploaded(), 'downloadSpeed': tor.downloadSpeed(), 'uploadSpeed': tor.uploadSpeed(), 'seedersConnected': tor.seedersConnected(), 'seedersTotal': tor.seedersTotal(), 'leechersConnected': tor.leechersConnected(), 'leechersTotal': tor.leechersTotal()})
      f = open("/tmp/ktorrent.torrents", "w")
      f.write(json.dumps(data))
      f.close()
      self.timer.start(50)

atd = ActiveTorrentsDump()
atd.load()

def configure():
   global atd

def unload():
   global atd
   del atd


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]