2019-07-27 16:51:56 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2022-03-06 11:55:29 +01:00
|
|
|
# file: apistatusd.py
|
2019-07-27 16:51:56 +02:00
|
|
|
# date: 26.07.2019
|
|
|
|
# email: berhsi@web.de
|
|
|
|
|
2020-07-09 12:08:06 +02:00
|
|
|
# Status server, listening for door status updates. The IPv4 address and port
|
|
|
|
# to listen on are configurable, by default localhost:10001 is used. The
|
|
|
|
# connection is secured by TLS and client side authentication.
|
2019-07-27 16:51:56 +02:00
|
|
|
|
2020-07-09 12:08:06 +02:00
|
|
|
import json
|
|
|
|
import logging
|
|
|
|
import os
|
2019-07-27 16:51:56 +02:00
|
|
|
import socket
|
2019-07-29 18:32:27 +02:00
|
|
|
import ssl
|
2020-07-09 12:08:06 +02:00
|
|
|
import sys
|
2022-07-12 21:57:20 +02:00
|
|
|
import threading
|
2022-07-10 18:17:33 +02:00
|
|
|
from mastodon import Mastodon
|
2022-07-10 19:38:29 +02:00
|
|
|
from time import time, localtime, strftime, sleep
|
2020-07-09 12:08:06 +02:00
|
|
|
import configparser
|
2019-07-27 16:51:56 +02:00
|
|
|
|
|
|
|
|
2022-07-12 21:57:20 +02:00
|
|
|
class Toot(threading.Thread):
|
|
|
|
'''
|
|
|
|
The thread to toot the status to mastodon.
|
|
|
|
'''
|
|
|
|
def __init__(self, status, timestamp, config):
|
|
|
|
'''
|
|
|
|
param1: boolean
|
|
|
|
param2: integer
|
|
|
|
param3: dictionary
|
|
|
|
'''
|
|
|
|
threading.Thread.__init__(self)
|
|
|
|
self.status = status
|
|
|
|
self.config = config
|
|
|
|
self.timestamp = timestamp
|
|
|
|
self.mastodon = Mastodon(api_base_url = self.config['mastodon']['host'],
|
|
|
|
access_token = self.config['mastodon']['token'])
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
'''
|
|
|
|
return: boolean
|
|
|
|
send_toot(status, timestamp,
|
|
|
|
config['mastodon']['host'],
|
|
|
|
config['mastodon']['token'])
|
|
|
|
'''
|
|
|
|
msg = None
|
|
|
|
timeformat = '%d.%m.%Y %H:%M Uhr'
|
|
|
|
timestring = strftime(timeformat, localtime(self.timestamp))
|
|
|
|
|
|
|
|
if self.status not in (True, False):
|
|
|
|
logging.error('Invalid status to toot')
|
|
|
|
timestring = strftime(timeformat, localtime(self.timestamp))
|
|
|
|
|
|
|
|
logging.debug('Try to toot status to {}'.format(host))
|
|
|
|
if self.status == True:
|
|
|
|
msg = 'The krautspace is open since: {}'.format(timestring)
|
|
|
|
elif self.status == False:
|
|
|
|
msg = 'The krautspace is closed since: {}'.format(timestring)
|
|
|
|
logging.debug('Send message: {}'.format(msg))
|
|
|
|
try:
|
|
|
|
mastodon = Mastodon(api_base_url = host,
|
|
|
|
access_token = token)
|
|
|
|
mastodon.toot(mag)
|
|
|
|
except Exception as e:
|
|
|
|
logging.error('Failed to toot status')
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def send_toot(self):
|
|
|
|
'''
|
|
|
|
Starts the thread
|
|
|
|
'''
|
|
|
|
send_toot(status, timestamp,
|
|
|
|
config['mastodon']['host'],
|
|
|
|
config['mastodon']['token'])
|
|
|
|
|
|
|
|
|
2019-07-30 22:06:07 +02:00
|
|
|
def certs_readable(config):
|
2019-07-30 22:20:45 +02:00
|
|
|
'''
|
2019-09-19 10:21:33 +02:00
|
|
|
checks at start, if the needed certificates defined (no nullstring) and
|
|
|
|
readable.
|
2019-07-30 22:20:45 +02:00
|
|
|
param 1: dictionary
|
|
|
|
return: boolean
|
|
|
|
'''
|
2020-07-09 12:08:06 +02:00
|
|
|
for i in (config['server']['key'], config['server']['cert'],
|
|
|
|
config['client']['cert']):
|
2019-09-19 10:21:33 +02:00
|
|
|
if i == '' or os.access(i, os.R_OK) is False:
|
2020-07-09 12:08:06 +02:00
|
|
|
logging.error('Cannot read {}'.format(i))
|
2019-07-30 22:06:07 +02:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2020-07-09 12:08:06 +02:00
|
|
|
def print_config(config):
|
2019-07-29 18:32:27 +02:00
|
|
|
'''
|
2020-07-09 12:08:06 +02:00
|
|
|
Logs the config with level debug.
|
2019-07-27 16:51:56 +02:00
|
|
|
'''
|
|
|
|
logging.debug('Using config:')
|
2020-07-09 12:08:06 +02:00
|
|
|
for section in config.sections():
|
|
|
|
logging.debug('Section {}'.format(section))
|
|
|
|
for i in config[section]:
|
|
|
|
logging.debug(' {}: {}'.format(i, config[section][i]))
|
2019-07-27 16:51:56 +02:00
|
|
|
|
2019-09-10 15:33:27 +02:00
|
|
|
def print_ciphers(cipherlist):
|
2019-09-13 10:29:38 +02:00
|
|
|
'''
|
2020-07-09 12:08:06 +02:00
|
|
|
Prints the list of allowed ciphers.
|
2019-09-13 10:29:38 +02:00
|
|
|
param1: dictionary
|
|
|
|
return: boolean
|
|
|
|
'''
|
2022-03-11 13:28:03 +01:00
|
|
|
logging.debug('Available ciphers')
|
2019-09-10 15:33:27 +02:00
|
|
|
for i in cipherlist:
|
|
|
|
for j in i.keys():
|
2022-03-11 13:28:03 +01:00
|
|
|
if j in ('name', 'protocol'):
|
|
|
|
logging.debug('{}: {}'.format(j, i[j]))
|
2019-09-10 15:33:27 +02:00
|
|
|
|
2022-03-11 13:28:03 +01:00
|
|
|
def print_context(ctx):
|
|
|
|
'''
|
|
|
|
Prints the ssl settings for the given ssl context.
|
|
|
|
param1: context object
|
|
|
|
'''
|
|
|
|
logging.debug('----------- context ----------------')
|
|
|
|
logging.debug('Minimum version ssl: {}'.format(ctx.minimum_version))
|
|
|
|
logging.debug('Maximum version ssl: {}'.format(ctx.maximum_version))
|
|
|
|
logging.debug('SSL options enabled: {}'.format(ctx.options))
|
|
|
|
logging.debug('Protocol: {}'.format(ctx.protocol))
|
|
|
|
logging.debug('Verify flags certificates: {}'.format(ctx.verify_flags))
|
|
|
|
logging.debug('Verify mode: {}'.format(ctx.verify_mode))
|
|
|
|
print_ciphers(ctx.get_ciphers())
|
|
|
|
logging.debug('------------------------------------')
|
2019-09-10 15:33:27 +02:00
|
|
|
|
2019-07-29 18:32:27 +02:00
|
|
|
def display_peercert(cert):
|
2019-09-13 10:29:38 +02:00
|
|
|
'''
|
2020-07-09 12:08:06 +02:00
|
|
|
Displays the values of a given certificate.
|
2022-03-11 13:28:03 +01:00
|
|
|
param1: dictionary or none
|
2019-09-13 10:29:38 +02:00
|
|
|
'''
|
2022-03-11 13:28:03 +01:00
|
|
|
if cert == None:
|
|
|
|
logging.debug('Peer does not offer a certificate')
|
|
|
|
elif len(cert) == 0:
|
|
|
|
logging.debug('Peer certificate was not valid')
|
|
|
|
else:
|
|
|
|
logging.debug('Peer certificate commonName: {}'.format(
|
|
|
|
cert['subject'][5][0][1]))
|
|
|
|
logging.debug('Peer certificate serialNumber: {}'.format(
|
|
|
|
cert['serialNumber']))
|
|
|
|
logging.debug('Peer certificate notBefore: {}'.format(
|
|
|
|
cert['notBefore']))
|
|
|
|
logging.debug('Peer certificate notAfter: {}'.format(
|
|
|
|
cert['notAfter']))
|
2019-07-29 18:32:27 +02:00
|
|
|
|
2019-07-27 16:51:56 +02:00
|
|
|
def receive_buffer_is_valid(raw_data):
|
|
|
|
'''
|
2020-07-09 12:08:06 +02:00
|
|
|
Checks validity of the received buffer contents.
|
2022-03-06 11:55:29 +01:00
|
|
|
param 1: byte object
|
2019-07-27 16:51:56 +02:00
|
|
|
return: boolean
|
|
|
|
'''
|
2022-03-06 11:55:29 +01:00
|
|
|
if raw_data.decode('utf-8', 'strict') in ('0', '1'):
|
2019-07-27 16:51:56 +02:00
|
|
|
logging.debug('Argument is valid: {}'.format(raw_data))
|
|
|
|
return True
|
2020-07-09 12:08:06 +02:00
|
|
|
logging.debug('Argument is not valid: {}'.format(raw_data))
|
|
|
|
return False
|
2019-07-27 16:51:56 +02:00
|
|
|
|
|
|
|
|
2022-07-10 18:17:33 +02:00
|
|
|
def change_status(status, timestamp, filename):
|
2019-07-27 16:51:56 +02:00
|
|
|
'''
|
2020-07-09 12:08:06 +02:00
|
|
|
Write the new status together with a timestamp into the Space API JSON.
|
2022-03-06 11:55:29 +01:00
|
|
|
param 1: byte object
|
2019-07-27 16:51:56 +02:00
|
|
|
param 2: string
|
|
|
|
return: boolean
|
|
|
|
'''
|
|
|
|
|
|
|
|
logging.debug('Change status API')
|
2020-07-09 12:08:06 +02:00
|
|
|
# todo: use walrus operator := when migrating to python >= 3.8
|
2022-07-10 18:17:33 +02:00
|
|
|
data = read_api(filename)
|
2020-07-09 12:08:06 +02:00
|
|
|
if data is False:
|
|
|
|
return False
|
|
|
|
|
2022-07-10 18:17:33 +02:00
|
|
|
if os.access(filename, os.W_OK):
|
2020-07-09 12:08:06 +02:00
|
|
|
logging.debug('API file is writable')
|
2022-07-10 18:17:33 +02:00
|
|
|
with open(filename, 'w') as api_file:
|
2020-07-09 12:08:06 +02:00
|
|
|
logging.debug('API file open successfull')
|
|
|
|
data["state"]["open"] = status
|
|
|
|
data["state"]["lastchange"] = timestamp
|
|
|
|
try:
|
|
|
|
json.dump(data, api_file, indent=4)
|
|
|
|
except Exception as e:
|
|
|
|
logging.error('Failed to change API file')
|
|
|
|
logging.error('{}'.format(e))
|
2022-03-06 11:55:29 +01:00
|
|
|
return False
|
2020-07-09 12:08:06 +02:00
|
|
|
logging.debug('API file changed')
|
|
|
|
else:
|
|
|
|
logging.error('API file is not writable. Wrong permissions?')
|
|
|
|
return False
|
2022-07-10 18:17:33 +02:00
|
|
|
logging.info('API file successfull changed to {}'.format(status))
|
2020-07-09 12:08:06 +02:00
|
|
|
return True
|
2019-07-27 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
def read_api(api):
|
|
|
|
'''
|
2020-07-09 12:08:06 +02:00
|
|
|
Reads the Space API JSON into a dict. Returns the dict on success and
|
|
|
|
False on failure.
|
|
|
|
|
2019-07-27 16:51:56 +02:00
|
|
|
param 1: string
|
2020-07-09 12:08:06 +02:00
|
|
|
return: dict or boolean
|
2019-07-27 16:51:56 +02:00
|
|
|
'''
|
2019-07-27 18:58:51 +02:00
|
|
|
logging.debug('Open API file: {}'.format(api))
|
2020-07-09 12:08:06 +02:00
|
|
|
|
|
|
|
# return early if the API JSON cannot be read
|
|
|
|
if not os.access(api, os.R_OK):
|
|
|
|
logging.error('Failed to read API file')
|
|
|
|
return False
|
|
|
|
|
|
|
|
logging.debug('API is readable')
|
|
|
|
with open(api, 'r') as api_file:
|
|
|
|
logging.debug('API file successfully opened')
|
|
|
|
try:
|
|
|
|
api_json_data = json.load(api_file)
|
|
|
|
logging.debug('API file read successfull')
|
|
|
|
except Exception as e:
|
|
|
|
logging.error('Failed to read API file: {}'.format(e))
|
|
|
|
return False
|
|
|
|
return api_json_data
|
2019-09-19 10:21:33 +02:00
|
|
|
|
2019-07-27 16:51:56 +02:00
|
|
|
|
2022-07-10 18:17:33 +02:00
|
|
|
def get_status_and_time(raw_data):
|
2019-07-27 16:51:56 +02:00
|
|
|
'''
|
|
|
|
Create a timestamp, changes the value of the given byte into a string
|
|
|
|
and returns both.
|
2022-03-06 11:55:29 +01:00
|
|
|
param 1: byte object
|
2022-07-10 19:38:29 +02:00
|
|
|
return: tuple (boolean, integer)
|
2019-07-27 16:51:56 +02:00
|
|
|
'''
|
2022-03-06 11:55:29 +01:00
|
|
|
status = True if raw_data.decode('utf-8', 'strict') == '1' else False
|
2020-11-22 22:35:27 +01:00
|
|
|
timestamp = int(str(time()).split('.')[0])
|
2020-07-09 12:08:06 +02:00
|
|
|
|
2019-09-19 10:21:33 +02:00
|
|
|
logging.debug('Set values for timestamp: {} and status: {}'.format(
|
2020-11-22 22:35:27 +01:00
|
|
|
str(timestamp), str(status)))
|
2019-07-27 16:51:56 +02:00
|
|
|
return (status, timestamp)
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
'''
|
2020-07-09 12:08:06 +02:00
|
|
|
The main function - open a socket, create a ssl context, load certs and
|
|
|
|
listen for connections. At SSL context we set only one available cipher
|
2019-09-19 10:21:33 +02:00
|
|
|
suite and disable compression.
|
2020-07-09 12:08:06 +02:00
|
|
|
OP_NO_COMPRESSION: prevention against CRIME attack
|
|
|
|
OP_DONT_ISERT_EMPTY_FRAGMENTS: prevention agains CBC 4 attack
|
2019-09-19 10:21:33 +02:00
|
|
|
(cve-2011-3389)
|
2019-07-27 16:51:56 +02:00
|
|
|
'''
|
2019-09-11 21:24:28 +02:00
|
|
|
|
2022-03-06 11:55:29 +01:00
|
|
|
answer = '3'.encode(encoding='utf-8', errors='strict')
|
2019-09-11 21:24:28 +02:00
|
|
|
loglevel = logging.WARNING
|
|
|
|
formatstring = '%(asctime)s: %(levelname)s: %(message)s'
|
|
|
|
logging.basicConfig(format=formatstring, level=loglevel)
|
|
|
|
|
2020-07-09 12:08:06 +02:00
|
|
|
default_config = {
|
|
|
|
'general': {
|
|
|
|
'timeout': 3.0,
|
|
|
|
'loglevel': 'warning'
|
|
|
|
},
|
|
|
|
'server': {
|
|
|
|
'host': 'localhost',
|
|
|
|
'port': 10001,
|
|
|
|
'cert': './certs/server.crt',
|
|
|
|
'key': './certs/server.key'
|
|
|
|
},
|
|
|
|
'client': {
|
|
|
|
'cert': './certs/client.crt'
|
|
|
|
},
|
|
|
|
'api': {
|
|
|
|
'api': './api',
|
|
|
|
'template': './api_template'
|
2022-07-10 18:17:33 +02:00
|
|
|
},
|
|
|
|
'mastodon': {
|
|
|
|
'send': 'false',
|
|
|
|
'host': 'localhost',
|
|
|
|
'token': 'aaaaa-bbbbb-ccccc-ddddd-eeeee'
|
2019-07-27 16:51:56 +02:00
|
|
|
}
|
2020-07-09 12:08:06 +02:00
|
|
|
}
|
2022-03-06 11:55:29 +01:00
|
|
|
configfile = './apistatusd.conf'
|
2020-07-09 12:08:06 +02:00
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config.read_dict(default_config)
|
|
|
|
if not config.read(configfile):
|
|
|
|
logging.warning('Configuration file %s not found or not readable. Using default values.',
|
|
|
|
configfile)
|
2019-09-11 21:24:28 +02:00
|
|
|
|
2020-07-09 12:08:06 +02:00
|
|
|
logger = logging.getLogger()
|
|
|
|
if not config['general']['loglevel'] in ('critical', 'error', 'warning', 'info', 'debug'):
|
|
|
|
logging.warning('Invalid loglevel %s given. Using default level %s.',
|
|
|
|
config['general']['loglevel'],
|
|
|
|
default_config['general']['loglevel'])
|
|
|
|
config.set('general', 'loglevel', default_config['general']['loglevel'])
|
2019-07-27 16:51:56 +02:00
|
|
|
|
2020-07-09 12:08:06 +02:00
|
|
|
logger.setLevel(config['general']['loglevel'].upper())
|
2019-09-17 19:07:07 +02:00
|
|
|
|
2020-07-09 12:08:06 +02:00
|
|
|
print_config(config)
|
|
|
|
|
|
|
|
# todo: zertifikate sollten nur lesbar sein!
|
|
|
|
if not certs_readable(config):
|
2019-07-30 22:06:07 +02:00
|
|
|
logging.error('Cert check failed\nExit')
|
2020-07-09 12:08:06 +02:00
|
|
|
sys.exit(1)
|
2019-07-30 22:06:07 +02:00
|
|
|
|
2019-07-29 18:32:27 +02:00
|
|
|
context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
|
2022-04-06 10:20:06 +02:00
|
|
|
context.verify_mode = ssl.CERT_OPTIONAL
|
2020-07-09 12:08:06 +02:00
|
|
|
context.load_cert_chain(certfile=config['server']['cert'],
|
|
|
|
keyfile=config['server']['key'])
|
|
|
|
context.load_verify_locations(cafile=config['client']['cert'])
|
2019-09-10 15:33:27 +02:00
|
|
|
context.options = ssl.OP_CIPHER_SERVER_PREFERENCE
|
2020-07-09 12:08:06 +02:00
|
|
|
# ensure, compression is disabled (disabled by default anyway at the moment)
|
|
|
|
context.options |= ssl.OP_NO_COMPRESSION
|
2019-07-29 18:32:27 +02:00
|
|
|
logging.debug('SSL context created')
|
2022-03-11 13:28:03 +01:00
|
|
|
print_context(context)
|
2019-07-29 18:32:27 +02:00
|
|
|
|
2019-07-27 16:51:56 +02:00
|
|
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) as mySocket:
|
|
|
|
logging.debug('Socket created')
|
2020-10-22 16:07:16 +02:00
|
|
|
mySocket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
|
|
|
keep = mySocket.getsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE)
|
2020-11-22 22:35:27 +01:00
|
|
|
logging.debug('Socket keepalive: {}'.format(keep))
|
2019-07-27 16:51:56 +02:00
|
|
|
try:
|
2020-07-09 12:08:06 +02:00
|
|
|
mySocket.bind((config['server']['host'], int(config['server']['port'])))
|
2019-07-27 16:51:56 +02:00
|
|
|
mySocket.listen(5)
|
|
|
|
except Exception as e:
|
2020-07-09 12:08:06 +02:00
|
|
|
logging.error('Unable to bind and listen')
|
2019-07-27 16:51:56 +02:00
|
|
|
logging.error('{}'.format(e))
|
2020-07-09 12:08:06 +02:00
|
|
|
sys.exit(1)
|
2020-07-09 16:09:14 +02:00
|
|
|
logging.info('Listening on {} at Port {}'.format(config['server']['host'],
|
|
|
|
config['server']['port']))
|
2020-07-09 12:08:06 +02:00
|
|
|
|
2019-07-27 16:51:56 +02:00
|
|
|
while True:
|
|
|
|
try:
|
2019-07-29 18:32:27 +02:00
|
|
|
fromSocket, fromAddr = mySocket.accept()
|
2020-07-09 12:08:06 +02:00
|
|
|
logging.info('Client connected: {}:{}'.format(fromAddr[0], fromAddr[1]))
|
2019-07-27 16:51:56 +02:00
|
|
|
try:
|
2020-07-09 12:08:06 +02:00
|
|
|
fromSocket.settimeout(float(config['general']['timeout']))
|
2019-09-19 10:21:33 +02:00
|
|
|
logging.debug('Connection timeout set to {}'.format(
|
2020-07-09 12:08:06 +02:00
|
|
|
config['general']['timeout']))
|
2019-09-19 10:21:33 +02:00
|
|
|
except Exception:
|
2020-07-09 12:08:06 +02:00
|
|
|
logging.error('Cannot set timeout to {}'.format(
|
|
|
|
config['general']['timeout']))
|
2019-07-29 18:32:27 +02:00
|
|
|
try:
|
2019-09-19 10:21:33 +02:00
|
|
|
conn = context.wrap_socket(fromSocket, server_side=True)
|
2020-07-09 16:09:14 +02:00
|
|
|
conn.settimeout(float(config['general']['timeout']))
|
2019-09-14 14:01:52 +02:00
|
|
|
except socket.timeout:
|
|
|
|
logging.error('Socket timeout')
|
2022-03-11 13:28:03 +01:00
|
|
|
continue
|
2019-07-29 18:32:27 +02:00
|
|
|
except Exception as e:
|
2019-09-14 14:01:52 +02:00
|
|
|
logging.error('Connection failed: {}'.format(e))
|
2022-03-11 13:28:03 +01:00
|
|
|
continue
|
2020-07-09 20:09:36 +02:00
|
|
|
logging.info('Connection established')
|
2022-03-11 13:28:03 +01:00
|
|
|
try:
|
|
|
|
cert = conn.getpeercert(binary_form=False)
|
|
|
|
display_peercert(cert)
|
|
|
|
except ValueError:
|
|
|
|
logging.debug('SSL handshake has not been done yet')
|
|
|
|
except Exception as e:
|
|
|
|
logging.debug('Unexpected error: {}'.format(e))
|
2020-07-09 12:08:06 +02:00
|
|
|
|
2019-07-27 16:51:56 +02:00
|
|
|
raw_data = conn.recv(1)
|
2019-09-19 10:21:33 +02:00
|
|
|
if receive_buffer_is_valid(raw_data) is True:
|
2022-07-10 18:17:33 +02:00
|
|
|
status, timestamp = get_status_and_time(raw_data)
|
|
|
|
if change_status(status, timestamp, config['api']['api']) is True:
|
2022-03-06 11:55:29 +01:00
|
|
|
answer = raw_data
|
2022-07-10 18:17:33 +02:00
|
|
|
if config['mastodon']['send'].lower() == 'true':
|
2022-07-12 21:57:20 +02:00
|
|
|
toot_threat = Toot(status, timestamp, config)
|
|
|
|
toot_thread.run()
|
|
|
|
logging.debug('Toot thread started')
|
2022-07-10 18:17:33 +02:00
|
|
|
else: logging.debug('Toot is set to false')
|
2022-03-06 11:55:29 +01:00
|
|
|
if conn:
|
|
|
|
logging.debug('Send {} back'.format(raw_data))
|
|
|
|
conn.send(answer)
|
2019-09-19 10:21:33 +02:00
|
|
|
sleep(0.1) # protection against dos
|
2019-07-27 16:51:56 +02:00
|
|
|
except KeyboardInterrupt:
|
2020-09-08 17:39:39 +02:00
|
|
|
logging.info('Keyboard interrupt received')
|
2020-07-09 12:08:06 +02:00
|
|
|
sys.exit(1)
|
2019-07-27 16:51:56 +02:00
|
|
|
except Exception as e:
|
|
|
|
logging.error('{}'.format(e))
|
2019-07-29 18:32:27 +02:00
|
|
|
continue
|
2019-08-02 14:20:08 +02:00
|
|
|
return 0
|
2019-07-27 16:51:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|