Skip to content

Commit

Permalink
Implemented Debug info button in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Laharah committed Jan 19, 2019
1 parent 041a4fd commit 20707dd
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
# FilebotTool: FileBot Integration for Deluge
*requires [Filebot](http://www.filebot.net/)*

**Version 1.2.0**
**Version 1.2.1**

##### [Download Latest Release](https://github.com/Laharah/deluge-FilebotTool/releases/latest)

Expand Down
13 changes: 13 additions & 0 deletions filebottool/core.py
Expand Up @@ -881,3 +881,16 @@ def get_config(self):
"""Returns the config dictionary"""
log.debug("Sending Config")
return self.config.config

@export
@defer.inlineCallbacks
def get_filebot_debug(self):
"""Returns the FileBot debug info."""
log.debug("Received request for FileBot debug info...")
try:
info = yield threads.deferToThread(pyfilebot.debug_info)
except Exception, err:
log.error("FILEBOT ERROR: {0}".format(str(err)), exc_info=True)
defer.returnValue('ERROR COMMUNICATING WITH FILEBOT!\n' + str(err))
log.debug("FileBot debug info retrieved.")
defer.returnValue(info)
101 changes: 65 additions & 36 deletions filebottool/data/config.glade
@@ -1,26 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0"?>
<glade-interface>
<!-- interface-requires gtk+ 2.16 -->
<!-- interface-naming-policy project-wide -->
<widget class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Hellow World</property>
<property name="window_position">center</property>
<child>
<widget class="GtkViewport" id="prefs_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">Edit selected profile</property>
<property name="resize_mode">queue</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkLabel" id="saved_handlers_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">Saved profiles are used in auto-execute rules, and call also be used in the rename dialog.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Saved Profiles:</property>
Expand All @@ -35,17 +32,14 @@
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">10</property>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkTreeView" id="saved_handlers_listview">
<property name="visible">True</property>
Expand All @@ -56,15 +50,12 @@
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkVButtonBox" id="vbuttonbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">center</property>
<child>
<widget class="GtkButton" id="add_handler">
Expand All @@ -73,7 +64,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Add a new profile</property>
<signal name="clicked" handler="on_add_handler" swapped="no"/>
<signal name="clicked" handler="on_add_handler"/>
</widget>
<packing>
<property name="expand">False</property>
Expand All @@ -87,7 +78,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_edit_handler" swapped="no"/>
<signal name="clicked" handler="on_edit_handler"/>
</widget>
<packing>
<property name="expand">False</property>
Expand All @@ -102,7 +93,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Remove selected profile.</property>
<signal name="clicked" handler="on_remove_handler" swapped="no"/>
<signal name="clicked" handler="on_remove_handler"/>
</widget>
<packing>
<property name="expand">False</property>
Expand All @@ -121,20 +112,16 @@
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<widget class="GtkLabel" id="rule_orders_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">On torrent completion. Executes the first rule that matches.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Auto Execute Rules:</property>
Expand All @@ -149,13 +136,11 @@
<child>
<widget class="GtkEventBox" id="eventbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="visible_window">False</property>
<signal name="button_press_event" handler="on_auto_sort_help_clicked" swapped="no"/>
<signal name="button_press_event" handler="on_auto_sort_help_clicked"/>
<child>
<widget class="GtkLabel" id="auto_sort_help">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip" translatable="yes">On torrent completion. Executes the first rule that matches.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;span color="blue"&gt;&lt;u&gt;help?&lt;/u&gt;&lt;/span&gt;</property>
Expand All @@ -179,13 +164,11 @@
<child>
<widget class="GtkHBox" id="rule_orders">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">10</property>
<property name="spacing">5</property>
<child>
<widget class="GtkViewport" id="viewport2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkTreeView" id="rule_listview">
<property name="visible">True</property>
Expand All @@ -197,15 +180,13 @@
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<child>
<widget class="GtkButton" id="move_rule_up">
Expand All @@ -214,11 +195,10 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Higher rules will be tried first.</property>
<signal name="clicked" handler="on_move_rule_up" swapped="no"/>
<signal name="clicked" handler="on_move_rule_up"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
Expand All @@ -229,11 +209,10 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Add a new rule</property>
<signal name="clicked" handler="on_add_rule" swapped="no"/>
<signal name="clicked" handler="on_add_rule"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
Expand All @@ -244,11 +223,10 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Remove selected rule.</property>
<signal name="clicked" handler="on_remove_rule" swapped="no"/>
<signal name="clicked" handler="on_remove_rule"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
Expand All @@ -259,11 +237,10 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip" translatable="yes">Lower Rules will be tried if upper rules do not match.</property>
<signal name="clicked" handler="on_move_rule_down" swapped="no"/>
<signal name="clicked" handler="on_move_rule_down"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
Expand All @@ -276,11 +253,63 @@
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="layout_style">start</property>
<child>
<widget class="GtkButton" id="debug_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">Show system and enviornment info from FileBot.</property>
<property name="border_width">1</property>
<property name="xalign">0</property>
<signal name="clicked" handler="on_debug_button_clicked"/>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-info</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">2</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="debug_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Debug Info</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</widget>
<packing>
<property name="position">4</property>
</packing>
</child>
</widget>
</child>
</widget>
Expand Down
19 changes: 18 additions & 1 deletion filebottool/gtkui/config_ui.py
Expand Up @@ -5,6 +5,9 @@
import time
import webbrowser

from twisted.internet import defer

from deluge.ui.client import client
import deluge.component as component

from filebottool.common import get_resource
Expand All @@ -13,6 +16,8 @@
from filebottool.gtkui.handler_editor import HandlerEditor
import filebottool.auto_sort

import user_messenger

SORT_OPERATORS = filebottool.auto_sort.OPERATOR_MAP.keys()
VALID_FIELDS = filebottool.auto_sort.VALID_FIELDS

Expand Down Expand Up @@ -70,6 +75,7 @@ def text_edited(widget, path, text):
"on_remove_rule": self.rules_list.remove,
"on_add_rule": self.on_add_rule,
"on_auto_sort_help_clicked": self.on_auto_sort_help_clicked,
"on_debug_button_clicked": self.on_debug_button_clicked,
})
self.gather_time = None
if settings:
Expand Down Expand Up @@ -167,6 +173,17 @@ def on_auto_sort_help_clicked(self, *args):
webbrowser.open('https://github.com/Laharah/deluge-FileBotTool/wiki/Auto-Sorting',
new=2)

