Skip to content

Commit

Permalink
Fixed issue with reading config file on Win
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin24u committed Sep 24, 2020
1 parent 9ce0568 commit bcf653e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Binary file renamed installers/Win/LogMonitor_1.0.5.zip → installers/Win/LogMonitor106_Win.zip
100755 → 100644
Binary file not shown.
Binary file not shown.
32 changes: 27 additions & 5 deletions src/LogMonitor.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
#!/usr/local/bin/python3

# version 1.0.5.0
# version 1.0.6.0

########################
# Emergency mail CONFIG - when some error occures
########################
EM_HOST=""
EM_PORT=""
EM_USER=""
EM_PASSWORD=""
EM_TO=""
EM_FROM=""
EM_USE_TLS=""
#########################

########
# DO NOT CHANGE THIS PART
########

import json
import copy
import os
import re
import http.client
import urllib
import urllib.request
import smtplib
import sys
import logging.handlers
import traceback
from email.mime.text import MIMEText
from email.utils import formatdate
from email.utils import make_msgid
Expand Down Expand Up @@ -61,7 +79,6 @@ def send_email(self, subject, message):
my_logger.error("Can't send an email notification. Error: {0}.".format(str(e)))
return False


class cMail:
def __init__(self):
self.host = ""
Expand Down Expand Up @@ -185,7 +202,8 @@ def __init__(self, config_file_path):
def read_and_parse_config_file(self, config_file_path):
try:
with open(config_file_path, "r", encoding="utf-8") as config_file:
config = json.loads(config_file.read())
config_file_content = config_file.read()
config = json.loads(config_file_content.encode().decode('utf-8-sig'))
self.mail.host = config["notification"]["mail"]["host"]
if 'port' in config["notification"]["mail"]:
self.mail.port = config["notification"]["mail"]["port"]
Expand Down Expand Up @@ -215,15 +233,19 @@ def read_and_parse_config_file(self, config_file_path):

self.datasets.append(newDataset)
except:
my_logger.error("couldn't process config file")
#print (traceback.format_exception(*sys.exc_info())[-2:])
my_logger.error("couldn't process config file: " + str(traceback.format_exception(*sys.exc_info())[0:]))
email = EmailClient(EM_HOST, EM_PORT, EM_USER, EM_PASSWORD, EM_USE_TLS, EM_FROM, EM_TO)
email.send_email("couldn't process config file", str(traceback.format_exception(*sys.exc_info())[0:]))
quit(0)

def processFiles(self, files, dataset):

try:
pattern = re.compile(dataset.regexRow)
except:
my_logger.error("cannot parse regular expression in regex_row: " + dataset.regexRow)

offsets_to_update = {}

isDatasetStart = True
Expand Down

0 comments on commit bcf653e

Please sign in to comment.