2006-11-30 23:04:59 +00:00
|
|
|
#!/usr/bin/env python2.4
|
|
|
|
#
|
|
|
|
# deluge
|
|
|
|
# Copyright (C) Zach Tibbitts 2006 <zach@collegegeek.org>
|
|
|
|
# Copyright (C) Alon Zakai 2006 <kripkensteiner@gmail.com>
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Deluge is free software.
|
|
|
|
#
|
|
|
|
# You may redistribute it and/or modify it under the terms of the
|
|
|
|
# GNU General Public License, as published by the Free Software
|
|
|
|
# Foundation; either version 2 of the License, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# deluge is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with deluge. If not, write to:
|
|
|
|
# The Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor
|
|
|
|
# Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
from optparse import OptionParser
|
2007-01-12 20:07:55 +00:00
|
|
|
import sys
|
|
|
|
import os, os.path
|
2006-11-30 23:04:59 +00:00
|
|
|
|
2007-02-15 05:24:44 +00:00
|
|
|
parser = OptionParser(usage="%prog [options] [actions]", version="%prog 0.4.90.0")
|
2006-11-30 23:04:59 +00:00
|
|
|
parser.add_option("--tray", dest="tray", help="start Deluge hidden in system tray",
|
|
|
|
metavar="TRAY", action="store_true")
|
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
2007-01-12 20:07:55 +00:00
|
|
|
import dbus
|
2006-11-30 23:04:59 +00:00
|
|
|
|
2007-01-12 20:07:55 +00:00
|
|
|
bus = dbus.SessionBus()
|
2006-11-30 23:04:59 +00:00
|
|
|
|
2007-01-12 20:07:55 +00:00
|
|
|
dbus_objects = dbus.Interface(bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'), 'org.freedesktop.DBus').ListNames()
|
|
|
|
|
|
|
|
interface = None
|
|
|
|
|
|
|
|
if not "org.deluge_torrent.Deluge" in dbus_objects:
|
|
|
|
print "no existing Deluge session"
|
2007-02-08 00:59:42 +00:00
|
|
|
import deluge, deluge.delugegtk
|
2007-02-16 02:03:16 +00:00
|
|
|
import gettext
|
2007-02-16 02:25:53 +00:00
|
|
|
gettext.install('deluge')
|
2007-02-16 02:03:16 +00:00
|
|
|
print _('message')
|
|
|
|
|
2007-02-08 00:59:42 +00:00
|
|
|
interface = deluge.delugegtk.DelugeGTK()
|
2007-01-12 20:07:55 +00:00
|
|
|
for arg in args:
|
|
|
|
apath = os.path.abspath(arg)
|
|
|
|
if apath.endswith(".torrent"):
|
|
|
|
interface.external_add_torrent(apath)
|
|
|
|
else:
|
|
|
|
print "Error,", arg, " does not seem to be a .torrent file"
|
|
|
|
interface.start(hidden=options.tray)
|
|
|
|
else:
|
|
|
|
## This connects to the deluge interface
|
|
|
|
print "create proxy object"
|
|
|
|
proxy = bus.get_object('org.deluge_torrent.Deluge', '/org/deluge_torrent/DelugeObject')
|
|
|
|
print "create iface"
|
|
|
|
deluge_iface = dbus.Interface(proxy, 'org.deluge_torrent.DelugeInterface')
|
|
|
|
print "send to iface"
|
|
|
|
for arg in args:
|
|
|
|
apath = os.path.abspath(arg)
|
|
|
|
if apath.endswith(".torrent"):
|
|
|
|
deluge_iface.external_add_torrent(apath)
|
|
|
|
else:
|
|
|
|
print "Error,", arg, " does not seem to be a .torrent file"
|