Explicit UTF-8 encoding, flush temp file before upload

This commit is contained in:
Ondrej Mikle 2018-07-22 19:29:24 +02:00
parent 45aead62ad
commit 8fd2b47638
2 changed files with 4 additions and 3 deletions

View file

@ -389,11 +389,12 @@ class SpaceAPIUploader(object):
spaceApiJson["state"] = {"open": True, "lastchange": time.time()} spaceApiJson["state"] = {"open": True, "lastchange": time.time()}
with tempfile.NamedTemporaryFile() as tf: 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 localFilename = tf.name
with pysftp.Connection(self.config.sftpHost, username=self.config.sftpUsername, port=self.config.sftpPort, with pysftp.Connection(self.config.sftpHost, username=self.config.sftpUsername, port=self.config.sftpPort,
private_key=self.config.sftpKey) as sftp: private_key=self.config.sftpKey) as sftp:
sftp.timeout = 30 sftp.timeout = 15
with sftp.cd(dirname): with sftp.cd(dirname):
sftp.put(localFilename, remotepath=targetFname) sftp.put(localFilename, remotepath=targetFname)

View file

@ -4,7 +4,7 @@
"logo": "https://brmlab.cz/brmlab.png", "logo": "https://brmlab.cz/brmlab.png",
"url": "https://brmlab.cz/", "url": "https://brmlab.cz/",
"location": { "location": {
"address": "Pod Kaplickou 3149/18, 13000 Praha 3", "address": "Pod Kapličkou 3149/18, 13000 Praha 3",
"lon": 50.08346, "lon": 50.08346,
"lat": 14.48032 "lat": 14.48032
}, },