mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Merge pull request #3936 from modoboa/fix/graphics-issue-popen
Make graphics rendering work again after change to Popen execution mode.
This commit is contained in:
@@ -37,7 +37,7 @@ def smart_str(value, *args, **kwargs):
|
|||||||
return django_smart_str(value, *args, **kwargs)
|
return django_smart_str(value, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def fix_utf8_encoding(value):
|
def fix_utf8_encoding(value: str) -> str:
|
||||||
"""Fix utf-8 strings that contain utf-8 escaped characters.
|
"""Fix utf-8 strings that contain utf-8 escaped characters.
|
||||||
|
|
||||||
msgs.from_addr and msgs.subject potentialy contain badly escaped utf-8
|
msgs.from_addr and msgs.subject potentialy contain badly escaped utf-8
|
||||||
@@ -58,12 +58,13 @@ def fix_utf8_encoding(value):
|
|||||||
value = bytes_value.decode("utf-8")
|
value = bytes_value.decode("utf-8")
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
encoding = chardet.detect(bytes_value)
|
encoding = chardet.detect(bytes_value)
|
||||||
try:
|
if encoding["confidence"] > 50.0:
|
||||||
value = bytes_value.decode(encoding["encoding"], "replace")
|
try:
|
||||||
except (TypeError, UnicodeDecodeError):
|
value = bytes_value.decode(encoding["encoding"], "replace")
|
||||||
# ??? use the original value, we've done our best to try and
|
except (TypeError, UnicodeDecodeError):
|
||||||
# convert it to a clean utf-8 string.
|
# ??? use the original value, we've done our best to try and
|
||||||
pass
|
# convert it to a clean utf-8 string.
|
||||||
|
pass
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|||||||
@@ -41,16 +41,16 @@ class Curve:
|
|||||||
return [
|
return [
|
||||||
f"DEF:{self.dsname}={rrdfile}:{self.dsname}:{self.cfunc}",
|
f"DEF:{self.dsname}={rrdfile}:{self.dsname}:{self.cfunc}",
|
||||||
f"CDEF:{self.dsname}pm={self.dsname},UN,0,{self.dsname},IF,60,*",
|
f"CDEF:{self.dsname}pm={self.dsname},UN,0,{self.dsname},IF,60,*",
|
||||||
f'XPORT:{self.dsname}pm:"{self.legend}"',
|
f"XPORT:{self.dsname}pm:'{self.legend}'",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class Graphic:
|
class Graphic:
|
||||||
"""Graphic."""
|
"""Graphic."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self) -> None:
|
||||||
"""Constructor."""
|
"""Constructor."""
|
||||||
self._curves = []
|
self._curves: list[Curve] = []
|
||||||
try:
|
try:
|
||||||
order = self.order
|
order = self.order
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@@ -131,9 +131,9 @@ class Graphic:
|
|||||||
class GraphicSet:
|
class GraphicSet:
|
||||||
"""A set of graphics."""
|
"""A set of graphics."""
|
||||||
|
|
||||||
domain_selector = False
|
domain_selector: bool = False
|
||||||
title = None
|
title: str | None = None
|
||||||
_graphics = []
|
_graphics: list[Graphic] = []
|
||||||
|
|
||||||
def __init__(self, instances=None):
|
def __init__(self, instances=None):
|
||||||
if instances is None:
|
if instances is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user