ratio fix
This commit is contained in:
parent
79e9e1de53
commit
7d680bdd3a
11
src/core.py
11
src/core.py
|
@ -162,6 +162,7 @@ class torrent_info:
|
||||||
self.compact = compact
|
self.compact = compact
|
||||||
self.user_paused = False
|
self.user_paused = False
|
||||||
self.uploaded_memory = 0
|
self.uploaded_memory = 0
|
||||||
|
self.initial_uploaded_memory = 0
|
||||||
self.upload_rate_limit = 0
|
self.upload_rate_limit = 0
|
||||||
self.download_rate_limit = 0
|
self.download_rate_limit = 0
|
||||||
self.webseed_urls = []
|
self.webseed_urls = []
|
||||||
|
@ -278,9 +279,6 @@ class Manager:
|
||||||
self.state = persistent_state()
|
self.state = persistent_state()
|
||||||
|
|
||||||
def quit(self):
|
def quit(self):
|
||||||
# Analyze data needed for pickling, etc.
|
|
||||||
self.pre_quitting()
|
|
||||||
|
|
||||||
# Pickle the prefs
|
# Pickle the prefs
|
||||||
print "Saving prefs..."
|
print "Saving prefs..."
|
||||||
self.config.save()
|
self.config.save()
|
||||||
|
@ -313,11 +311,12 @@ class Manager:
|
||||||
pickle.dump(self.state, output)
|
pickle.dump(self.state, output)
|
||||||
output.close()
|
output.close()
|
||||||
|
|
||||||
def pre_quitting(self):
|
def save_upmem(self):
|
||||||
# Save the uploaded data from this session to the existing upload memory
|
# Save the uploaded data from this session to the existing upload memory
|
||||||
for unique_ID in self.unique_IDs.keys():
|
for unique_ID in self.unique_IDs.keys():
|
||||||
# self.get_core_torrent_state purposefully not cached.
|
# self.get_core_torrent_state purposefully not cached.
|
||||||
self.unique_IDs[unique_ID].uploaded_memory += \
|
self.unique_IDs[unique_ID].uploaded_memory = \
|
||||||
|
self.unique_IDs[unique_ID].initial_uploaded_memory + \
|
||||||
self.get_core_torrent_state(unique_ID, False)['total_upload']
|
self.get_core_torrent_state(unique_ID, False)['total_upload']
|
||||||
|
|
||||||
# Preference management functions
|
# Preference management functions
|
||||||
|
@ -982,7 +981,7 @@ class Manager:
|
||||||
# Calculations
|
# Calculations
|
||||||
|
|
||||||
def calc_ratio(self, unique_ID, torrent_state):
|
def calc_ratio(self, unique_ID, torrent_state):
|
||||||
up = float((torrent_state['total_payload_upload'] / 1024) + (self.unique_IDs[unique_ID].uploaded_memory / 1024))
|
up = float(self.unique_IDs[unique_ID].uploaded_memory / 1024)
|
||||||
down = float(torrent_state["total_done"] / 1024)
|
down = float(torrent_state["total_done"] / 1024)
|
||||||
try:
|
try:
|
||||||
ret = up/down
|
ret = up/down
|
||||||
|
|
|
@ -161,6 +161,7 @@ class DelugeGTK:
|
||||||
|
|
||||||
self.dht_timer = 0
|
self.dht_timer = 0
|
||||||
self.dht_skip = False
|
self.dht_skip = False
|
||||||
|
self.memory_timer = 0
|
||||||
|
|
||||||
def connect_signals(self):
|
def connect_signals(self):
|
||||||
self.wtree.signal_autoconnect({
|
self.wtree.signal_autoconnect({
|
||||||
|
@ -962,6 +963,9 @@ window, please enter your password"))
|
||||||
if self.manager.unique_IDs[unique_id].trackers:
|
if self.manager.unique_IDs[unique_id].trackers:
|
||||||
self.manager.replace_trackers(unique_id, \
|
self.manager.replace_trackers(unique_id, \
|
||||||
self.manager.unique_IDs[unique_id].trackers)
|
self.manager.unique_IDs[unique_id].trackers)
|
||||||
|
if self.manager.unique_IDs[unique_id].uploaded_memory:
|
||||||
|
self.manager.unique_IDs[unique_id].initial_uploaded_memory \
|
||||||
|
= self.manager.unique_IDs[unique_id].uploaded_memory
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -981,7 +985,10 @@ window, please enter your password"))
|
||||||
|
|
||||||
self.update_interface = self.window.get_property("visible") and not \
|
self.update_interface = self.window.get_property("visible") and not \
|
||||||
self.is_minimized
|
self.is_minimized
|
||||||
|
self.memory_timer += 1
|
||||||
|
if (self.memory_timer == 60):
|
||||||
|
self.manager.save_upmem()
|
||||||
|
self.memory_timer = 0
|
||||||
# Handle the events
|
# Handle the events
|
||||||
self.manager.handle_events()
|
self.manager.handle_events()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue