Browse Source

rpc-window: use pkg_resources for glade file

This is more canonical way for accessing data files.

QubesOS/qubes-issues#910
Marek Marczykowski-Górecki 7 years ago
parent
commit
b1dbc0647f
3 changed files with 7 additions and 7 deletions
  1. 0 2
      qubespolicy/gtkhelpers.py
  2. 4 5
      qubespolicy/rpcconfirmation.py
  3. 3 0
      setup.py

+ 0 - 2
qubespolicy/gtkhelpers.py

@@ -26,8 +26,6 @@ from gi.repository import Gtk, Gdk, GdkPixbuf, GObject, GLib
 import qubes
 from qubespolicy.utils import sanitize_domain_name
 
-glade_directory = os.path.join(os.path.dirname(__file__), "glade")
-
 
 class GtkIconGetter:
     def __init__(self, size):

+ 4 - 5
qubespolicy/rpcconfirmation.py

@@ -18,18 +18,17 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-
-
+import pkg_resources
 from gi.repository import Gtk, Gdk, GLib
 import os
-from qubespolicy.gtkhelpers import VMListModeler, FocusStealingHelper, \
-    glade_directory
+from qubespolicy.gtkhelpers import VMListModeler, FocusStealingHelper
 from qubespolicy.utils import sanitize_domain_name, \
     sanitize_service_name
 
 
 class RPCConfirmationWindow:
-    _source_file = os.path.join(glade_directory, "RPCConfirmationWindow.glade")
+    _source_file = pkg_resources.resource_filename('qubespolicy',
+        os.path.join('glade', "RPCConfirmationWindow.glade"))
     _source_id = {'window': "RPCConfirmationWindow",
                   'ok': "okButton",
                   'cancel': "cancelButton",

+ 3 - 0
setup.py

@@ -27,6 +27,9 @@ if __name__ == '__main__':
         license='GPL2+',
         url='https://www.qubes-os.org/',
         packages=setuptools.find_packages(exclude=('core*', 'tests')),
+        package_data = {
+            'qubespolicy': ['glade/*.glade'],
+        },
         entry_points={
             'console_scripts': list(get_console_scripts()) + [
                 'qrexec-policy = qubespolicy.cli:main',