Package flumotion :: Package component :: Package producers :: Package videotest :: Module admin_text
[hide private]

Source Code for Module flumotion.component.producers.videotest.admin_text

 1  # -*- Mode: Python -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3   
 4  # Flumotion - a streaming media server 
 5  # Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L. 
 6  # Copyright (C) 2010,2011 Flumotion Services, S.A. 
 7  # All rights reserved. 
 8  # 
 9  # This file may be distributed and/or modified under the terms of 
10  # the GNU Lesser General Public License version 2.1 as published by 
11  # the Free Software Foundation. 
12  # This file is distributed without any warranty; without even the implied 
13  # warranty of merchantability or fitness for a particular purpose. 
14  # See "LICENSE.LGPL" in the source distribution for more information. 
15  # 
16  # Headers in this file shall remain intact. 
17   
18  import string 
19   
20  from flumotion.component.base.admin_text import BaseAdminText 
21   
22  __version__ = "$Rev$" 
23   
24   
25 -class VideoTestAdminText(BaseAdminText):
26 commands = ['setpattern', 'getpattern'] 27 patterns = ['smpte', 'snow', 'black'] 28
29 - def setup(self):
30 pass
31
32 - def getCompletions(self, input):
33 input_split = input.split() 34 available_commands = [] 35 if input.endswith(' '): 36 input_split.append('') 37 if len(input_split) <= 1: 38 for c in self.commands: 39 if c.startswith(string.lower(input_split[0])): 40 available_commands.append(c) 41 elif len(input_split) == 2: 42 if string.lower(input_split[0]) == 'setpattern': 43 for p in self.patterns: 44 if p.startswith(string.lower(input_split[1])): 45 available_commands.append(p) 46 47 return available_commands
48
49 - def runCommand(self, command):
50 command_split = command.split() 51 if string.lower(command_split[0]) == 'setpattern': 52 # set pattern 53 if len(command_split) == 2: 54 pattern = -1 55 if string.lower(command_split[1]) == 'smpte': 56 pattern = 0 57 elif string.lower(command_split[1]) == 'snow': 58 pattern = 1 59 elif string.lower(command_split[1]) == 'black': 60 pattern = 2 61 if pattern > -1: 62 d = self.callRemote("setPattern", pattern) 63 return d 64 elif string.lower(command_split[0]) == 'getpattern': 65 # get pattern 66 67 def getpattern_cb(uiState): 68 return self.patterns[uiState.get('pattern')]
69 d = self.callRemote("getUIState") 70 d.addCallback(getpattern_cb) 71 return d 72 else: 73 return None
74 75 76 UIClass = VideoTestAdminText 77