Fix some accidental reverts
This commit is contained in:
parent
1cb42252b8
commit
e6135aa2a9
|
@ -17,9 +17,9 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# In addition, as a special exception, the copyright holders give
|
# In addition, as a special exception, the copyright holders give
|
||||||
# permission to link the code of portions of this program with the OpenSSL
|
# permission to link the code of portions of this program with the OpenSSL
|
||||||
|
|
|
@ -75,16 +75,17 @@ def decode_string(s, encoding="utf8"):
|
||||||
class TorrentInfo(object):
|
class TorrentInfo(object):
|
||||||
"""
|
"""
|
||||||
Collects information about a torrent file.
|
Collects information about a torrent file.
|
||||||
|
|
||||||
:param filename: The path to the torrent
|
:param filename: The path to the torrent
|
||||||
:type filename: string
|
:type filename: string
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
# Get the torrent data from the torrent file
|
# Get the torrent data from the torrent file
|
||||||
try:
|
try:
|
||||||
log.debug("Attempting to open %s.", filename)
|
log.debug("Attempting to open %s.", filename)
|
||||||
self.__m_metadata = bencode.bdecode(open(filename, "rb").read())
|
self.__m_filedata = open(filename, "rb").read()
|
||||||
|
self.__m_metadata = bencode.bdecode(self.__m_filedata)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.warning("Unable to open %s: %s", filename, e)
|
log.warning("Unable to open %s: %s", filename, e)
|
||||||
raise e
|
raise e
|
||||||
|
@ -163,7 +164,7 @@ class TorrentInfo(object):
|
||||||
def name(self):
|
def name(self):
|
||||||
"""
|
"""
|
||||||
The name of the torrent.
|
The name of the torrent.
|
||||||
|
|
||||||
:rtype: string
|
:rtype: string
|
||||||
"""
|
"""
|
||||||
return self.__m_name
|
return self.__m_name
|
||||||
|
@ -172,7 +173,7 @@ class TorrentInfo(object):
|
||||||
def info_hash(self):
|
def info_hash(self):
|
||||||
"""
|
"""
|
||||||
The torrents info_hash
|
The torrents info_hash
|
||||||
|
|
||||||
:rtype: string
|
:rtype: string
|
||||||
"""
|
"""
|
||||||
return self.__m_info_hash
|
return self.__m_info_hash
|
||||||
|
@ -181,7 +182,7 @@ class TorrentInfo(object):
|
||||||
def files(self):
|
def files(self):
|
||||||
"""
|
"""
|
||||||
A list of the files that the torrent contains.
|
A list of the files that the torrent contains.
|
||||||
|
|
||||||
:rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
return self.__m_files
|
return self.__m_files
|
||||||
|
@ -190,15 +191,15 @@ class TorrentInfo(object):
|
||||||
def files_tree(self):
|
def files_tree(self):
|
||||||
"""
|
"""
|
||||||
A dictionary based tree of the files.
|
A dictionary based tree of the files.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
{
|
{
|
||||||
"some_directory": {
|
"some_directory": {
|
||||||
"some_file": (index, size, download)
|
"some_file": (index, size, download)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:rtype: dictionary
|
:rtype: dictionary
|
||||||
"""
|
"""
|
||||||
return self.__m_files_tree
|
return self.__m_files_tree
|
||||||
|
@ -207,11 +208,21 @@ class TorrentInfo(object):
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
"""
|
"""
|
||||||
The torrents metadata.
|
The torrents metadata.
|
||||||
|
|
||||||
:rtype: dictionary
|
:rtype: dictionary
|
||||||
"""
|
"""
|
||||||
return self.__m_metadata
|
return self.__m_metadata
|
||||||
|
|
||||||
|
@property
|
||||||
|
def filedata(self):
|
||||||
|
"""
|
||||||
|
The torrents file data. This will be the bencoded dictionary read
|
||||||
|
from the torrent file.
|
||||||
|
|
||||||
|
:rtype: string
|
||||||
|
"""
|
||||||
|
return self.__m_filedata
|
||||||
|
|
||||||
class FileTree(object):
|
class FileTree(object):
|
||||||
"""
|
"""
|
||||||
Convert a list of paths in a file tree.
|
Convert a list of paths in a file tree.
|
||||||
|
@ -219,7 +230,7 @@ class FileTree(object):
|
||||||
:param paths: The paths to be converted.
|
:param paths: The paths to be converted.
|
||||||
:type paths: list
|
:type paths: list
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, paths):
|
def __init__(self, paths):
|
||||||
self.tree = {}
|
self.tree = {}
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ class AddTorrentDialog(component.Component):
|
||||||
new_row = self.torrent_liststore.append(
|
new_row = self.torrent_liststore.append(
|
||||||
[info.info_hash, info.name, filename])
|
[info.info_hash, info.name, filename])
|
||||||
self.files[info.info_hash] = info.files
|
self.files[info.info_hash] = info.files
|
||||||
self.infos[info.info_hash] = info.metadata
|
self.infos[info.info_hash] = info.filedata
|
||||||
self.listview_torrents.get_selection().select_iter(new_row)
|
self.listview_torrents.get_selection().select_iter(new_row)
|
||||||
|
|
||||||
self.set_default_options()
|
self.set_default_options()
|
||||||
|
@ -226,7 +226,11 @@ class AddTorrentDialog(component.Component):
|
||||||
new_row = None
|
new_row = None
|
||||||
|
|
||||||
for uri in uris:
|
for uri in uris:
|
||||||
info_hash = base64.b32decode(uri.split("&")[0][20:]).encode("hex")
|
s = uri.split("&")[0][20:]
|
||||||
|
if len(s) == 32:
|
||||||
|
info_hash = base64.b32decode(s).encode("hex")
|
||||||
|
elif len(s) == 40:
|
||||||
|
info_hash = s
|
||||||
if info_hash in self.infos:
|
if info_hash in self.infos:
|
||||||
log.debug("Torrent already in list!")
|
log.debug("Torrent already in list!")
|
||||||
continue
|
continue
|
||||||
|
@ -716,11 +720,6 @@ class AddTorrentDialog(component.Component):
|
||||||
if row is not None:
|
if row is not None:
|
||||||
self.save_torrent_options(row)
|
self.save_torrent_options(row)
|
||||||
|
|
||||||
torrent_filenames = []
|
|
||||||
torrent_magnets = []
|
|
||||||
torrent_magnet_options = []
|
|
||||||
torrent_options = []
|
|
||||||
|
|
||||||
row = self.torrent_liststore.get_iter_first()
|
row = self.torrent_liststore.get_iter_first()
|
||||||
while row != None:
|
while row != None:
|
||||||
torrent_id = self.torrent_liststore.get_value(row, 0)
|
torrent_id = self.torrent_liststore.get_value(row, 0)
|
||||||
|
@ -735,26 +734,16 @@ class AddTorrentDialog(component.Component):
|
||||||
options["file_priorities"] = file_priorities
|
options["file_priorities"] = file_priorities
|
||||||
|
|
||||||
if deluge.common.is_magnet(filename):
|
if deluge.common.is_magnet(filename):
|
||||||
torrent_magnets.append(filename)
|
|
||||||
del options["file_priorities"]
|
del options["file_priorities"]
|
||||||
torrent_magnet_options.append(options)
|
client.core.add_torrent_magnet(filename, options)
|
||||||
else:
|
else:
|
||||||
torrent_filenames.append(filename)
|
client.core.add_torrent_file(
|
||||||
torrent_options.append(options)
|
os.path.split(filename)[-1],
|
||||||
|
base64.encodestring(self.infos[torrent_id]),
|
||||||
|
options)
|
||||||
|
|
||||||
row = self.torrent_liststore.iter_next(row)
|
row = self.torrent_liststore.iter_next(row)
|
||||||
|
|
||||||
if torrent_filenames:
|
|
||||||
for i, f in enumerate(torrent_filenames):
|
|
||||||
client.core.add_torrent_file(
|
|
||||||
os.path.split(f)[-1],
|
|
||||||
base64.encodestring(open(f, "rb").read()),
|
|
||||||
torrent_options[i])
|
|
||||||
if torrent_magnets:
|
|
||||||
for i, m in enumerate(torrent_magnets):
|
|
||||||
client.core.add_torrent_magnet(m, torrent_magnet_options[i])
|
|
||||||
|
|
||||||
client.force_call(False)
|
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
def _on_button_apply_clicked(self, widget):
|
def _on_button_apply_clicked(self, widget):
|
||||||
|
|
|
@ -71,7 +71,9 @@ class IPCInterface(component.Component):
|
||||||
_args = []
|
_args = []
|
||||||
for arg in args:
|
for arg in args:
|
||||||
if arg.strip():
|
if arg.strip():
|
||||||
_args.append(os.path.abspath(arg))
|
if not deluge.common.is_magnet(arg) and not deluge.common.is_url(arg):
|
||||||
|
arg = os.path.abspath(arg)
|
||||||
|
_args.append(arg)
|
||||||
args = _args
|
args = _args
|
||||||
|
|
||||||
socket = os.path.join(deluge.configmanager.get_config_dir("ipc"), "deluge-gtk")
|
socket = os.path.join(deluge.configmanager.get_config_dir("ipc"), "deluge-gtk")
|
||||||
|
@ -117,7 +119,6 @@ class IPCInterface(component.Component):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error("Problem deleting lockfile or socket file!")
|
log.error("Problem deleting lockfile or socket file!")
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.factory = Factory()
|
self.factory = Factory()
|
||||||
self.factory.protocol = IPCProtocolServer
|
self.factory.protocol = IPCProtocolServer
|
||||||
|
|
|
@ -64,7 +64,7 @@ class MainWindow(component.Component):
|
||||||
self.window = self.main_glade.get_widget("main_window")
|
self.window = self.main_glade.get_widget("main_window")
|
||||||
|
|
||||||
self.window.set_icon(common.get_deluge_icon())
|
self.window.set_icon(common.get_deluge_icon())
|
||||||
|
|
||||||
self.vpaned = self.main_glade.get_widget("vpaned")
|
self.vpaned = self.main_glade.get_widget("vpaned")
|
||||||
self.initial_vpaned_position = self.config["window_pane_position"]
|
self.initial_vpaned_position = self.config["window_pane_position"]
|
||||||
|
|
||||||
|
@ -103,14 +103,20 @@ class MainWindow(component.Component):
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
try:
|
try:
|
||||||
self.resume_components()
|
component.resume("TorrentView")
|
||||||
|
component.resume("StatusBar")
|
||||||
|
component.resume("TorrentDetails")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
self.pause_components()
|
component.pause("TorrentView")
|
||||||
|
component.get("TorrentView").save_state()
|
||||||
|
component.pause("StatusBar")
|
||||||
|
component.pause("TorrentDetails")
|
||||||
# Store the x, y positions for when we restore the window
|
# Store the x, y positions for when we restore the window
|
||||||
self.window_x_pos = self.window.get_position()[0]
|
self.window_x_pos = self.window.get_position()[0]
|
||||||
self.window_y_pos = self.window.get_position()[1]
|
self.window_y_pos = self.window.get_position()[1]
|
||||||
|
@ -124,31 +130,15 @@ class MainWindow(component.Component):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
self.resume_components()
|
component.resume("TorrentView")
|
||||||
|
component.resume("StatusBar")
|
||||||
|
component.resume("TorrentDetails")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.window.present()
|
self.window.present()
|
||||||
self.load_window_state()
|
self.load_window_state()
|
||||||
|
|
||||||
def pause_components(self):
|
|
||||||
"""
|
|
||||||
Pause certain components. This is useful when the main window is not
|
|
||||||
being shown to reduce cpu usage.
|
|
||||||
"""
|
|
||||||
component.pause("TorrentView")
|
|
||||||
component.get("TorrentView").save_state()
|
|
||||||
component.pause("StatusBar")
|
|
||||||
component.pause("TorrentDetails")
|
|
||||||
|
|
||||||
def resume_components(self):
|
|
||||||
"""
|
|
||||||
Resumes components that are paused in `:meth:pause_components`.
|
|
||||||
"""
|
|
||||||
component.resume("TorrentView")
|
|
||||||
component.resume("StatusBar")
|
|
||||||
component.resume("TorrentDetails")
|
|
||||||
|
|
||||||
def active(self):
|
def active(self):
|
||||||
"""Returns True if the window is active, False if not."""
|
"""Returns True if the window is active, False if not."""
|
||||||
return self.window.is_active()
|
return self.window.is_active()
|
||||||
|
@ -191,12 +181,14 @@ class MainWindow(component.Component):
|
||||||
if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
|
if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
|
||||||
if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
|
if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
|
||||||
log.debug("MainWindow is minimized..")
|
log.debug("MainWindow is minimized..")
|
||||||
self.pause_components()
|
component.pause("TorrentView")
|
||||||
|
component.pause("StatusBar")
|
||||||
self.is_minimized = True
|
self.is_minimized = True
|
||||||
else:
|
else:
|
||||||
log.debug("MainWindow is not minimized..")
|
log.debug("MainWindow is not minimized..")
|
||||||
try:
|
try:
|
||||||
self.resume_components()
|
component.resume("TorrentView")
|
||||||
|
component.resume("StatusBar")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.is_minimized = False
|
self.is_minimized = False
|
||||||
|
|
|
@ -165,7 +165,7 @@ class SystemTray(component.Component):
|
||||||
self.tray.set_tooltip(_("Deluge\nNot Connected.."))
|
self.tray.set_tooltip(_("Deluge\nNot Connected.."))
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
if self.config["enable_system_tray"]:
|
if self.config["enable_system_tray"]:
|
||||||
self.tray.set_visible(False)
|
self.tray.set_visible(False)
|
||||||
|
|
||||||
def send_status_request(self):
|
def send_status_request(self):
|
||||||
|
@ -196,6 +196,9 @@ class SystemTray(component.Component):
|
||||||
self.upload_rate = deluge.common.fsize(upload_rate)
|
self.upload_rate = deluge.common.fsize(upload_rate)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
if not self.config["enable_system_tray"]:
|
||||||
|
return
|
||||||
|
|
||||||
# Set the tool tip text
|
# Set the tool tip text
|
||||||
max_download_speed = self.max_download_speed
|
max_download_speed = self.max_download_speed
|
||||||
max_upload_speed = self.max_upload_speed
|
max_upload_speed = self.max_upload_speed
|
||||||
|
|
Loading…
Reference in New Issue