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   
25 -class Plug(log.Loggable):
26 """ 27 Base class for plugs. Provides an __init__ method that receives the 28 plug args and sets them to the 'args' attribute. 29 """
30 - def __init__(self, args):
31 """ 32 @param args: The plug args 33 @type args: dict with keys 'socket', 'type', and 'properties'. 34 'properties' has the same format as component 35 properties. 36 """ 37 self.args = args
38
39 -class ComponentPlug(Plug):
40 """ 41 Base class for plugs that live in a component. Subclasses can 42 implement the start and stop vmethods, which will be called with the 43 component as an argument. 44 """
45 - def start(self, component):
46 pass
47
48 - def stop(self, component):
49 pass
50
51 - def restart(self, component):
52 self.stop(component) 53 self.start(component)
54
55 -class ManagerPlug(Plug):
56 """ 57 Base class for plugs that live in the manager. Subclasses can 58 implement the start and stop vmethods, which will be called with the 59 manager vishnu as an argument. 60 """
61 - def start(self, vishnu):
62 pass
63
64 - def stop(self, vishnu):
65 pass
66
67 - def restart(self, vishnu):
68 self.stop(vishnu) 69 self.start(vishnu)
70