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 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 functions based on twisted.python.reflect 24 """ 25 26 # FIXME: clean up unused imports 27 from twisted.cred import checkers, credentials 28 from twisted.cred.portal import IRealm, Portal 29 from twisted.internet import protocol 30 from twisted.python import log, reflect 31 from twisted.spread import pb, flavors 32 from twisted.spread.pb import PBClientFactory 33 34 __version__ = "$Rev$" 35 36 37 ### stolen from twisted.python.reflect and changed 38 ### the version in Twisted 1.3.0 checks length of backtrace as metric for 39 ### ImportError; for me this fails because two lines of ihooks.py are in 40 ### between 41 ### filed as http://www.twistedmatrix.com/users/roundup.twistd/twisted/issue698 42 ### remove this when fixed and depending on new upstream twisted 43 4446 """Get a fully named package, module, module-global object, or attribute. 47 """ 48 names = name.split('.') 49 topLevelPackage = None 50 moduleNames = names[:] 51 while not topLevelPackage: 52 try: 53 trialname = '.'.join(moduleNames) 54 topLevelPackage = __import__(trialname) 55 except ImportError: 56 import sys 57 # if the ImportError happened in the module being imported, 58 # this is a failure that should be handed to our caller. 59 shortname = trialname.split('.')[-1] 60 # if we're on python2.7 the module is wrapped in single quotation 61 # marks thus broking this method that relies on the message ending 62 # with the name that failed. 63 r = str(sys.exc_info()[1]).strip("'") 64 if not (r.startswith('No module named') and 65 r.endswith(shortname)): 66 raise 67 68 #if str(sys.exc_info()[1]) != "No module named %s" % trialname: 69 # raise 70 moduleNames.pop() 71 72 obj = topLevelPackage 73 for n in names[1:]: 74 obj = getattr(obj, n) 75 76 return obj77 78 # Use the method that comes with twisted if we're running on 8.0 or higher. 79 # FIXME: Remove this module when we can depend on Twisted 8.0 80 from twisted import version 81 if (version.major, version.minor, version.micro) >= (8, 0, 0): 82 from twisted.python.reflect import namedAny 83
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu May 5 05:30:47 2011 | http://epydoc.sourceforge.net |