1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
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
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
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