Trees | Indices | Help |
---|
|
1 # -*- Mode: Python; test-case-name: flumotion.test.test_feedcomponent010 -*- 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 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 """ 23 Component tab in the component UI 24 """ 25 26 import gettext 27 import os 28 import time 29 30 import gtk 31 32 from flumotion.common.format import formatStorage, formatTime 33 from flumotion.common.i18n import gettexter 34 from flumotion.component.base.baseadminnode import BaseAdminGtkNode 35 from flumotion.extern.log.log import getDebug 36 from flumotion.common.planet import AdminFlowState 37 38 39 _ = gettext.gettext 40 __version__ = "$Rev$" 41 T_ = gettexter() 42 4345 gladeFile = os.path.join('flumotion', 'component', 'base', 46 'component.glade') 4724349 BaseAdminGtkNode.__init__(self, state, admin, title=_("Component")) 50 51 self._startTime = None 52 self._debugging = None 53 self._initialFluMask = '' 54 self._initialGstMask = ''5557 BaseAdminGtkNode.setDebugEnabled(self, enabled) 58 if self._debugging: 59 self._debugging.set_property('visible', enabled) 60 61 self._initialFluMask = getDebug() 62 self._initialGstMask = os.environ.get('GST_DEBUG', '')6365 self.widget = self.wtree.get_widget('main-vbox') 66 assert self.widget, "No component-widget in %s" % self.gladeFile 67 self.gst_mask = self.wtree.get_widget('gst_mask') 68 self.gst_label = self.wtree.get_widget('gst_label') 69 self.flu_mask = self.wtree.get_widget('flu_mask') 70 self.gst_profile = self.wtree.get_widget('gst_profile') 71 self.gst_profile.connect('changed', self._on_gst_profile_changed) 72 self.flu_profile = self.wtree.get_widget('flu_profile') 73 self.flu_profile.connect('changed', self._on_flu_profile_changed) 74 self.gst_button = self.wtree.get_widget('gst_button') 75 self.gst_button.connect('clicked', self._on_gst_button_clicked) 76 self.gst_mask.connect('activate', self._on_gst_button_clicked) 77 self.flu_button = self.wtree.get_widget('flu_button') 78 self.flu_button.connect('clicked', self._on_flu_button_clicked) 79 self.flu_mask.connect('activate', self._on_flu_button_clicked) 80 81 # pid 82 l = self.wtree.get_widget('label-pid') 83 pid = self.state.get('pid') 84 l.set_text(str(pid)) 85 86 # Find the labels which we'll update when we get uiState updates. 87 self._label_start_time = self.wtree.get_widget('label-since') 88 self._label_uptime = self.wtree.get_widget('label-uptime') 89 self._label_cpu = self.wtree.get_widget('label-cpu') 90 self._label_vsize = self.wtree.get_widget('label-vsize') 91 self._label_component_type = self.wtree.get_widget( 92 'label-component-type') 93 94 self._label_resets = self.wtree.get_widget('label-resets') 95 self._label_resets_count = self.wtree.get_widget('label-resets-count') 96 self.widget.show() 97 98 self._prepareDebugging() 99 100 self._debugging = self.wtree.get_widget('debugging') 101 if self._debugEnabled: 102 self._debugging.show() 103 104 componentType = self.state.get('config')['type'] 105 self._label_component_type.set_text(componentType) 106 107 return self.widget108110 if ':' not in mask or mask.count(':') != 1: 111 return False 112 name, level = mask.split(':', 1) 113 try: 114 int(level) 115 except ValueError: 116 return False 117 return True118120 profile = combo.get_selected() 121 if profile is not None: 122 gtk.Entry.set_text(self.gst_mask, profile) 123 self.gst_mask.set_sensitive(profile is None)124126 profile = combo.get_selected() 127 if profile is not None: 128 gtk.Entry.set_text(self.flu_mask, profile) 129 self.flu_mask.set_sensitive(profile is None)130 138 146148 debugEnabled = self._debugEnabled 149 self._debugEnabled = False 150 default = [(_('Nothing'), '*:0'), 151 (_('Everything'), '*:4'), 152 (_('Custom'), None)] 153 self.flu_profile.prefill(default) 154 155 if isinstance(self.state.get('parent'), AdminFlowState): 156 self.gst_profile.prefill(default) 157 else: 158 self.gst_profile.hide() 159 self.gst_label.hide() 160 self.gst_mask.hide() 161 self.gst_button.hide() 162 163 self._debugEnabled = debugEnabled164166 self._label_start_time.set_text( 167 time.strftime("%c", time.localtime(value))) 168 self._label_uptime.set_text(formatTime(0)) 169 170 self._startTime = value171173 if self._startTime is not None: 174 runtime = value - self._startTime 175 176 self._label_uptime.set_text(formatTime(runtime)) 177 else: 178 self._label_uptime.set_text(_("not available"))179181 self.gst_mask.set_text(value) 182 try: 183 self.gst_profile.select_item_by_data(value) 184 except KeyError: 185 self.gst_profile.select_item_by_data(None)186188 self.flu_mask.set_text(value) 189 try: 190 self.flu_profile.select_item_by_data(value) 191 except KeyError: 192 self.flu_profile.select_item_by_data(None)193 197199 # given int for vsize in bytes, update the label 200 if not vsize: 201 self._label_vsize.set_text(_('Unknown')) 202 else: 203 self._label_vsize.set_text('%sB' % formatStorage(vsize))204206 if not self._label_resets.get_property('visible'): 207 self._label_resets.show() 208 self._label_resets_count.show() 209 self._label_resets_count.set_text('%d restarts' % count)210212 BaseAdminGtkNode.setUIState(self, uiState) 213 214 # Ick; we don't get these otherwise. 215 for key in uiState.keys(): 216 val = uiState.get(key) 217 if val is not None: 218 self.stateSet(uiState, key, uiState.get(key))219 220 # IStateListener Interface 221223 if key == 'cpu-percent': 224 self._updateCPU(value) 225 elif key == 'virtual-size': 226 self._updateVSize(value) 227 elif key == 'start-time': 228 self._setStartTime(value) 229 elif key == 'current-time': 230 self._setCurrentTime(value) 231 elif key == 'reset-count': 232 self._updateResets(value) 233 elif key == 'flu-debug': 234 self._setFluDebug(value) 235 elif key == 'gst-debug': 236 self._setGstDebug(value)237 240
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Dec 8 09:51:26 2011 | http://epydoc.sourceforge.net |