Trees | Indices | Help |
---|
|
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 gettext 19 import os 20 import time 21 22 from flumotion.common.mimetypes import launchApplicationByUrl 23 from flumotion.component.base.admin_gtk import BaseAdminGtk 24 from flumotion.component.base.baseadminnode import BaseAdminGtkNode 25 from flumotion.ui.linkwidget import LinkWidget 26 27 _ = gettext.gettext 28 __version__ = "$Rev$" 29 3032 gladeFile = os.path.join('flumotion', 'component', 'common', 33 'streamer', 'streamer.glade') 34139 14036 BaseAdminGtkNode.__init__(self, *args, **kwargs) 37 self._statistics = None 38 self._shown = False 39 self._stats = None 40 self._link = None 41 self._labels = {}42 43 # BaseAdminGtkNode 4446 self._labels = {} 47 self._statistics = self.wtree.get_widget('main_vbox') 48 self.widget = self._statistics 49 50 for name in ['uptime', 'mime', 'current-bitrate', 'bitrate', 51 'totalbytes']: 52 self._registerLabel('stream-' + name) 53 for name in ['current', 'average', 'max', 'peak', 'peak-time']: 54 self._registerLabel('clients-' + name) 55 for name in ['bitrate', 'bitrate-current', 'totalbytes']: 56 self._registerLabel('consumption-' + name) 57 58 if self._stats: 59 self._shown = True 60 self._updateLabels(self._stats) 61 self._statistics.show_all() 62 63 return self._statistics6466 # Set _stats regardless of if condition 67 # Used to be a race where _stats was 68 # not set if widget tree was gotten before 69 # ui state 70 self._stats = stats 71 if not self._statistics: 72 return 73 74 self._updateLabels(stats) 75 76 if not self._shown: 77 # widget tree created but not yet shown 78 self._shown = True 79 self._statistics.show_all()80 81 # Private 8284 # widgetname = name.replace('-', '_') 85 # FIXME: make object member directly 86 widget = self.wtree.get_widget('label-' + name) 87 if not widget: 88 print "FIXME: no widget %s" % name 89 return 90 91 self._labels[name] = widget9294 # changed in 0.1.9.1 to be int so we can localize time 95 peakTime = state.get('clients-peak-time') 96 if not isinstance(peakTime, str): 97 peakTime = time.strftime("%c", time.localtime(peakTime)) 98 99 self._labels['clients-peak-time'].set_text(peakTime) 100 101 for name in self._labels: 102 if name == 'clients-peak-time': 103 continue 104 text = state.get(name) 105 if text is None: 106 text = '' 107 108 self._labels[name].set_text(text) 109 110 uri = state.get('stream-url', '') 111 if not self._link and uri: 112 self._link = self._createLinkWidget(uri) 113 elif self._link: 114 self._link.set_uri(uri) 115 self._link.set_label(uri) 116 117 disable = state.get('stream-mime') is None 118 tooltip = _('The stream is temporarly unavailable.\n' 119 'No data is being transmitted right now.') 120 if self._link: 121 self._link.set_sensitive(not disable) 122 self._link.set_tooltip_text((disable and tooltip) or '') 123 self._link.set_uri(uri)124126 holder = self.wtree.get_widget('link-holder') 127 if holder is None: 128 return 129 link = LinkWidget(uri) 130 link.set_callback(self._on_link_show_url) 131 link.show_all() 132 holder.add(link) 133 return link134 135 # Callbacks 136142161144 statistics = StatisticsAdminGtkNode(self.state, self.admin, 145 _("Statistics")) 146 self.nodes['Statistics'] = statistics 147 # FIXME: maybe make a protocol instead of overriding 148 return BaseAdminGtk.setup(self)149 152 153 # FIXME: tie this to the statistics node better 154 158
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Aug 13 06:17:20 2013 | http://epydoc.sourceforge.net |