configurable idling time

This commit is contained in:
Tobias Brunner 2018-01-02 17:58:35 +01:00
parent 1e0e27d08e
commit 49c7d074cb
3 changed files with 7 additions and 9 deletions

View File

@ -20,8 +20,6 @@ Einsätze correctly into [Lodur](https://www.lodur.ch/lodur.html).
### Version 1
* IMAP IDLE
* Parse Form
* README / Docs
Before version 1 can be tagged, it must have processed at least 5 real
@ -34,6 +32,7 @@ Einsätze!
### Future versions
* Generalize
* IMAP Idle
* Display PDF on Dashboard
* Send statistics to InfluxDB
* Webapp to see what's going on

View File

@ -48,9 +48,9 @@ class MQTTClient:
self.mqtt_client.publish(topic + 'bemerkungen', pdf_data['bemerkungen'])
# Publish the PDF blob
#pdf_fh = open(pdf_file, 'rb')
#pdf_binary = pdf_fh.read()
#self.mqtt_client.publish(topic + 'pdf', bytes(pdf_binary))
pdf_fh = open(pdf_file, 'rb')
pdf_binary = pdf_fh.read()
self.mqtt_client.publish(topic + 'pdf', bytes(pdf_binary))
except IndexError as err:
self.logger.info('[%s] Cannot publish information: %s', f_id, err)
elif f_type == 'Einsatzprotokoll':

View File

@ -16,15 +16,13 @@ from library.mqtt import MQTTClient
from library.pdf_extract import PDFHandling
from library.webdav import WebDav
# TODO replace by IMAP idle
_INTERVAL = 10
# Configuration
load_dotenv(find_dotenv())
IMAP_SERVER = os.getenv("IMAP_SERVER")
IMAP_USERNAME = os.getenv("IMAP_USERNAME")
IMAP_PASSWORD = os.getenv("IMAP_PASSWORD")
IMAP_MAILBOX = os.getenv("IMAP_MAILBOX", "INBOX")
IMAP_CHECK_INTERVAL = os.getenv("IMAP_CHECK_INTERVAL", "10")
WEBDAV_URL = os.getenv("WEBDAV_URL")
WEBDAV_USERNAME = os.getenv("WEBDAV_USERNAME")
WEBDAV_PASSWORD = os.getenv("WEBDAV_PASSWORD")
@ -176,7 +174,8 @@ def main():
# send heartbeat
requests.get(HEARTBEAT_URL)
# repeat every
time.sleep(_INTERVAL)
logger.info('Waiting %s seconds until next check', IMAP_CHECK_INTERVAL)
time.sleep(int(IMAP_CHECK_INTERVAL))
if __name__ == '__main__':
try: