From 8fd2b47638e3a7188eb3a9b235113ae9b54e3c24 Mon Sep 17 00:00:00 2001 From: Ondrej Mikle Date: Sun, 22 Jul 2018 19:29:24 +0200 Subject: [PATCH] Explicit UTF-8 encoding, flush temp file before upload --- brmdoor_nfc_daemon.py | 5 +++-- spaceapi_template.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/brmdoor_nfc_daemon.py b/brmdoor_nfc_daemon.py index 61b5635..ec5dbe2 100755 --- a/brmdoor_nfc_daemon.py +++ b/brmdoor_nfc_daemon.py @@ -389,11 +389,12 @@ class SpaceAPIUploader(object): spaceApiJson["state"] = {"open": True, "lastchange": time.time()} with tempfile.NamedTemporaryFile() as tf: - json.dump(spaceApiJson, tf) + json.dump(spaceApiJson, tf, indent=4, ensure_ascii=True, encoding='utf-8') + tf.flush() localFilename = tf.name with pysftp.Connection(self.config.sftpHost, username=self.config.sftpUsername, port=self.config.sftpPort, private_key=self.config.sftpKey) as sftp: - sftp.timeout = 30 + sftp.timeout = 15 with sftp.cd(dirname): sftp.put(localFilename, remotepath=targetFname) diff --git a/spaceapi_template.json b/spaceapi_template.json index d20b500..2392582 100644 --- a/spaceapi_template.json +++ b/spaceapi_template.json @@ -4,7 +4,7 @@ "logo": "https://brmlab.cz/brmlab.png", "url": "https://brmlab.cz/", "location": { - "address": "Pod Kaplickou 3149/18, 13000 Praha 3", + "address": "Pod Kapličkou 3149/18, 13000 Praha 3", "lon": 50.08346, "lat": 14.48032 },