diff --git a/library/cpp/flood_core.cpp b/library/cpp/flood_core.cpp index 489235291..293a4b983 100755 --- a/library/cpp/flood_core.cpp +++ b/library/cpp/flood_core.cpp @@ -337,7 +337,7 @@ static PyObject *torrent_init(PyObject *self, PyObject *args) static PyObject *torrent_quit(PyObject *self, PyObject *args) { 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"); delete M_settings; printf("core: removing torrents...\r\n"); diff --git a/library/flood.py b/library/flood.py index 1eb0117c3..8b16013b2 100644 --- a/library/flood.py +++ b/library/flood.py @@ -332,18 +332,13 @@ class manager: return ret # 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() # Add the flood-level things to the flood_core data if self.get_supp_torrent_state(unique_ID) is not None: 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 def get_torrent_peer_info(self, unique_ID): @@ -473,6 +468,32 @@ class manager: except AttributeError: 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 def set_user_pause(self, unique_ID, new_value): @@ -609,9 +630,3 @@ class manager: ret = -1 return ret - - def calc_availability(self, unique_ID): - pass - - def calc_swarm_speed(self, unique_ID): - pass diff --git a/library/setup.py b/library/setup.py index 44ed92f3d..16cfb28e4 100644 --- a/library/setup.py +++ b/library/setup.py @@ -21,8 +21,6 @@ import sys command = sys.argv[1] -assert(command in ['build', 'install']) - removals = ['-g', '-DNDEBUG', '-O2', '-Wstrict-prototypes'] addition = "-DNDEBUG -O2" # Oddly, -O2 gives smaller .o's than -Os @@ -36,7 +34,7 @@ print "=====================================" 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() p.close() diff --git a/library/testit b/library/testit deleted file mode 100755 index dea5ec9d1..000000000 --- a/library/testit +++ /dev/null @@ -1,5 +0,0 @@ -echo "" -echo "Run!" -echo "" -#LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH python test.py -python test.py