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 """Wizard plugin for the cortado http plug 19 """ 20 21 from zope.interface import implements 22 23 import gtk 24 import os 25 26 from flumotion.admin.assistant.interfaces import IHTTPServerPlugin 27 from flumotion.admin.assistant.models import Plug 28 from flumotion.common import messages 29 from flumotion.common.i18n import N_, gettexter 30 from flumotion.ui.fileselector import FileSelectorDialog 31 from flumotion.ui.plugarea import WizardPlugLine 32 33 __version__ = "$Rev$" 34 T_ = gettexter() 35 3638 """I am a model representing the configuration file for a 39 Request Logger plug. 40 """ 41 plugType = "requestlogger-file" 42 4753 5456 gladeFile = os.path.join(os.path.dirname(os.path.abspath(__file__)), 57 'wizard.glade') 58 toplevel_name = 'requestlogger-window' 599861 WizardPlugLine.__init__(self, wizard, model, description) 62 63 self.logfile.data_type = str 64 self._proxy = self.add_proxy(self.model.properties, ['logfile']) 65 66 if self.getActive(): 67 self.model.setActive(True) 68 else: 69 self.plugActiveChanged(False)70 71 # WizardPlugLine 7274 self.logfile.set_sensitive(active) 75 self.select_logfile.set_sensitive(active) 76 self.model.setActive(active)77 78 # Callbacks 7981 82 def response(fs, response): 83 fs.hide() 84 if response == gtk.RESPONSE_OK: 85 filename = os.path.join(fs.getFilename(), 'access.log') 86 self.model.properties.logfile = filename 87 self._proxy.update('logfile')88 89 fs = FileSelectorDialog(self.wizard.window, 90 self.wizard.getAdminModel()) 91 92 fs.connect('response', response) 93 fs.selector.setOnlyDirectoriesMode(True) 94 fs.selector.setWorkerName(self.model.component.worker) 95 directory = os.path.dirname(self.model.properties.logfile) 96 fs.setDirectory(directory) 97 fs.show_all()100 self._runChecks()101103 self.wizard.waitForTask('ondemand check') 104 105 worker = self.model.component.worker 106 directory = os.path.dirname(self.logfile.get_text()) 107 108 def importError(failure): 109 failure.trap(ImportError) 110 self.info('could not import twisted-web') 111 message = messages.Warning(T_(N_( 112 "Worker '%s' cannot import module '%s'."), 113 worker, 'twisted.web')) 114 message.add(T_(N_("\nThis module is part of the '%s'."), 115 'Twisted Project')) 116 message.add(T_(N_("\nThe project's homepage is %s"), 117 'http://www.twistedmatrix.com/')) 118 message.id = 'module-twisted-web' 119 self.wizard.add_msg(message) 120 self.wizard.taskFinished(True) 121 return False122 123 def checkPathFinished(pathExists): 124 if not pathExists: 125 message = messages.Warning(T_(N_( 126 "Directory '%s' does not exist, " 127 "or is not readable on worker '%s'.") 128 % (directory, worker))) 129 message.id = 'log-path-check' 130 self.wizard.add_msg(message) 131 self.wizard.taskFinished(True) 132 return False 133 else: 134 self.wizard.clear_msg('log-path-check') 135 self.wizard.taskFinished(False) 136 return True 137 138 self.wizard.taskFinished() 139 140 def checkPath(unused): 141 d = self.wizard.runInWorker( 142 worker, 'flumotion.worker.checks.check', 143 'checkDirectory', directory) 144 d.addCallback(checkPathFinished) 145 return d 146 147 d = self.wizard.checkImport(worker, 'twisted.web') 148 d.addCallback(checkPath) 149 d.addErrback(importError) 150 return d 151 152 165 166168 """I am a model representing the configuration file for the 169 Force download plug. 170 """ 171 plugType = "requestmodifier-forcedownload" 172184 185174 Plug.__init__(self) 175 self.component = component 176 self.properties.argument_name = 'force' 177 self.properties.trigger_value = 'true'178187198 199 213189 WizardPlugLine.__init__(self, wizard, model, description) 190 191 if self.getActive(): 192 self.model.setActive(True)193 194 # WizardPlugLine 195197 self.model.setActive(active)
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Aug 13 06:17:23 2013 | http://epydoc.sourceforge.net |