mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-07 00:48:41 +00:00
This commit is contained in:
parent
7d2b0a4e8c
commit
356009f5ee
4 changed files with 29 additions and 21 deletions
|
@ -337,7 +337,7 @@ static PyObject *torrent_init(PyObject *self, PyObject *args)
|
||||||
static PyObject *torrent_quit(PyObject *self, PyObject *args)
|
static PyObject *torrent_quit(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
printf("core: shutting down session...\r\n");
|
printf("core: shutting down session...\r\n");
|
||||||
delete M_ses; // SLOWPOKE because of waiting for the trackers before shutting down
|
delete M_ses; // 100% CPU...
|
||||||
printf("core: removing settings...\r\n");
|
printf("core: removing settings...\r\n");
|
||||||
delete M_settings;
|
delete M_settings;
|
||||||
printf("core: removing torrents...\r\n");
|
printf("core: removing torrents...\r\n");
|
||||||
|
|
|
@ -332,18 +332,13 @@ class manager:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# This is the EXTERNAL function, for the GUI. It returns the core_state + supp_state
|
# This is the EXTERNAL function, for the GUI. It returns the core_state + supp_state
|
||||||
def get_torrent_state(self, unique_ID, full=False):
|
def get_torrent_state(self, unique_ID):
|
||||||
ret = self.get_core_torrent_state(unique_ID, True).copy()
|
ret = self.get_core_torrent_state(unique_ID, True).copy()
|
||||||
|
|
||||||
# Add the flood-level things to the flood_core data
|
# Add the flood-level things to the flood_core data
|
||||||
if self.get_supp_torrent_state(unique_ID) is not None:
|
if self.get_supp_torrent_state(unique_ID) is not None:
|
||||||
ret.update(self.get_supp_torrent_state(unique_ID))
|
ret.update(self.get_supp_torrent_state(unique_ID))
|
||||||
|
|
||||||
# If asked, we calculate the time-costly information as well
|
|
||||||
if full:
|
|
||||||
ret['availability'] = self.calc_availability(unique_ID)
|
|
||||||
ret['swarm speed'] = self.calc_swarm_speed(unique_ID)
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def get_torrent_peer_info(self, unique_ID):
|
def get_torrent_peer_info(self, unique_ID):
|
||||||
|
@ -473,6 +468,32 @@ class manager:
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Advanced statistics
|
||||||
|
|
||||||
|
# Availability - how many complete copies are among our peers
|
||||||
|
def calc_availability(self, unique_ID):
|
||||||
|
peer_info = self.get_core_torrent_peer_info(unique_ID)
|
||||||
|
|
||||||
|
if len(peer_info) == 0:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
num_pieces = len(peer_info[0].pieces)
|
||||||
|
|
||||||
|
freqs = [0]*num_pieces
|
||||||
|
|
||||||
|
for peer in peer_info:
|
||||||
|
for piece in num_pieces:
|
||||||
|
freqs[piece] = freqs[piece] + peer['pieces'][piece]
|
||||||
|
|
||||||
|
minimum = min(freqs)
|
||||||
|
# frac = freqs.count(minimum + 1) # Does this mean something?
|
||||||
|
|
||||||
|
return minimum
|
||||||
|
|
||||||
|
# Swarm speed - try to guess the speed of the entire swarm
|
||||||
|
def calc_swarm_speed(self, unique_ID):
|
||||||
|
pass
|
||||||
|
|
||||||
# Miscellaneous minor functions
|
# Miscellaneous minor functions
|
||||||
|
|
||||||
def set_user_pause(self, unique_ID, new_value):
|
def set_user_pause(self, unique_ID, new_value):
|
||||||
|
@ -609,9 +630,3 @@ class manager:
|
||||||
ret = -1
|
ret = -1
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def calc_availability(self, unique_ID):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def calc_swarm_speed(self, unique_ID):
|
|
||||||
pass
|
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
import sys
|
import sys
|
||||||
command = sys.argv[1]
|
command = sys.argv[1]
|
||||||
|
|
||||||
assert(command in ['build', 'install'])
|
|
||||||
|
|
||||||
removals = ['-g', '-DNDEBUG', '-O2', '-Wstrict-prototypes']
|
removals = ['-g', '-DNDEBUG', '-O2', '-Wstrict-prototypes']
|
||||||
addition = "-DNDEBUG -O2" # Oddly, -O2 gives smaller .o's than -Os
|
addition = "-DNDEBUG -O2" # Oddly, -O2 gives smaller .o's than -Os
|
||||||
|
|
||||||
|
@ -36,7 +34,7 @@ print "====================================="
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
p = os.popen("python setup_naive.py --dry-run build")
|
p = os.popen("python setup_naive.py --dry-run " + command)
|
||||||
data = p.readlines()
|
data = p.readlines()
|
||||||
p.close()
|
p.close()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
echo ""
|
|
||||||
echo "Run!"
|
|
||||||
echo ""
|
|
||||||
#LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH python test.py
|
|
||||||
python test.py
|
|
Loading…
Add table
Add a link
Reference in a new issue