jobcontrol.utils¶
- class jobcontrol.utils.cached_property(func, name=None, doc=None)[source]¶
A decorator that converts a function into a lazy property. The function wrapped is called the first time to retrieve the result and then that calculated result is used the next time you access the value:
class Foo(object): @cached_property def foo(self): # calculate something important here return 42
The class has to have a __dict__ in order for this property to work.
- jobcontrol.utils.import_object(name)[source]¶
Import an object from a module, by name.
Parameters: name – The object name, in the package.module:name format. Returns: The imported object
- jobcontrol.utils.get_storage_from_url(url)[source]¶
Get a storage from URL.
Storages URLs are in the format:
- <scheme>://
- <class>+<scheme>:// Load <class>, pass the URL removing <class>+
- jobcontrol.utils.short_repr(obj, maxlen=50)[source]¶
Returns a “shortened representation” of an object; that is, the return value of repr(obj) limited to a certain length, with a trailing ellipsis '...' if text was truncated.
This function is mainly used in order to provide a nice representation of local variables in TracebackInfo objects
- jobcontrol.utils.trim_string(s, maxlen=1024, ellps='...')[source]¶
Trim a string to a maximum length, adding an “ellipsis” indicator if the string was trimmed
- class jobcontrol.utils.TracebackInfo[source]¶
Class used to hold information about an error traceback.
This is meant to be serialized & stored in the database, instead of a full traceback object, which is not serializable.
It holds information about:
- the exception that caused the thing to fail
- the stack frames (with file / line number, function and exact code around the point in which the exception occurred)
- a representation of the local variables for each frame.
A textual representation of the traceback information may be retrieved by using str() or unicode() on the object instance.
- class jobcontrol.utils.ProgressReport(name, current=None, total=None, status_line=None, children=None)[source]¶
Class used to represent progress reports.
It supports progress reporting on a multi-level “tree” structure; each level can have its own progress status, or it will generate it automatically by summing up values from children.