wingo - in flumotion/trunk: . bin flumotion/common
flumotion/component flumotion/component/consumers/disker
flumotion/component/consumers/httpstreamer
flumotion/component/consumers/preview flumotion/manager
flumotion/test
flumotion-commit at lists.fluendo.com
flumotion-commit at lists.fluendo.com
Fri Jul 27 15:38:04 CEST 2007
Author: wingo
Date: Fri Jul 27 15:37:41 2007
New Revision: 5365
Added:
flumotion/trunk/flumotion/common/signals.py
flumotion/trunk/flumotion/test/test_common_signals.py
Modified:
flumotion/trunk/ChangeLog
flumotion/trunk/bin/flumotion-manager.in
flumotion/trunk/flumotion/common/Makefile.am
flumotion/trunk/flumotion/component/component.py
flumotion/trunk/flumotion/component/consumers/disker/disker.py
flumotion/trunk/flumotion/component/consumers/httpstreamer/http.py
flumotion/trunk/flumotion/component/consumers/preview/preview.py
flumotion/trunk/flumotion/component/feedcomponent010.py
flumotion/trunk/flumotion/manager/main.py
flumotion/trunk/flumotion/test/Makefile.am
Log:
2007-07-27 Andy Wingo <wingo at pobox.com>
* flumotion/component/consumers/httpstreamer/http.py
(MultifdSinkStreamer): Don't register type; register signals via
SignalMixin interface.
* flumotion/component/consumers/preview/preview.py
(Preview.get_pipeline_string):
* flumotion/component/consumers/disker/disker.py
(Disker._on_marker_start): No need to register gtypes.
* flumotion/manager/main.py (main): Remove gstreamer arg munger.
* flumotion/component/feedcomponent010.py
(FeedComponent.__signals__): Define the signals via the mixin.
* flumotion/component/component.py (BaseComponent): Don't import
gobject. Make components have the SignalMixin; they are not
GObjects any more.
* flumotion/common/Makefile.am (flumotion_PYTHON):
* flumotion/common/signals.py: New mixin, emulates the GObject
connection mechanism in Python so that we can remove dependencies
on GLib in more places.
* flumotion/test/Makefile.am (EXTRA_DIST):
* flumotion/test/test_common_signals.py: Tests for SignalMixin.
* bin/flumotion-manager.in: Don't install the gtk2reactor, we can
use the selectreactor.
Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog (original)
+++ flumotion/trunk/ChangeLog Fri Jul 27 15:37:41 2007
@@ -1,5 +1,34 @@
2007-07-27 Andy Wingo <wingo at pobox.com>
+ * flumotion/component/consumers/httpstreamer/http.py
+ (MultifdSinkStreamer): Don't register type; register signals via
+ SignalMixin interface.
+
+ * flumotion/component/consumers/preview/preview.py
+ (Preview.get_pipeline_string):
+ * flumotion/component/consumers/disker/disker.py
+ (Disker._on_marker_start): No need to register gtypes.
+
+ * flumotion/manager/main.py (main): Remove gstreamer arg munger.
+
+ * flumotion/component/feedcomponent010.py
+ (FeedComponent.__signals__): Define the signals via the mixin.
+
+ * flumotion/component/component.py (BaseComponent): Don't import
+ gobject. Make components have the SignalMixin; they are not
+ GObjects any more.
+
+ * flumotion/common/Makefile.am (flumotion_PYTHON):
+ * flumotion/common/signals.py: New mixin, emulates the GObject
+ connection mechanism in Python so that we can remove dependencies
+ on GLib in more places.
+
+ * flumotion/test/Makefile.am (EXTRA_DIST):
+ * flumotion/test/test_common_signals.py: Tests for SignalMixin.
+
+ * bin/flumotion-manager.in: Don't install the gtk2reactor, we can
+ use the selectreactor.
+
* flumotion/worker/job.py (CheckJobHeaven.__init__): Keep a pool
of idle jobs for running checks.
(CheckJobHeaven.getCheckJobFromPool): New function, tries to reuse
Modified: flumotion/trunk/bin/flumotion-manager.in
==============================================================================
--- flumotion/trunk/bin/flumotion-manager.in (original)
+++ flumotion/trunk/bin/flumotion-manager.in Fri Jul 27 15:37:41 2007
@@ -42,7 +42,7 @@
# and boot!
from flumotion.common import boot
- boot.boot(PROGRAM_PATH, gst=False)
+ boot.boot(PROGRAM_PATH, gst=False, gtk=False, installReactor=False)
except KeyboardInterrupt:
print 'Interrupted'
Modified: flumotion/trunk/flumotion/common/Makefile.am
==============================================================================
--- flumotion/trunk/flumotion/common/Makefile.am (original)
+++ flumotion/trunk/flumotion/common/Makefile.am Fri Jul 27 15:37:41 2007
@@ -33,6 +33,7 @@
reload.py \
server.py \
setup.py \
+ signals.py \
startset.py \
watched.py \
worker.py
Added: flumotion/trunk/flumotion/common/signals.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/common/signals.py Fri Jul 27 15:37:41 2007
@@ -0,0 +1,66 @@
+# -*- Mode: Python; test-case-name: flumotion.test.test_common_signals -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+from flumotion.common import log
+
+class SignalMixin(object):
+ __signals__ = ()
+
+ __signalConnections = None
+ __signalId = 0
+
+ def __ensureSignals(self):
+ if self.__signalConnections is None:
+ self.__signalConnections = {}
+
+ def connect(self, signalName, proc, *args, **kwargs):
+ self.__ensureSignals()
+
+ if signalName not in self.__signals__:
+ raise ValueError('Unknown signal for object of type %r: %s'
+ % (type(self), signalName))
+
+ sid = self.__signalId
+ self.__signalConnections[sid] = (signalName, proc, args, kwargs)
+ self.__signalId += 1
+
+ def disconnect(self, signalId):
+ self.__ensureSignals()
+
+ if signalId not in self.__signalConnections:
+ raise ValueError('Unknown signal ID: %s' % (signalId,))
+
+ del self.__signalConnections[signalId]
+
+ def emit(self, signalName, *args):
+ self.__ensureSignals()
+ if signalName not in self.__signals__:
+ raise ValueError('Emitting unknown signal %s' % signalName)
+
+ connections = self.__signalConnections
+ for name, proc, pargs, pkwargs in connections.itervalues():
+ if name == signalName:
+ try:
+ proc(*(args + pargs), **pkwargs)
+ except Exception, e:
+ log.warning("signalmixin", "Exception calling "
+ "signal handler %r: %s", proc,
+ log.getExceptionMessage(e))
Modified: flumotion/trunk/flumotion/component/component.py
==============================================================================
--- flumotion/trunk/flumotion/component/component.py (original)
+++ flumotion/trunk/flumotion/component/component.py Fri Jul 27 15:37:41 2007
@@ -28,21 +28,20 @@
import time
import socket
-import gobject
-
from twisted.internet import reactor, error, defer
from twisted.cred import error as crederror
from twisted.spread import pb
from twisted.python import reflect
from zope.interface import implements
-from flumotion.common import interfaces, errors, log, planet, medium, pygobject
+from flumotion.common import interfaces, errors, log, planet, medium
from flumotion.common import componentui, common, registry, messages, interfaces
+from flumotion.common import signals
+
from flumotion.common.planet import moods
from flumotion.configure import configure
from flumotion.twisted import credentials
from flumotion.twisted import pb as fpb
-from flumotion.common.pygobject import gsignal
from flumotion.common.messages import N_
T_ = messages.gettexter('flumotion')
@@ -273,7 +272,8 @@
self.warning(msg)
raise errors.MoMethodError(msg)
-class BaseComponent(common.InitMixin, log.Loggable, gobject.GObject):
+class BaseComponent(common.InitMixin, log.Loggable,
+ signals.SignalMixin):
"""
I am the base class for all Flumotion components.
@@ -300,8 +300,6 @@
See L{flumotion.common.common.InitMixin} for more details.
"""
- gobject.GObject.__init__(self)
-
# this will call self.init() for all implementors of init()
common.InitMixin.__init__(self)
@@ -585,14 +583,6 @@
d.addBoth(fireShutdownHook)
return d
- ### GObject methods
- def emit(self, name, *args):
- if 'uninitialized' in str(self):
- self.warning('Uninitialized object!')
- #self.__gobject_init__()
- else:
- gobject.GObject.emit(self, name, *args)
-
### BaseComponent public methods
def getName(self):
return self.name
@@ -720,5 +710,3 @@
self.lastClock = nowClock
self._cpuCallLater = reactor.callLater(5, self._updateCPUUsage)
-
-pygobject.type_register(BaseComponent)
Modified: flumotion/trunk/flumotion/component/consumers/disker/disker.py
==============================================================================
--- flumotion/trunk/flumotion/component/consumers/disker/disker.py (original)
+++ flumotion/trunk/flumotion/component/consumers/disker/disker.py Fri Jul 27 15:37:41 2007
@@ -438,5 +438,3 @@
'%r <-- %r; %r' %
(self._marker_prefix, data, err))
self.change_filename(tmpl)
-
-pygobject.type_register(Disker)
Modified: flumotion/trunk/flumotion/component/consumers/httpstreamer/http.py
==============================================================================
--- flumotion/trunk/flumotion/component/consumers/httpstreamer/http.py (original)
+++ flumotion/trunk/flumotion/component/consumers/httpstreamer/http.py Fri Jul 27 15:37:41 2007
@@ -254,7 +254,9 @@
pipe_template = 'multifdsink name=sink ' + \
'sync=false ' + \
'recover-policy=3'
- gsignal('client-removed', object, int, int, object)
+
+ __signals__ = feedcomponent.ParseLaunchComponent.__signals__
+ __signals__ += ('client-removed',)
componentMediumClass = HTTPMedium
@@ -739,5 +741,3 @@
self.setMood(moods.happy)
d.addCallback(turnHappy)
return d
-
-pygobject.type_register(MultifdSinkStreamer)
Modified: flumotion/trunk/flumotion/component/consumers/preview/preview.py
==============================================================================
--- flumotion/trunk/flumotion/component/consumers/preview/preview.py (original)
+++ flumotion/trunk/flumotion/component/consumers/preview/preview.py Fri Jul 27 15:37:41 2007
@@ -27,5 +27,3 @@
class Preview(feedcomponent.ParseLaunchComponent):
def get_pipeline_string(self, properties):
return 'decodebin ! ffmpegcolorspace ! xvimagesink qos=false'
-
-pygobject.type_register(Preview)
Modified: flumotion/trunk/flumotion/component/feedcomponent010.py
==============================================================================
--- flumotion/trunk/flumotion/component/feedcomponent010.py (original)
+++ flumotion/trunk/flumotion/component/feedcomponent010.py Fri Jul 27 15:37:41 2007
@@ -33,7 +33,6 @@
from flumotion.component import feed
from flumotion.common.planet import moods
-from flumotion.common.pygobject import gsignal
from flumotion.common.messages import N_
T_ = messages.gettexter('flumotion')
@@ -457,8 +456,7 @@
logCategory = 'feedcomponent'
- gsignal('feed-ready', str, bool)
- gsignal('error', str, str)
+ __signals__ = ('feed-ready', 'error')
_reconnectInterval = 3
@@ -1484,5 +1482,3 @@
if self._eaterMapping.has_key(feedId):
return self._eaterMapping[feedId]
return None
-
-pygobject.type_register(FeedComponent)
Modified: flumotion/trunk/flumotion/manager/main.py
==============================================================================
--- flumotion/trunk/flumotion/manager/main.py (original)
+++ flumotion/trunk/flumotion/manager/main.py Fri Jul 27 15:37:41 2007
@@ -110,9 +110,6 @@
vishnu.loadComponentConfigurationXML(path, manager.LOCAL_IDENTITY)
def main(args):
- # XXX: gst_init should remove all options, like gtk_init
- args = [arg for arg in args if not arg.startswith('--gst')]
-
parser = _createParser()
log.debug('manager', 'Parsing arguments (%r)' % ', '.join(args))
Modified: flumotion/trunk/flumotion/test/Makefile.am
==============================================================================
--- flumotion/trunk/flumotion/test/Makefile.am (original)
+++ flumotion/trunk/flumotion/test/Makefile.am Fri Jul 27 15:37:41 2007
@@ -61,6 +61,7 @@
test_porter.py \
test_reflect.py \
test_registry.py \
+ test_signal_mixin.py \
test_testclasses.py \
test_twisted_integration.py \
test_ui_fgtk.py \
Added: flumotion/trunk/flumotion/test/test_common_signals.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/test/test_common_signals.py Fri Jul 27 15:37:41 2007
@@ -0,0 +1,57 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2007 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+import common
+import random
+
+from twisted.trial import unittest
+
+from flumotion.common import signals
+
+
+class TestObject(signals.SignalMixin):
+ __signals__ = ('foo', 'bar')
+
+class TestSignalMixin(unittest.TestCase):
+ def testMixin(self):
+ o = TestObject()
+
+ o.emit('foo')
+ o.emit('bar')
+
+ self.assertRaises(ValueError, o.emit, 'qux')
+
+ emissions = []
+ def trackEmission(*args, **kwargs):
+ emissions.append((args[-1], args[:-1], kwargs))
+
+ o.connect('foo', trackEmission, 'foo')
+ o.connect('bar', trackEmission, 'bar', baz='qux')
+
+ o.emit('foo')
+ self.assertEquals(emissions, [('foo', (), {})])
+ o.emit('foo', 1)
+ self.assertEquals(emissions, [('foo', (), {}),
+ ('foo', (1,), {})])
+ o.emit('bar', 'xyzzy')
+ self.assertEquals(emissions, [('foo', (), {}),
+ ('foo', (1,), {}),
+ ('bar', ('xyzzy',), {'baz':'qux'})])
More information about the flumotion-commit
mailing list