Commit 8541cf19 authored by Olivier Kaufmann's avatar Olivier Kaufmann Committed by Olivier Kaufmann
Browse files

Merge remote-tracking branch 'origin/class' into class

Showing with 27 additions and 12 deletions
+27 -12
......@@ -39,7 +39,7 @@ class CompressedSizedTimedRotatingFileHandler(handlers.TimedRotatingFileHandler)
dir_name, base_name = os.path.split(self.baseFilename)
file_names = os.listdir(dir_name)
result = []
prefix = f'{base_name}.2' # we want to find a rotated file with eg filename.2017-12-12... name
prefix = f'{base_name}.2' # we want to find a rotated file with e.g. filename.2017-12-12... name
for file_name in file_names:
if file_name.startswith(prefix) and not file_name.endswith('.zip'):
result.append(file_name)
......@@ -55,4 +55,4 @@ class CompressedSizedTimedRotatingFileHandler(handlers.TimedRotatingFileHandler)
os.remove(dfn_zipped)
with zipfile.ZipFile(dfn_zipped, 'w', self.zip_mode) as f:
f.write(dfn)
os.remove(dfn)
\ No newline at end of file
os.remove(dfn)
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtdef='\e[0;0m' # Default
echo -e "${txtgrn}>>> Updating system and installing MQTT broker...${txtdef}"
sudo apt update && sudo apt upgrade
sudo apt install -y mosquitto mosquitto-clients
sudo systemctl enable mosquitto.service
echo "Broker is intalled. Starting now..."
mosquitto -v
echo -e "\n${txtgrn}>>> Broker is installed. Starting now...${txtdef}"
mosquitto -v
echo -e "\n${txtgrn}>>> Updating configuration to allow anonymous remote connections...${txtdef}"
echo "listener 1883" | sudo tee -a /etc/mosquitto/mosquitto.conf
echo "allow_anonymous true" | sudo tee -a /etc/mosquitto/mosquitto.conf
echo -e "\n${txtgrn}>>> Current configuration stored in /etc/mosquitto/mosquitto.conf is displayed below${txtdef}"
cat /etc/mosquitto/mosquitto.conf
echo -e "\n${txtylw}>>> Adapt it according to your needs!${txtdef}\n"
......@@ -68,7 +68,7 @@ def setup_loggers(mqtt=True):
return msg_logger, msg_log_filename, data_logger, data_log_filename, logging_level
def init_logging(msg_logger, logging_level, log_path, data_log_filename):
def init_logging(msg_logger, logging_level, data_log_filename):
""" This is the init sequence for the logging system """
init_logging_status = True
......
from http.server import SimpleHTTPRequestHandler, HTTPServer
import time
# import time
import os
import json
from Ohmpi import OhmPi
import threading
from ohmpi import OhmPi
# import threading
import pandas as pd
import shutil
#hostName = "0.0.0.0"
hostName = 'localhost'
serverPort = 8080
......@@ -18,6 +17,7 @@ with open('ohmpi_param.json') as json_file:
ohmpi = OhmPi(pardict)
class MyServer(SimpleHTTPRequestHandler):
# because we use SimpleHTTPRequestHandler, we do not need to implement
# the do_GET() method (if we use the BaseHTTPRequestHandler, we would need to)
......@@ -32,9 +32,10 @@ class MyServer(SimpleHTTPRequestHandler):
# self.end_headers()
# with open(os.path.join('.', self.path[1:]), 'r') as f:
# self.wfile.write(bytes(f.read(), "utf-8"))
def do_POST(self):
global ohmpiThread, status, run
# global ohmpiThread, status, run
dic = json.loads(self.rfile.read(int(self.headers['Content-Length'])))
rdic = {}
if dic['command'] == 'start':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment