Commits

Ronny Pfannschmidt committed 47eb32a

initial

  • Participants

Comments (0)

Files changed (5)

+^\.hg
+^\.mq
+syntax: glob
+status
+guards

File commander-vte-event-parsing

+diff -r f4b2bf9fa4f0 -r d597cdb9e785 pida/services/commander/commander.py
+--- a/pida/services/commander/commander.py	Mon Jun 15 23:59:43 2009 +0200
++++ b/pida/services/commander/commander.py	Tue Jun 16 15:04:12 2009 +0200
+@@ -471,19 +471,14 @@ class TerminalView(PidaView):
+                             self._on_python_fork_parse_key_press_event, self.master)
+ 
+     def _on_python_fork_parse_key_press_event(self, term, event, fd):
+-        if event.hardware_keycode == 22:
+-            os.write(fd, "\x7f")
+-        elif event.hardware_keycode == 98:
+-            os.write(fd, "\x1bOA")
+-        elif event.hardware_keycode == 104:
+-            os.write(fd, "\x1bOB")
+-        elif event.hardware_keycode == 100:
+-            os.write(fd, "\x1bOD")
+-        elif event.hardware_keycode == 102:
+-            os.write(fd, "\x1bOC")
+-        else:
+-            data = event.string
+-            os.write(fd, data)
++        mapping = {
++                22: '\x7f',
++                98: "\x1bOA",
++                104:"\x1bOB",
++                100:"\x1bOD",
++                102:"\x1bOC",
++                }
++        os.write(fd, mapping.get(event.hardware_keycode, event.string))
+         return True
+ 
+     def _on_python_fork_parse_stdout(self, fd, state, parser = None):

File error-free-plugin-load

+# HG changeset patch
+# User Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
+# Date 1243750351 -7200
+# Node ID f5add93dc7e0c15ee944adbc355db520dcf53737
+# Parent  3b88bb1b40d299ed4e522933af9856a3b4bca346
+initial handler for graccefull handling of plugin loading errors NEEDS TESTS
+
+diff -r 3b88bb1b40d2 -r f5add93dc7e0 pida/core/servicemanager.py
+--- a/pida/core/servicemanager.py	Wed Jun 10 04:08:16 2009 +0200
++++ b/pida/core/servicemanager.py	Sun May 31 08:12:31 2009 +0200
+@@ -139,23 +139,48 @@ class ServiceManager(object):
+         self._pre_start_services()
+ 
+     def start_plugin(self, name):
+-        plugin = self._plugins.get_one(name)(self._boss)
+-        assert not hasattr(plugin, 'started')
+-        plugin.started = False # not yet started
+-        pixmaps_dir = os.path.join(plugin.__path__, 'pixmaps')
+-        if os.path.exists(pixmaps_dir):
+-            self._boss._icons.register_file_icons_for_directory(pixmaps_dir)
+-        if plugin is not None:
++        plugin_class = self._plugins.get_one(name)
++        if plugin_class is None:
++            log.error('Unable to load plugin %s' % name)
++            return
++
++        #XXX: test this more roughly
++        plugin = plugin_class(self._boss)
++        try:
++            if hasattr(plugin, 'started') :
++                log.error("plugin.started shouldn't be set by %r", plugin)
++
++            plugin.started = False # not yet started
++
++            #XXX: unregister?
++            pixmaps_dir = os.path.join(plugin.__path__, 'pixmaps')
++            if os.path.exists(pixmaps_dir):
++                self._boss._icons.register_file_icons_for_directory(pixmaps_dir)
+             self._register(plugin)
+-            plugin.create_all()
+-            plugin.subscribe_all()
+-            plugin.pre_start()
+-            plugin.start()
+-            assert plugin.started is False # this shouldn't change
+-            plugin.started = True
+-            return plugin
+-        else:
+-            log.error('Unable to load plugin %s' % name)
++            try:
++                try:
++                    plugin.create_all()
++
++                    #stop_components will handle
++                    plugin.subscribe_all()
++
++                    #XXX: what to do with unrolling those
++                    plugin.pre_start()
++                    plugin.start()
++                    assert plugin.started is False # this shouldn't change
++                    plugin.started = True
++                    return plugin
++                except:
++                    plugin.stop_components()
++                    raise
++            except:
++                del self._reg[name]
++                raise
++
++        except:
++            self._plugins.unload(name)
++            raise
++
+ 
+     def stop_plugin(self, name):
+         plugin = self.get_service(name)
+commander-vte-event-parsing
+error-free-plugin-load
+waypoint
+diff -r f5add93dc7e0 pida-plugins/waypoint/test_waypoint.py
+--- a/pida-plugins/waypoint/test_waypoint.py	Sun May 31 08:12:31 2009 +0200
++++ b/pida-plugins/waypoint/test_waypoint.py	Wed Jun 10 14:58:01 2009 +0200
+@@ -26,10 +26,12 @@ from pida.core.document import Document
+ 
+ from .waypoint import WayPoint, WayStack
+ 
+-BOSS = Mock()
+ 
+ class WaypointTest(object):
+ 
++    def setup_method(self, method):
++        self.boss = Mock()
++
+     def should(self, wp, should):
+         for i, (doc, pos) in enumerate(should):
+             self.assertEqual(wp[i].document, doc)
+@@ -37,8 +39,8 @@ class WaypointTest(object):
+ 
+ 
+     def test_has(self):
+-        doc1 = Document(BOSS)
+-        doc2 = Document(BOSS)
++        doc1 = Document(self.boss)
++        doc2 = Document(self.boss)
+         wp = WayStack(max_length=10, threshold=10)
+         w1 = WayPoint(doc1, 10)
+         w2 = WayPoint(doc1, 10)
+@@ -73,7 +75,7 @@ class WaypointTest(object):
+         w3 = WayPoint(doc2, 10)
+ 
+     def test_maxlength(self):
+-        doc1 = Document(BOSS)
++        doc1 = Document(self.boss)
+         wp = WayStack(max_length=10, threshold=10, timespan=5)
+         for i in xrange(20):
+             wp.notify_change(doc1, 100*i+1, time_=(60*i)+1)
+@@ -84,8 +86,8 @@ class WaypointTest(object):
+ 
+ 
+     def test_waypoint(self):
+-        doc1 = Document(BOSS)
+-        doc2 = Document(BOSS)
++        doc1 = Document(self.boss)
++        doc2 = Document(self.boss)
+         wp = WayStack(max_length=10, threshold=30, timespan=4)
+         wp.notify_change(doc1, 10, time_=10)
+         wp.notify_change(doc1, 12, time_=20)
+@@ -146,8 +148,8 @@ class WaypointTest(object):
+ 
+ 
+     def test_waypoint_jump(self):
+-        doc1 = Document(BOSS)
+-        doc2 = Document(BOSS)
++        doc1 = Document(self.boss)
++        doc2 = Document(self.boss)
+         wp = WayStack(max_length=10)
+         wp.notify_change(doc1, 10, time_=10)
+         wp.notify_change(doc1, 10, time_=20)