@defer.inlineCallbacks
def on_debug_button_clicked(self, button):
log.debug("Sending request for FileBot debug info...")
button.set_sensitive(False)
info = yield client.filebottool.get_filebot_debug()
log.debug("Displaying debug info")
dialog = user_messenger.UserMessenger()
dialog.display_text("Filebot Debug Info", info)
button.set_sensitive(True)


#########
# Section: Utilities
#########
Expand All @@ -187,4 +204,4 @@ def build_combo_cellrenderer(model, cb):
renderer.set_property("editable", True)
renderer.set_property("text-column", 0)
renderer.connect("edited", cb)
return renderer
return renderer
24 changes: 23 additions & 1 deletion filebottool/gtkui/user_messenger.py
Expand Up @@ -100,7 +100,8 @@ def show_new_files(self, files):
dialog.run_async()
return

def display_errors(self, errors,
def display_errors(self,
errors,
title=None,
message=None,
parent=None,
Expand Down Expand Up @@ -164,6 +165,27 @@ def _show_details(_):
dialog.run_async()
return

def display_text(self, title, text, parent=None, modal=False):
dialog = InfoDialog(title, None, parent, modal)
text_view = gtk.TextView()
text_view.get_buffer().set_text(text)
text_view.set_editable(False)
text_view.set_cursor_visible(False)
text_view.show()
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.show()
sw.add(text_view)
detail_view = gtk.Frame()
detail_view.set_shadow_type(gtk.SHADOW_IN)
detail_view.add(sw)
detail_view.set_border_width(6)
dialog.vbox.add(detail_view)
detail_view.show()
text_view.set_size_request(485, 300)
dialog.run_async()
return


def format_errors(errors):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -42,7 +42,7 @@
__plugin_name__ = "FileBotTool"
__author__ = "laharah"
__author_email__ = "laharah+fbt@gmail.com"
__version__ = "1.2.0"
__version__ = "1.2.1"
__url__ = "https://github.com/Laharah/deluge-FileBotTool"
__license__ = "GPLv3"
__description__ = "Integrates FileBot functionality to Deluge"
Expand Down

0 comments on commit 20707dd

Please sign in to comment.