dbus fallback

This commit is contained in:
Zach Tibbitts 2007-02-26 20:39:35 +00:00
commit 93378db25d

View file

@ -31,7 +31,7 @@ import os, os.path
parser = OptionParser(usage="%prog [options] [actions]", version="%prog 0.4.90.0") parser = OptionParser(usage="%prog [options] [actions]", version="%prog 0.4.90.0")
parser.add_option("--tray", dest="tray", help="start Deluge hidden in system tray", parser.add_option("--tray", dest="tray", help="start Deluge hidden in system tray",
metavar="TRAY", action="store_true") metavar="TRAY", action="store_true")
try:
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
import dbus import dbus
@ -43,8 +43,10 @@ elif dbus_version >= (0,80,0):
DBusGMainLoop(set_as_default=True) DBusGMainLoop(set_as_default=True)
else: else:
pass pass
except: dbus_imported = False
else: dbus_imported = True
if dbus_imported:
bus = dbus.SessionBus() bus = dbus.SessionBus()
dbus_objects = dbus.Interface(bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'), 'org.freedesktop.DBus').ListNames() dbus_objects = dbus.Interface(bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'), 'org.freedesktop.DBus').ListNames()
@ -78,3 +80,17 @@ else:
deluge_iface.external_add_torrent(apath) deluge_iface.external_add_torrent(apath)
else: else:
print "Error,", arg, " does not seem to be a .torrent file" print "Error,", arg, " does not seem to be a .torrent file"
else:
print "no existing Deluge session"
import deluge, deluge.delugegtk
import gettext
gettext.install('deluge')
interface = deluge.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)