mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-06-08 08:34:00 +02:00
Fix sftp spaceapi upload, add logging for sftp upload
This commit is contained in:
parent
43e5ecaab8
commit
71566fac2a
1 changed files with 6 additions and 3 deletions
|
@ -386,7 +386,7 @@ class SpaceAPIUploader(object):
|
||||||
dirname, targetFname = os.path.split(self.config.sftpDestFile)
|
dirname, targetFname = os.path.split(self.config.sftpDestFile)
|
||||||
|
|
||||||
spaceApiJson = json.load(file("spaceapi_template.json"))
|
spaceApiJson = json.load(file("spaceapi_template.json"))
|
||||||
spaceApiJson["state"] = {"open": True, "lastchange": time.time()}
|
spaceApiJson["state"] = {"open": isOpen, "lastchange": time.time()}
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile() as tf:
|
with tempfile.NamedTemporaryFile() as tf:
|
||||||
json.dump(spaceApiJson, tf, indent=4, ensure_ascii=True, encoding='utf-8')
|
json.dump(spaceApiJson, tf, indent=4, ensure_ascii=True, encoding='utf-8')
|
||||||
|
@ -435,8 +435,11 @@ class OpenSwitchThread(threading.Thread):
|
||||||
#this will upload status always upon brmdoor start, which is better than waiting until someone
|
#this will upload status always upon brmdoor start, which is better than waiting until someone
|
||||||
#changes status with button
|
#changes status with button
|
||||||
if self.config.useStatusUpload:
|
if self.config.useStatusUpload:
|
||||||
|
isOpen = (status == self.openValue)
|
||||||
uploader = SpaceAPIUploader(self.config)
|
uploader = SpaceAPIUploader(self.config)
|
||||||
uploader.upload(status == self.openValue)
|
logging.info("Going to upload spaceAPI status, opened: %s, status: %s", isOpen, status)
|
||||||
|
uploader.upload(isOpen)
|
||||||
|
logging.info("SpaceAPI json status upload finished")
|
||||||
except Exception:
|
except Exception:
|
||||||
#we could use retrying with @retry decorator, but it's likely that it wouldn't help with
|
#we could use retrying with @retry decorator, but it's likely that it wouldn't help with
|
||||||
#current connection/upload/out of disk space or similar problem
|
#current connection/upload/out of disk space or similar problem
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue