mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
/data and /tmp standarization
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Register NetAlertX directories
|
||||
INSTALL_PATH="/app"
|
||||
sys.path.extend([f"{INSTALL_PATH}/server"])
|
||||
|
||||
# Register NetAlertX modules
|
||||
from const import pluginsPath, logPath, applicationPath, reportTemplatesPath
|
||||
from const import logPath
|
||||
from logger import mylog
|
||||
|
||||
|
||||
class UserEventsQueueInstance:
|
||||
"""
|
||||
Handles the execution queue log file, allowing reading, writing,
|
||||
@@ -19,12 +14,11 @@ class UserEventsQueueInstance:
|
||||
self.log_path = logPath
|
||||
self.log_file = os.path.join(self.log_path, "execution_queue.log")
|
||||
|
||||
|
||||
def has_update_devices(self):
|
||||
lines = self.read_log()
|
||||
|
||||
for line in lines:
|
||||
if 'update_api|devices' in line:
|
||||
if "update_api|devices" in line:
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -35,7 +29,10 @@ class UserEventsQueueInstance:
|
||||
Returns an empty list if the file doesn't exist.
|
||||
"""
|
||||
if not os.path.exists(self.log_file):
|
||||
mylog('none', ['[UserEventsQueueInstance] Log file not found: ', self.log_file])
|
||||
mylog(
|
||||
"none",
|
||||
["[UserEventsQueueInstance] Log file not found: ", self.log_file],
|
||||
)
|
||||
return [] # No log file, return empty list
|
||||
with open(self.log_file, "r") as file:
|
||||
return file.readlines()
|
||||
@@ -64,7 +61,9 @@ class UserEventsQueueInstance:
|
||||
# Process the log file line by line
|
||||
with open(self.log_file, "r") as file:
|
||||
for line in file:
|
||||
columns = line.strip().split('|')[2:4] # Extract event and param columns
|
||||
columns = line.strip().split("|")[
|
||||
2:4
|
||||
] # Extract event and param columns
|
||||
if len(columns) == 2:
|
||||
event_name, _ = columns
|
||||
if event_name == event and not removed:
|
||||
@@ -76,10 +75,6 @@ class UserEventsQueueInstance:
|
||||
# Write back the remaining lines
|
||||
self.write_log(updated_lines)
|
||||
|
||||
|
||||
mylog('minimal', ['[UserEventsQueueInstance] Processed event: ', event])
|
||||
mylog("minimal", ["[UserEventsQueueInstance] Processed event: ", event])
|
||||
|
||||
return removed
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user