dbus changes
This commit is contained in:
@@ -25,8 +25,10 @@
|
||||
# Boston, MA 02110-1301, USA.
|
||||
|
||||
from optparse import OptionParser
|
||||
import sys
|
||||
import os, os.path
|
||||
|
||||
parser = OptionParser(usage="%prog [options] [actions]", version="%prog 0.5")
|
||||
parser = OptionParser(usage="%prog [options] [actions]", version="%prog 0.5.0")
|
||||
parser.add_option("--tray", dest="tray", help="start Deluge hidden in system tray",
|
||||
metavar="TRAY", action="store_true")
|
||||
|
||||
@@ -34,6 +36,39 @@ parser.add_option("--tray", dest="tray", help="start Deluge hidden in system tra
|
||||
|
||||
if options.tray:
|
||||
print "Deluge will start in the system tray if available"
|
||||
|
||||
print options
|
||||
print args
|
||||
|
||||
import dbus
|
||||
|
||||
bus = dbus.SessionBus()
|
||||
|
||||
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"
|
||||
import delugegtk
|
||||
interface = delugegtk.DelugeGTK()
|
||||
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"
|
||||
|
Reference in New Issue
Block a user