remove file manager setting and use xdg-open, use os.startfile in windows, remove initial_upload, fix ratio
This commit is contained in:
parent
3befc2e084
commit
7e5179d0de
File diff suppressed because it is too large
Load Diff
|
@ -185,17 +185,16 @@ def fetch_url(url):
|
|||
|
||||
return None
|
||||
|
||||
def exec_command(executable, *parameters):
|
||||
def exec_command(executable=None, *parameters):
|
||||
import os
|
||||
command = [executable]
|
||||
command.extend(parameters)
|
||||
if windows_check():
|
||||
try:
|
||||
from subprocess import Popen
|
||||
Popen(command)
|
||||
os.startfile(parameters)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
command = [executable]
|
||||
command.extend(parameters)
|
||||
try:
|
||||
os.WEXITSTATUS(os.system(command[0] + " \"%s\"" %command[1]))
|
||||
except OSError:
|
||||
|
|
12
src/core.py
12
src/core.py
|
@ -165,7 +165,6 @@ class torrent_info:
|
|||
self.compact = compact
|
||||
self.user_paused = user_paused
|
||||
self.uploaded_memory = 0
|
||||
self.initial_uploaded_memory = 0
|
||||
self.upload_rate_limit = 0
|
||||
self.download_rate_limit = 0
|
||||
self.webseed_urls = []
|
||||
|
@ -358,8 +357,12 @@ class Manager:
|
|||
|
||||
def pickle_state(self):
|
||||
print "save uploaded memory"
|
||||
for torrent in self.state.torrents:
|
||||
uid = self.state.torrents[torrent]
|
||||
state = persistent_state()
|
||||
state.torrents = dict(self.state.torrents.iteritems())
|
||||
state.queue = self.state.queue[:]
|
||||
|
||||
for torrent in state.torrents:
|
||||
uid = state.torrents[torrent]
|
||||
try:
|
||||
torrent.uploaded_memory = self.unique_IDs[uid].uploaded_memory +\
|
||||
self.get_core_torrent_state(uid, False)['total_upload']
|
||||
|
@ -371,11 +374,10 @@ class Manager:
|
|||
if not os.path.exists(self.base_dir):
|
||||
os.makedirs(self.base_dir)
|
||||
output = open(os.path.join(self.base_dir, STATE_FILENAME), 'wb')
|
||||
pickle.dump(self.state, output)
|
||||
pickle.dump(state, output)
|
||||
output.close()
|
||||
|
||||
# Preference management functions
|
||||
|
||||
def get_config(self):
|
||||
# This returns the preference object
|
||||
return self.config
|
||||
|
|
|
@ -50,9 +50,6 @@ class PreferencesDlg:
|
|||
self.glade.signal_autoconnect({
|
||||
'toggle_ui': self.toggle_ui,
|
||||
'on_btn_testport_clicked': self.TestPort,
|
||||
'on_combo_file_manager_entry_focus_in_event': self.on_combo_file_manager_entry_focus_in_event,
|
||||
'on_txt_open_folder_location_focus_in_event': self.on_txt_open_folder_location_focus_in_event,
|
||||
'on_radio_open_folder_custom_focus_in_event': self.on_radio_open_folder_custom_focus_in_event
|
||||
})
|
||||
|
||||
self.preferences = preferences
|
||||
|
@ -77,15 +74,6 @@ class PreferencesDlg:
|
|||
def show(self, interface, window):
|
||||
# Load settings into dialog
|
||||
try:
|
||||
self.glade.get_widget("combo_file_manager").set_active(self.preferences.get("file_manager"))
|
||||
self.glade.get_widget("txt_open_folder_location").set_text(self.preferences.get("open_folder_location"))
|
||||
self.glade.get_widget("radio_open_folder_stock").set_active(self.preferences.get("open_folder_stock"))
|
||||
self.glade.get_widget("radio_open_folder_custom").set_active(not self.preferences.get("open_folder_stock"))
|
||||
if common.windows_check():
|
||||
self.glade.get_widget("combo_file_manager").set_sensitive(False)
|
||||
self.glade.get_widget("txt_open_folder_location").set_sensitive(False)
|
||||
self.glade.get_widget("radio_open_folder_stock").set_sensitive(False)
|
||||
self.glade.get_widget("radio_open_folder_custom").set_sensitive(False)
|
||||
self.glade.get_widget("combo_encin").set_active(self.preferences.get("encin_state"))
|
||||
self.glade.get_widget("combo_encout").set_active(self.preferences.get("encout_state"))
|
||||
self.glade.get_widget("combo_enclevel").set_active(self.preferences.get("enclevel_type"))
|
||||
|
@ -208,9 +196,6 @@ class PreferencesDlg:
|
|||
def ok_clicked(self, source, interface):
|
||||
self.dialog.hide()
|
||||
import sha
|
||||
self.preferences.set("file_manager", self.glade.get_widget("combo_file_manager").get_active())
|
||||
self.preferences.set("open_folder_stock", self.glade.get_widget("radio_open_folder_stock").get_active())
|
||||
self.preferences.set("open_folder_location", self.glade.get_widget("txt_open_folder_location").get_text())
|
||||
self.preferences.set("encin_state", self.glade.get_widget("combo_encin").get_active())
|
||||
self.preferences.set("encout_state", self.glade.get_widget("combo_encout").get_active())
|
||||
self.preferences.set("enclevel_type", self.glade.get_widget("combo_enclevel").get_active())
|
||||
|
@ -395,15 +380,6 @@ class PreferencesDlg:
|
|||
self.glade.get_widget('spin_port_min').set_sensitive(True)
|
||||
self.glade.get_widget('spin_port_max').set_sensitive(True)
|
||||
|
||||
def on_combo_file_manager_entry_focus_in_event(self, widget, event):
|
||||
self.glade.get_widget("radio_open_folder_stock").set_active(True)
|
||||
|
||||
def on_txt_open_folder_location_focus_in_event(self, widget, event):
|
||||
self.glade.get_widget("radio_open_folder_custom").set_active(True)
|
||||
|
||||
def on_radio_open_folder_custom_focus_in_event(self, widget, event):
|
||||
self.glade.get_widget("txt_open_folder_location").grab_focus()
|
||||
|
||||
class MergeDlg:
|
||||
def __init__(self):
|
||||
self.glade = gtk.glade.XML(common.get_glade_file("merge_dialog.glade"),
|
||||
|
|
|
@ -159,9 +159,6 @@ class DelugeGTK:
|
|||
for torrent in self.manager.get_queue():
|
||||
unique_ID = self.manager.get_torrent_unique_id(torrent)
|
||||
try:
|
||||
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
|
||||
if self.manager.unique_IDs[unique_ID].trackers_changed:
|
||||
self.manager.replace_trackers(unique_ID, \
|
||||
self.manager.unique_IDs[unique_ID].trackers)
|
||||
|
@ -732,22 +729,6 @@ window, please enter your password"))
|
|||
self.open_folder(view_column)
|
||||
|
||||
def open_folder(self, widget, uids=None):
|
||||
if not common.windows_check():
|
||||
if self.config.get("open_folder_stock"):
|
||||
if self.config.get("file_manager") == common.FileManager.xdg:
|
||||
file_manager = "xdg-open"
|
||||
elif self.config.get("file_manager") == common.FileManager.\
|
||||
konqueror:
|
||||
file_manager = "konqueror"
|
||||
elif self.config.get("file_manager") == common.FileManager.nautilus:
|
||||
file_manager = "nautilus"
|
||||
elif self.config.get("file_manager") == common.FileManager.thunar:
|
||||
file_manager = "thunar"
|
||||
else:
|
||||
file_manager = self.config.get("open_folder_location")
|
||||
else:
|
||||
file_manager = "explorer.exe"
|
||||
|
||||
if not uids:
|
||||
unique_ids = self.get_selected_torrent_rows()
|
||||
else:
|
||||
|
@ -756,7 +737,12 @@ window, please enter your password"))
|
|||
try:
|
||||
for uid in unique_ids:
|
||||
torrent_path = self.manager.get_torrent_path(uid)
|
||||
if not common.windows_check():
|
||||
file_manager = "xdg-open"
|
||||
common.exec_command(file_manager, torrent_path)
|
||||
else:
|
||||
common.exec_command(executable=None, parameters=torrent_path)
|
||||
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
@ -806,7 +792,7 @@ window, please enter your password"))
|
|||
self.update()
|
||||
self.manager.prioritize_files(unique_ID, save_info[5], update_files_removed=False)
|
||||
if save_info[4]:
|
||||
self.manager.unique_IDs[unique_ID].initial_uploaded_memory = \
|
||||
self.manager.unique_IDs[unique_ID].uploaded_memory = \
|
||||
save_info[4]
|
||||
self.manager.pickle_state()
|
||||
if save_info[6]:
|
||||
|
|
Loading…
Reference in New Issue