Commit 647a6c472a2a473015dfac4c57a0f14c1da14efe

Authored by Patrick Maeght
1 parent e11721dc
Exists in dev

guitalens worker config and similator log

simulators/logconf/__init__.py 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +
  2 +import logging.config
  3 +
  4 +logging.config.fileConfig( __path__[0] + '/logging.ini')
0 5 \ No newline at end of file
... ...
simulators/logconf/logging.ini 0 → 100644
... ... @@ -0,0 +1,31 @@
  1 +[loggers]
  2 +keys=root
  3 +
  4 +[handlers]
  5 +keys=fileHandler, consoleHandler
  6 +
  7 +[formatters]
  8 +keys=simpleFormaters
  9 +
  10 +[logger_root]
  11 +level=DEBUG
  12 +handlers=fileHandler, consoleHandler
  13 +
  14 +[handler_fileHandler]
  15 +class=logging.handlers.RotatingFileHandler
  16 +level=INFO
  17 +maxBytes=1000000
  18 +backupCount=20
  19 +encoding=utf8
  20 +formatter=simpleFormaters
  21 +args=('../../logs/guitalens.log', 'a')
  22 +
  23 +[handler_consoleHandler]
  24 +class=StreamHandler
  25 +level=INFO
  26 +formatter=simpleFormaters
  27 +args=(sys.stdout,)
  28 +
  29 +[formatter_simpleFormaters]
  30 +format=%(asctime)s - %(module)s:%(name)s:%(lineno)s - %(levelname)s - %(message)s
  31 +datefmt=
... ...
simulators/plc/guitalens_worker.py
... ... @@ -6,9 +6,16 @@ import time
6 6 from datetime import datetime
7 7 import urllib.request
8 8 import json
9   -
  9 +import os, sys
  10 +print(os.path.abspath("."))
  11 +_path = os.path.abspath("..")
  12 +sys.path.insert(0, _path )
  13 +import logconf
10 14 logger = logging.getLogger(__name__)
11   -
  15 +"""logger = logging.getLogger(__name__)
  16 +logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
  17 +logging.FileHandler('../../logs/guitalens.log', mode='w')
  18 +logger.setLevel('DEBUG')"""
12 19  
13 20 class WorkerState(object):
14 21 """
... ... @@ -60,14 +67,14 @@ class WorkerUrl(threading.Thread):
60 67 self.shared.status_time = str(datetime.now())
61 68 except Exception as e:
62 69 logger.info('Worker init error ' + str(e))
63   - self.shared.status = 'wait'
  70 + #self.shared.status = 'wait'
64 71  
65 72 def try_work(self):
66 73 try:
67 74 self.work()
68 75 except Exception as e:
69 76 logger.info('Worker error ' + str(e))
70   - self.shared.status = 'wait'
  77 + self.shared.status = 'init'
71 78  
72 79 def work(self):
73 80 #logger.info('Working '+ str(self.item))
... ...
src/monitoring/plc_checker.py
1 1 import json
2 2 import logging
3 3 logger = logging.getLogger(__name__)
  4 +logger.setLevel('DEBUG')
4 5  
5 6  
6 7  
... ... @@ -136,10 +137,7 @@ class PlcChecker(object):
136 137 self.device_name = self.get_key(device, "device_name")
137 138 self.device_type = self.get_key(device, "device_type")
138 139 self.serial_number = self.get_key(device, "serial_number")
139   - try:
140   - self.valid = not bool(int(self.get_key(device, "error_code")))
141   - except:
142   - self.valid = False
  140 + self.valid = True if self.get_key(device, "error_code") == '0' else False
143 141 for device_values in device["device_values"]:
144 142 sensor = []
145 143 sensor.append(self.device_name)
... ...