Skip to content
Snippets Groups Projects
Commit b191541b authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

line len

parent 07bc9587
No related branches found
No related tags found
No related merge requests found
# coding=UTF-8 # coding=UTF-8
""" """
Allows you to preserve entire stack frame along with all variables (even pickles them). Allows you to preserve entire stack frame along with all variables (even
pickles them).
After this, you can send this report somewhere. At target, it will be unpickled in a safe way After this, you can send this report somewhere. At target, it will be unpickled
(without importing anything extra from environment). You can unpickle particular variables stored, in a safe way
(without importing anything extra from environment). You can unpickle
particular variables stored,
but that may involve an import. but that may involve an import.
Use in such a way: Use in such a way:
...@@ -70,7 +73,8 @@ class GenerationPolicy(object): ...@@ -70,7 +73,8 @@ class GenerationPolicy(object):
""" """
What compression level to use to pickle this? What compression level to use to pickle this?
:param pickledata: bytes, pickle value :param pickledata: bytes, pickle value
:return: int, 1-9, where "1" is the fastest, and "9" is the slowest, but produces best compression :return: int, 1-9, where "1" is the fastest, and "9" is the slowest,
but produces best compression
""" """
return 6 return 6
...@@ -96,12 +100,14 @@ class StoredVariable(object): ...@@ -96,12 +100,14 @@ class StoredVariable(object):
Attributes are: Attributes are:
.repr - a text representation obtained using repr .repr - a text representation obtained using repr
.typeinfo - a text representation of variable's type .typeinfo - a text representation of variable's type
.pickle - bytes with pickled (optionally processed) value, or None if not available .pickle - bytes with pickled (optionally processed) value, or None if
not available
.pickle_type - what is stored in .pickle? .pickle_type - what is stored in .pickle?
None - nothing None - nothing
"pickle" - normal Python pickle "pickle" - normal Python pickle
"pickle/gzip" - Python pickle treated with zlib.compress "pickle/gzip" - Python pickle treated with zlib.compress
"failed" - could not pickle, pickle contains a text with human-readable reason "failed" - could not pickle, pickle contains a text with
human-readable reason
""" """
__slots__ = ('repr', 'type_', 'pickle', 'pickle_type') __slots__ = ('repr', 'type_', 'pickle', 'pickle_type')
...@@ -135,9 +141,10 @@ class StoredVariable(object): ...@@ -135,9 +141,10 @@ class StoredVariable(object):
else: else:
if policy.should_compress(self.pickle): if policy.should_compress(self.pickle):
try: try:
self.pickle = zlib.compress(self.pickle, self.pickle = zlib.compress(
policy.get_compression_level( self.pickle,
self.pickle)) policy.get_compression_level(
self.pickle))
self.pickle_type = "pickle/gzip" self.pickle_type = "pickle/gzip"
except zlib.error: except zlib.error:
pass # ok, keep normal pass # ok, keep normal
...@@ -229,7 +236,8 @@ class Traceback(object): ...@@ -229,7 +236,8 @@ class Traceback(object):
def pretty_format(self): def pretty_format(self):
""" """
Return a multi-line, pretty-printed representation of all exception data. Return a multi-line, pretty-printed representation of all exception
data.
:return: text :return: text
""" """
bio = io.StringIO() bio = io.StringIO()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment