mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-25 08:28:23 +01:00
fixed issues with xml upload in case of non compatible characters
This commit is contained in:
parent
f8bd353f02
commit
ee2acda2e3
2 changed files with 5 additions and 4 deletions
|
@ -1 +1 @@
|
||||||
__version__ = "4.0.0.40"
|
__version__ = "4.0.0.41"
|
||||||
|
|
|
@ -23,6 +23,7 @@ from ..api.step import StepMove, StepResult, StepState
|
||||||
import re
|
import re
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
|
|
||||||
class UploadController:
|
class UploadController:
|
||||||
|
|
||||||
def __init__(self, cbpi):
|
def __init__(self, cbpi):
|
||||||
|
@ -110,7 +111,7 @@ class UploadController:
|
||||||
|
|
||||||
if content_type == 'text/xml':
|
if content_type == 'text/xml':
|
||||||
try:
|
try:
|
||||||
beer_xml = recipe_file.read().decode()
|
beer_xml = recipe_file.read().decode('utf-8','replace')
|
||||||
if recipe_file and self.allowed_file(filename, 'xml'):
|
if recipe_file and self.allowed_file(filename, 'xml'):
|
||||||
self.path = os.path.join(".", 'config', "upload", "beer.xml")
|
self.path = os.path.join(".", 'config', "upload", "beer.xml")
|
||||||
|
|
||||||
|
@ -118,8 +119,8 @@ class UploadController:
|
||||||
f.write(beer_xml)
|
f.write(beer_xml)
|
||||||
f.close()
|
f.close()
|
||||||
self.cbpi.notify("Success", "XML Recipe {} has been uploaded".format(filename), NotificationType.SUCCESS)
|
self.cbpi.notify("Success", "XML Recipe {} has been uploaded".format(filename), NotificationType.SUCCESS)
|
||||||
except:
|
except Exception as e:
|
||||||
self.cbpi.notify("Error" "XML Recipe upload failed", NotificationType.ERROR)
|
self.cbpi.notify("Error" "XML Recipe upload failed: {}".format(e), NotificationType.ERROR)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif content_type == 'application/octet-stream':
|
elif content_type == 'application/octet-stream':
|
||||||
|
|
Loading…
Reference in a new issue