Package flumotion :: Package component :: Package plugs :: Module base
[hide private]

Source Code for Module flumotion.component.plugs.base

 1  # -*- Mode: Python -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3  # 
 4  # Flumotion - a streaming media server 
 5  # Copyright (C) 2006 Fluendo, S.L. (www.fluendo.com). 
 6  # All rights reserved. 
 7   
 8  # This file may be distributed and/or modified under the terms of 
 9  # the GNU General Public License version 2 as published by 
10  # the Free Software Foundation. 
11  # This file is distributed without any warranty; without even the implied 
12  # warranty of merchantability or fitness for a particular purpose. 
13  # See "LICENSE.GPL" in the source distribution for more information. 
14   
15  # Licensees having purchased or holding a valid Flumotion Advanced 
16  # Streaming Server license may use this file in accordance with the 
17  # Flumotion Advanced Streaming Server Commercial License Agreement. 
18  # See "LICENSE.Flumotion" in the source distribution for more information. 
19   
20  # Headers in this file shall remain intact. 
21   
22  from flumotion.common import log 
23   
24  __version__ = "$Rev: 6125 $" 
25   
26   
27 -class Plug(log.Loggable):
28 """ 29 Base class for plugs. Provides an __init__ method that receives the 30 plug args and sets them to the 'args' attribute. 31 """
32 - def __init__(self, args):
33 """ 34 @param args: The plug args 35 @type args: dict with keys 'socket', 'type', and 'properties'. 36 'properties' has the same format as component 37 properties. 38 """ 39 self.args = args
40
41 -class ComponentPlug(Plug):
42 """ 43 Base class for plugs that live in a component. Subclasses can 44 implement the start and stop vmethods, which will be called with the 45 component as an argument. 46 """
47 - def start(self, component):
48 pass
49
50 - def stop(self, component):
51 pass
52
53 - def restart(self, component):
54 self.stop(component) 55 self.start(component)
56
57 -class ManagerPlug(Plug):
58 """ 59 Base class for plugs that live in the manager. Subclasses can 60 implement the start and stop vmethods, which will be called with the 61 manager vishnu as an argument. 62 """
63 - def start(self, vishnu):
64 pass
65
66 - def stop(self, vishnu):
67 pass
68
69 - def restart(self, vishnu):
70 self.stop(vishnu) 71 self.start(vishnu)
72