Add Monitoring files in Python and Mui/React
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
import os
|
||||
import time
|
||||
from uuid import uuid4
|
||||
import uuid
|
||||
from flask import jsonify
|
||||
import json
|
||||
|
||||
from marshmallow import EXCLUDE
|
||||
#from vrpmdvcreatemoncmd import VRPMDV_CreateMonCmd
|
||||
#from vrpmdvcreatemonschema import VRPMDV_CreateMonSchema
|
||||
#from vrpmdvdeletemoncmd import VRPMDV_DeleteMonCmd
|
||||
#from vrpmdvdeletemonschema import VRPMDV_DeleteMonSchema
|
||||
from vrpmdvmonfilesschema import VRPMDV_MonfilesSchema
|
||||
from vrpmdvmonitoring import VRPMDV_Monitoring
|
||||
from vrpmdvmonitoringschema import VRPMDV_MonitoringSchema
|
||||
from vrpmdvmonreqschema import VRPMDV_MonReqSchema
|
||||
from vrpmdvntlink import trySend
|
||||
# from vrpmdvntlink import trySend
|
||||
|
||||
from extensions.rt_service import rt_service as rts
|
||||
from vrpmdvmonitoringState import VRPMDVMonitoringState
|
||||
@@ -25,10 +29,13 @@ class VRPMDV_Data:
|
||||
format = "%(asctime)s: %(message)s"
|
||||
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
|
||||
self.mons:list = []
|
||||
self.rtservice = rts.RT_Service()
|
||||
self.rtservice.initCoproFW("home/root/elffile","zephyr_openamp_rsc_table.elf")
|
||||
#TODO ML: uncomment this lines
|
||||
self.rtservice = None #rts.RT_Service()
|
||||
if (self.rtservice != None):
|
||||
self.rtservice.initCoproFW("home/root/elffile","zephyr_openamp_rsc_table.elf")
|
||||
self.logTask = None #createCoproLoggingTask()
|
||||
self.loaded = self.loadFile()
|
||||
self.monfilespath = '/home/markus/monfiles/'
|
||||
#start the monitorings
|
||||
time.sleep(1)
|
||||
self.startMons();
|
||||
@@ -341,3 +348,66 @@ class VRPMDV_Data:
|
||||
except:
|
||||
return "no Item found"
|
||||
|
||||
def getMonitoring2files(self):
|
||||
#search in the given directory
|
||||
dirs = [d for d in os.listdir(self.monfilespath) if os.path.isdir(d)]
|
||||
#return for the filter
|
||||
|
||||
|
||||
def getMonitoringfiles(self, id):
|
||||
#search in the given directory
|
||||
dirname = os.path.dirname(self.monfilespath)
|
||||
dirs = []
|
||||
for d in os.listdir(dirname) :
|
||||
# if os.path.isdir(d) :
|
||||
dirs.append(d)
|
||||
|
||||
#dirs = [d for d in os.listdir(dirname) if os.path.isdir(d)]
|
||||
id = '0'
|
||||
#currently we return the first one
|
||||
for dir in dirs:
|
||||
mon = self.findMonitoring(dir)
|
||||
id = mon.id
|
||||
|
||||
|
||||
#TODO ML change to array
|
||||
#for file in files:
|
||||
filename = self.monfilespath + str(id) + '/'
|
||||
monfiles = self.loadMonfiles(filename)
|
||||
schema = VRPMDV_MonfilesSchema()
|
||||
result = schema.dumps(monfiles, many=True)
|
||||
return result
|
||||
|
||||
def loadMonfiles(self, id):
|
||||
#files = [f for f in os.listdir() if os.path.isfile(f)]
|
||||
completeMonPath = os.path.dirname(id)
|
||||
monfiles = []
|
||||
for f in os.listdir(completeMonPath) :
|
||||
# if (os.path.isfile(f)) :
|
||||
try:
|
||||
completeFilepath = id + str(f)
|
||||
with open(completeFilepath, 'r') as f:
|
||||
fmonfile = f.read()
|
||||
|
||||
if fmonfile:
|
||||
schema = VRPMDV_MonfilesSchema()
|
||||
monfile = schema.loads(fmonfile, unknown=EXCLUDE)
|
||||
monfiles.append(monfile)
|
||||
except:
|
||||
#nothing todo ML we should create a file later the database
|
||||
print("file not found")
|
||||
return monfiles
|
||||
|
||||
|
||||
|
||||
# This is to get the directory that the program
|
||||
# is currently running in.
|
||||
# dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
# for root, dirs, files in os.walk(dir_path):
|
||||
# for file in files:
|
||||
|
||||
# # change the extension from '.mp3' to
|
||||
# # the one of your choice.
|
||||
# if file.endswith('.mp3'):
|
||||
# print (root+'/'+str(file))
|
||||
|
||||
Reference in New Issue
Block a user