Change the add-dialog options to be less confusing
This commit is contained in:
parent
2505aa214c
commit
a8b666effd
|
@ -26,8 +26,8 @@ parser = ArgumentParser(description="A BitTorrent client.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-v', '--verbose', action="count", help="max is -vvv")
|
'-v', '--verbose', action="count", help="max is -vvv")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--add-with-dialog', action="store_true",
|
'--disable-add-dialog', action="store_true",
|
||||||
help="Torrents to be added from arguments open a dialog"
|
help="Torrents to be added from arguments don't open a dialog"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'torrents', nargs="*", help="file path, magnet uri, or info hash",
|
'torrents', nargs="*", help="file path, magnet uri, or info hash",
|
||||||
|
@ -48,8 +48,12 @@ except dbus.exceptions.DBusException:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
for f in args.torrents:
|
for f in args.torrents:
|
||||||
print("Sending %s via dbus".format(f))
|
print("Sending {0} via dbus".format(f))
|
||||||
dbo.AddTorrent(f, dbus_interface="net.launchpad.epour")
|
if args.disable_add_dialog:
|
||||||
|
dbo.AddTorrentWithoutDialog(
|
||||||
|
f, dbus_interface="net.launchpad.epour")
|
||||||
|
else:
|
||||||
|
dbo.AddTorrent(f, dbus_interface="net.launchpad.epour")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -84,7 +88,8 @@ class Epour(object):
|
||||||
self.session.load_torrents()
|
self.session.load_torrents()
|
||||||
|
|
||||||
for t in args.torrents:
|
for t in args.torrents:
|
||||||
if args.add_with_dialog:
|
if (not args.disable_add_dialog) and \
|
||||||
|
self.conf.getboolean("Settings", "add_dialog_enabled"):
|
||||||
self.gui.add_torrent(t)
|
self.gui.add_torrent(t)
|
||||||
else:
|
else:
|
||||||
add_dict = {
|
add_dict = {
|
||||||
|
@ -135,7 +140,7 @@ class Epour(object):
|
||||||
),
|
),
|
||||||
"move_completed_enabled": str(False),
|
"move_completed_enabled": str(False),
|
||||||
"confirm_exit": str(False),
|
"confirm_exit": str(False),
|
||||||
"dialog_add_dbus": str(True),
|
"add_dialog_enabled": str(True),
|
||||||
"delete_original": str(False),
|
"delete_original": str(False),
|
||||||
"listen_low": str(0),
|
"listen_low": str(0),
|
||||||
"listen_high": str(0),
|
"listen_high": str(0),
|
||||||
|
@ -193,9 +198,8 @@ class EpourDBus(dbus.service.Object):
|
||||||
in_signature='s', out_signature='')
|
in_signature='s', out_signature='')
|
||||||
def AddTorrent(self, t):
|
def AddTorrent(self, t):
|
||||||
self.log.info("Adding %s from dbus" % t)
|
self.log.info("Adding %s from dbus" % t)
|
||||||
#self.session.add_torrent(str(t))
|
|
||||||
try:
|
try:
|
||||||
if self.conf.getboolean("Settings", "dialog_add_dbus"):
|
if self.conf.getboolean("Settings", "add_dialog_enabled"):
|
||||||
self.gui.add_torrent(t)
|
self.gui.add_torrent(t)
|
||||||
else:
|
else:
|
||||||
add_dict = {
|
add_dict = {
|
||||||
|
@ -211,6 +215,24 @@ class EpourDBus(dbus.service.Object):
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log.exception("Error while adding torrent from dbus")
|
self.log.exception("Error while adding torrent from dbus")
|
||||||
|
|
||||||
|
@dbus.service.method(dbus_interface='net.launchpad.epour',
|
||||||
|
in_signature='s', out_signature='')
|
||||||
|
def AddTorrentWithoutDialog(self, t):
|
||||||
|
self.log.info("Adding %s from dbus" % t)
|
||||||
|
try:
|
||||||
|
add_dict = {
|
||||||
|
"save_path": self.conf.get("Settings", "storage_path"),
|
||||||
|
"flags": 592
|
||||||
|
}
|
||||||
|
if os.path.isfile(t):
|
||||||
|
self.session.add_torrent_from_file(add_dict, t)
|
||||||
|
elif t.startswith("magnet:"):
|
||||||
|
self.session.add_torrent_from_magnet(add_dict, t)
|
||||||
|
else:
|
||||||
|
self.session.add_torrent_from_hash(add_dict, t)
|
||||||
|
except Exception:
|
||||||
|
self.log.exception("Error while adding torrent from dbus")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
efllog = logging.getLogger("efl")
|
efllog = logging.getLogger("efl")
|
||||||
efllog.setLevel(logging.INFO)
|
efllog.setLevel(logging.INFO)
|
||||||
|
|
|
@ -164,10 +164,11 @@ class PreferencesGeneral(PreferencesDialog):
|
||||||
|
|
||||||
chk3 = Check(self)
|
chk3 = Check(self)
|
||||||
chk3.size_hint_align = ALIGN_LEFT
|
chk3.size_hint_align = ALIGN_LEFT
|
||||||
chk3.text = "Torrents to be added from dbus open a dialog"
|
chk3.text = (
|
||||||
chk3.state = conf.getboolean("Settings", "dialog_add_dbus")
|
"Torrents to be added from dbus or command line open a dialog")
|
||||||
|
chk3.state = conf.getboolean("Settings", "add_dialog_enabled")
|
||||||
chk3.callback_changed_add(lambda x: conf.set(
|
chk3.callback_changed_add(lambda x: conf.set(
|
||||||
"Settings", "confirmations", str(bool(chk3.state))
|
"Settings", "add_dialog_enabled", str(bool(chk3.state))
|
||||||
))
|
))
|
||||||
|
|
||||||
sep2 = Separator(self)
|
sep2 = Separator(self)
|
||||||
|
|
Loading…
Reference in New Issue