Traceback:
francisco@VoidCaster [12:24:58] [~]
-> $ nautilus
sys:1: PyGIWarning: Nautilus was imported without specifying a version first. Use gi.require_version('Nautilus', '3.0') before import to ensure that the right version gets loaded.
Number of files is 0
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/gi/types.py", line 237, in mro
return mro(cls)
File "/usr/lib/python2.7/site-packages/gi/types.py", line 271, in mro
for base in C.__bases__:
TypeError: get_background_items must return a sequence of Nautilus.MenuItem
**
ERROR:../../pygobject/gi/pygobject-object.c:993:pygobject_new_full: assertion failed: (tp != NULL)
[1] 3375 abort (core dumped) nautilus
Using Nautilus 3.22.2 from ArchLinux. The crash only started happening after updating terminix to 1.5.0, so I suspect commit 0ef55af523762c1918753c98b1c2892ce6867478.
I will try to revert that commit and see if it helps.
Simply removing /usr/share/nautilus-python/extensions/open-terminix.py will avoid the crash (and remove the option "Open in Terminix" from nautilus.
How did you installed terminix ?
Plus, what's the output of which terminix ? The only thing that might cause this issue, is that i have added a check whether the application is installed or not. Which works perfectly in my machine (Archlinux too)
@bil-elmoussaoui
I have installed terminix via the AUR package.
Here is the output you requested:
francisco@VoidCaster [15:21:07] [~]
-> $ which terminix
/usr/bin/terminix
I can confirm that reverting 0ef55af and 3267d9d02b9c5b79b366a45a1658979bf5f792f8 will allow nautilus to work normally and open terminix here works.
Well that's really unexpected. I will investigate tomorrow.
@StuntsPT I took a look and i couldn't reproduce this at all :( anyway i will remove the conditions that i have added, and paste a new Nautilus plugin here. Would you like to test it so i can be sure that everything works fine in your case?
@bil-elmoussaoui Thank you! I will gladly test any solution you propose. Just let me know where to get the new code. =-)
@StuntsPT Wel, here you go, just modify the file under /usr/share/nautilus-python/extensions/open-terminix.pyand replace the content with
# -*- coding: UTF-8 -*-
# This example is contributed by Martin Enlund
# Example modified for Terminix
# Shortcuts Provider was inspired by captain nemo extension
import gettext
from urllib import unquote
from subprocess import PIPE, call
from urlparse import urlparse
gettext.textdomain("terminix")
_ = gettext.gettext
from gi import require_version
require_version('Gtk', '3.0')
require_version('Nautilus', '3.0')
from gi.repository import GObject, Gdk, Gio, Gtk, Nautilus
TERMINAL = "terminix"
def open_terminl_in_file(filename):
if filename:
call('{0} -w "{1}" &'.format(TERMINAL, filename), shell=True)
else:
call("{0} &".format(TERMINAL), shell=True)
class OpenTerminixShortcutProvider(GObject.GObject, Nautilus.LocationWidgetProvider):
def __init__(self):
self.accel_group = Gtk.AccelGroup()
self.gsettings = Gio.Settings.new(
"com.gexperts.Terminix.Keybindings")
self.gsettings.connect("changed", self.bind_shortcut)
self._create_accel_group()
self.window = None
self.uri = None
def _create_accel_group(self):
shortcut = self.gsettings.get_string("nautilus-open")
key, mod = Gtk.accelerator_parse(shortcut)
self.accel_group.connect(
key, mod, Gtk.AccelFlags.VISIBLE, self._open_terminal)
def bind_shortcut(self, gsettings, key):
if key == "nautilus-open":
self.accel_group.disconnect(self._open_terminal)
self._create_accel_group()
def _open_terminal(self, *args):
filename = unquote(self.uri[7:])
open_terminl_in_file(filename)
def get_widget(self, uri, window):
self.uri = uri
if self.window:
self.window.remove_accel_group(self.accel_group)
window.add_accel_group(self.accel_group)
self.window = window
return None
class OpenTerminixExtension(GObject.GObject, Nautilus.MenuProvider):
def _open_terminal(self, file):
if file.get_uri_scheme() in ['ftp', 'sftp']:
result = urlparse(file.get_uri())
if result.username:
value = 'ssh -t {0}@{1}'.format(result.username,
result.hostname)
else:
value = 'ssh -t {0}'.format(result.hostname)
if result.port:
value = "{0} -p {1}".format(value, result.port)
if file.is_directory():
value = '{0} cd "{1}" ; $SHELL'.format(value, result.path)
call('{0} -e "{1}" &'.format(TERMINAL, value), shell=True)
else:
gfile = Gio.File.new_for_uri(file.get_uri())
filename = gfile.get_path()
open_terminl_in_file(filename)
def menu_activate_cb(self, menu, file):
self._open_terminal(file)
def menu_background_activate_cb(self, menu, file):
self._open_terminal(file)
def get_file_items(self, window, files):
if len(files) != 1:
print("Number of files is %d" % len(files))
return
items = []
file = files[0]
print("Handling file: ", file.get_uri())
print("file scheme: ", file.get_uri_scheme())
if file.is_directory(): # and file.get_uri_scheme() == 'file':
if file.get_uri_scheme() in ['ftp', 'sftp']:
item = Nautilus.MenuItem(name='NautilusPython::openterminal_remote_item',
label=_(u'Open Remote Terminix'),
tip=_(u'Open Remote Terminix In %s') % file.get_uri())
item.connect('activate', self.menu_activate_cb, file)
items.append(item)
gfile = Gio.File.new_for_uri(file.get_uri())
info = gfile.query_info(
"standard::*", Gio.FileQueryInfoFlags.NONE, None)
# Get UTF-8 version of basename
filename = info.get_attribute_as_string("standard::name")
item = Nautilus.MenuItem(name='NautilusPython::openterminal_file_item',
label=_(u'Open In Terminix'),
tip=_(u'Open Terminix In %s') % filename)
item.connect('activate', self.menu_activate_cb, file)
items.append(item)
return items
def get_background_items(self, window, file):
items = []
if file.get_uri_scheme() in ['ftp', 'sftp']:
item = Nautilus.MenuItem(name='NautilusPython::openterminal_bg_remote_item',
label=_(u'Open Remote Terminix Here'),
tip=_(u'Open Remote Terminix In This Directory'))
item.connect('activate', self.menu_activate_cb, file)
items.append(item)
item = Nautilus.MenuItem(name='NautilusPython::openterminal_bg_file_item',
label=_(u'Open Terminix Here'),
tip=_(u'Open Terminix In This Directory'))
item.connect('activate', self.menu_background_activate_cb, file)
items.append(item)
return items
Just to let you know, this might break Nautilus and make it crash if you remove Terminix without removing the extension.
Using the code you provided seems to make everything work fine. Thanks!
Isn't this the extension file with both patches reverted? Or did I miss something?
Nop, not at all! both patches were to add a shortcut to open Terminix in the current directory using a keyboard shortcut. And as we use Terminix Gsettings, if you do remove Terminix, Nautilus will crash as It won't find the correct GSettings to read from.
Anyway, i will create a PR right now :)
Ok,I got it now. Thanks.
Wait, what is the default keyboard short-cut you defined?
Could it be that I already had that short-cut defined in my settings and hence that crash on my system, but not yours?
I'm using the default one (CTRL + SHIFT + T), Check your Terminix Settings to modify it :)

Humm... I already had that defined for opening a new session.
Let me see if simply changing that will solve the crash.
@StuntsPT The shortcuts defined on Terminix won't conflict with the Nautilus shortcut ;)
Yeah, it didn't solve it.
@StuntsPT Thanks for testing, i've created a PR :-)
You're welcome.
Thank you for handling this so fast. I'll be sure to report any other issues I find.
Terminix has quickly replaced Terminology as my favourite terminal emulator and is my current main terminal. It really is an awesome project.