Trees | Indices | Help |
|
---|
|
|
|||
HtmlFormatter Formatter for the logging class |
|||
SendPageProtocol | |||
Singleton Metaclass that ensures only a single instance of a class is ever created. |
|
|||
logging handler |
|
||
|
|||
string |
|
||
list |
|
||
object |
|
||
integer or None |
|
||
object or None |
|
||
class |
|
||
string |
|
||
list |
|
||
list |
|
||
list |
|
||
string |
|
||
string |
|
||
object |
|
||
object |
|
||
string |
|
||
string |
|
||
tuple |
|
||
tuple |
|
||
string |
|
||
re match object |
|
||
re match object |
|
||
boolean |
|
||
string |
|
||
|
|||
string |
|
||
string |
|
||
|
|||
|
|||
string |
|
||
string |
|
||
integer |
|
||
boolean |
|
||
string |
|
||
string |
|
||
boolean |
|
||
unsigned int |
|
||
|
|||
|
|||
|
|||
function |
|
||
function |
|
||
str
>>> readable_time(None) '0 seconds' >>> readable_time(0) '0 seconds' >>> readable_time(0.12) '0 seconds' >>> readable_time(1) '1 second' >>> readable_time(1.5) '1 second' >>> readable_time(60) '1 minute' >>> readable_time(60*60*3+12) '3 hours' >>> readable_time(60*60*3+12, 2) '3 hours 12 seconds' |
|
||
str
>>> relative_time(time.time() - 60*10) '10 minutes ago' >>> relative_time(time.time() - 60*10-3, precision=2) '10 minutes 3 seconds ago' >>> relative_time(time.time() - 60*60*24*10, precision=2) '1 week 3 days ago' >>> relative_time(time.time() - 60*60*24*365-1, precision=2) '1 year 1 second ago' >>> relative_time(time.time() + 1 + 60*60*24*7*2) # Add 1 for rounding 'in 2 weeks' |
|
||
|
|||
string |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
__doc__ = """Ut
|
|||
log = logging.getLogger("zen.Utils")
|
|||
DEFAULT_SOCKET_TIMEOUT = 30
|
|||
EXIT_CODE_MAPPING = {0: 'Success', 1: 'General error', 2: 'Mis
|
|
Setup logging to log to a browser using a request object.
|
Clear our web logger.
|
Convert a number to its human-readable form. ie: 4GB, 4MB, etc. >>> convToUnits() # Don't do this! '0.0B' >>> convToUnits(None) # Don't do this! '' >>> convToUnits(123456789) '117.7MB' >>> convToUnits(123456789, 1000, "Hz") '123.5MHz'
|
Walk a series of to one rels collecting collectname into collect
|
Get a Zope object by its path (e.g. '/Devices/Server/Linux'). Mostly a stripdown of unrestrictedTraverse method from Zope 2.8.8.
|
Perform issubclass using class name as string
|
look in sys.modules for our class
|
Import a class from the module given.
|
Take the trailing off the end of a string
|
Do a depth-first search looking for objects that the function filter returns as True. If descend is passed it will check to see if we should keep going down or not
|
Do a depth-first search looking for objects that the function filter returns as True. If descend is passed it will check to see if we should keep going down or not. This is a Python iterable.
|
Get all ZenModelRM objects in database
|
Split a zen path and clean up any blanks or bogus spaces in it
|
Build a zenpath in its string form
|
Create a hierarchy object from its path we use relpath to skip down any missing relations in the path and factory is the constructor for this object.
|
Return an object using its path relations are optional in the path.
|
Add the username and password to a url in the form http://username:password@host/path
|
Make an id with valid url characters. Subs [^a-zA-Z0-9-_,.$\(\) ] with subchar. If id then starts with subchar it is removed.
|
Send an email. Return a tuple: (sucess, message) where sucess is True or False.
|
Send a page. Return a tuple: (success, message) where sucess is True or False.
|
Convert a string using the decoding found in zCollectorDecoding
|
Test to see if an IP should not be included in the network map. Uses the zLocalIpAddresses to decide.
|
Test to see if an interface should not be included in the network map. Uses the zLocalInterfaceNames to decide.
|
Check to see if any of an object's base classes are in a list of class names. Like isinstance(), but without requiring a class to compare against.
|
Resequence a seqmap
|
Prune out objects
|
Convert edges to an XML file
|
Joins paths in a saner manner than os.path.join()
|
Return a path relative to $ZENHOME specified by joining args. The path is not guaranteed to exist on the filesystem. >>> import os >>> zenHome = os.environ['ZENHOME'] >>> zenPath() == zenHome True >>> zenPath( '' ) == zenHome True >>> zenPath('Products') == os.path.join(zenHome, 'Products') True >>> zenPath('/Products/') == zenPath('Products') True >>> >>> zenPath('Products', 'foo') == zenPath('Products/foo') True # NB: The following is *NOT* true for os.path.join() >>> zenPath('/Products', '/foo') == zenPath('Products/foo') True >>> zenPath(zenPath('Products')) == zenPath('Products') True >>> zenPath(zenPath('Products'), 'orange', 'blue' ) == zenPath('Products', 'orange', 'blue' ) True # Pathological case # NB: need to expand out the array returned by split() >>> zenPath() == zenPath( *'/'.split(zenPath()) ) True
To Do: determine what the correct behaviour should be if $ZENHOME is a symlink! |
Similar to zenPath() except that this constructs a path based on ZOPEHOME rather than ZENHOME. This is useful on the appliance. If ZOPEHOME is not defined or is empty then return ''. NOTE: A non-empty return value does not guarantee that the path exists, just that ZOPEHOME is defined. >>> import os >>> zopeHome = os.environ.setdefault('ZOPEHOME', '/something') >>> zopePath('bin') == os.path.join(zopeHome, 'bin') True >>> zopePath(zopePath('bin')) == zopePath('bin') True
|
Search for the given file in a list of possible locations. Return either the full path to the file or '' if the file was not found. >>> len(binPath('zenoss')) > 0 True >>> len(binPath('zeoup.py')) > 0 # This doesn't exist in Zope 2.12 False >>> len(binPath('check_http')) > 0 True >>> binPath('Idontexistreally') == '' True
|
IE puts the POST content in one place in the REQUEST object, and Firefox in another. Thus we need to try both.
|
A no-op function useful for shutting up pychecker
|
Did we receive a XML-RPC call?
|
Extract out the 2nd outermost table
|
Execute the command and return the output
|
Compare (cmp()) a + b's IP addresses These addresses may contain subnet mask info.
|
Convert negative 32-bit values into the 2's complement unsigned value >>> str(unsigned(-1)) '4294967295' >>> unsigned(1) 1L >>> unsigned(1e6) 1000000L >>> unsigned(1e10) 10000000000L
|
Execute cmd in the shell and send the output to writefunc.
|
A decorator to patch the decorated function into the given class. >>> @monkeypatch('Products.ZenModel.DataRoot.DataRoot') ... def do_nothing_at_all(self): ... print "I do nothing at all." ... >>> from Products.ZenModel.DataRoot import DataRoot >>> hasattr(DataRoot, 'do_nothing_at_all') True >>> DataRoot('dummy').do_nothing_at_all() I do nothing at all. You can also call the original within the new method using a special variable available only locally. >>> @monkeypatch('Products.ZenModel.DataRoot.DataRoot') ... def getProductName(self): ... print "Doing something additional." ... return 'core' or original(self) ... >>> from Products.ZenModel.DataRoot import DataRoot >>> DataRoot('dummy').getProductName() Doing something additional. 'core' You can also stack monkeypatches. ### @monkeypatch('Products.ZenModel.System.System') ... @monkeypatch('Products.ZenModel.DeviceGroup.DeviceGroup') ... @monkeypatch('Products.ZenModel.Location.Location') ... def foo(self): ... print "bar!" ... ### dmd.Systems.foo() bar! ### dmd.Groups.foo() bar! ### dmd.Locations.foo() bar! @param target: class @type target: class object @return: decorator function return @rtype: function |
Decorator to set headers which force browser to not cache request This is intended to decorate methods of BrowserViews.
|
Decorator to pass in request.form information as arguments to a method. These are intended to decorate methods of BrowserViews.
|
Convert some number of seconds into a human-readable string.
|
Return a human-readable string describing time relative to
|
Check to see if the TCP connection to the browser is still open. This might be used to interrupt an infinite while loop, which would preclude the thread from being destroyed even though the connection has been closed. |
Return a nice exit message that corresponds to the given exit status code
|
Dump the callback chain of a Twisted Deferred object. The chain will be displayed on standard output.
|
Load an additional ZCML file into the context, overriding others. Use with extreme care. |
|
|
__doc__
|
EXIT_CODE_MAPPING
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1.1812 on Tue Oct 11 12:51:17 2011 | http://epydoc.sourceforge.net |