added time to all events. this is a unix timestamp so will need to be converted to something nicer if dispalyed, but hey, its easy to store
This commit is contained in:
@ -14,9 +14,10 @@ from typing import Any, Tuple, Dict, Union
|
||||
from time import sleep
|
||||
|
||||
from meow_base.core.vars import VALID_CHANNELS, EVENT_RULE, EVENT_PATH, \
|
||||
VALID_HANDLER_NAME_CHARS, META_FILE, JOB_ID, WATCHDOG_BASE, JOB_FILE, \
|
||||
JOB_PARAMETERS, get_drt_imp_msg
|
||||
VALID_HANDLER_NAME_CHARS, META_FILE, JOB_ID, JOB_FILE, JOB_PARAMETERS, \
|
||||
get_drt_imp_msg
|
||||
from meow_base.core.meow import valid_event
|
||||
from meow_base.patterns.file_event_pattern import WATCHDOG_HASH
|
||||
from meow_base.functionality.file_io import threadsafe_write_status, \
|
||||
threadsafe_update_status, make_dir, write_file, lines_to_string
|
||||
from meow_base.functionality.validation import check_implementation, \
|
||||
@ -179,6 +180,7 @@ class BaseHandler:
|
||||
|
||||
# Get updated job parameters
|
||||
# TODO replace this with generic implementation
|
||||
from meow_base.patterns.file_event_pattern import WATCHDOG_BASE
|
||||
params_dict = replace_keywords(
|
||||
params_dict,
|
||||
meow_job[JOB_ID],
|
||||
@ -242,8 +244,8 @@ class BaseHandler:
|
||||
"#!/bin/bash",
|
||||
"",
|
||||
"# Get job params",
|
||||
"given_hash=$(grep 'file_hash: *' $(dirname $0)/job.yml | tail -n1 | cut -c 14-)",
|
||||
"event_path=$(grep 'event_path: *' $(dirname $0)/job.yml | tail -n1 | cut -c 15-)",
|
||||
f"given_hash=$(grep '{WATCHDOG_HASH}: *' $(dirname $0)/job.yml | tail -n1 | cut -c 14-)",
|
||||
f"event_path=$(grep '{EVENT_PATH}: *' $(dirname $0)/job.yml | tail -n1 | cut -c 15-)",
|
||||
"",
|
||||
"echo event_path: $event_path",
|
||||
"echo given_hash: $given_hash",
|
||||
|
12
core/meow.py
12
core/meow.py
@ -12,21 +12,16 @@ from meow_base.core.rule import Rule
|
||||
from meow_base.functionality.validation import check_type
|
||||
from meow_base.core.vars import EVENT_TYPE, EVENT_PATH, \
|
||||
JOB_EVENT, JOB_TYPE, JOB_ID, JOB_PATTERN, JOB_RECIPE, JOB_RULE, \
|
||||
JOB_STATUS, JOB_CREATE_TIME, EVENT_RULE, WATCHDOG_BASE, WATCHDOG_HASH
|
||||
JOB_STATUS, JOB_CREATE_TIME, EVENT_RULE, EVENT_TIME
|
||||
|
||||
# Required keys in event dict
|
||||
EVENT_KEYS = {
|
||||
EVENT_TYPE: str,
|
||||
EVENT_PATH: str,
|
||||
EVENT_TIME: float,
|
||||
EVENT_RULE: Rule
|
||||
}
|
||||
|
||||
WATCHDOG_EVENT_KEYS = {
|
||||
WATCHDOG_BASE: str,
|
||||
WATCHDOG_HASH: str,
|
||||
**EVENT_KEYS
|
||||
}
|
||||
|
||||
# Required keys in job dict
|
||||
JOB_KEYS = {
|
||||
JOB_TYPE: str,
|
||||
@ -59,6 +54,3 @@ def valid_event(event:Dict[str,Any])->None:
|
||||
def valid_job(job:Dict[str,Any])->None:
|
||||
"""Check that a given dict expresses a meow job."""
|
||||
valid_meow_dict(job, "Job", JOB_KEYS)
|
||||
|
||||
def valid_watchdog_event(event:Dict[str,Any])->None:
|
||||
valid_meow_dict(event, "Watchdog event", WATCHDOG_EVENT_KEYS)
|
||||
|
@ -44,12 +44,8 @@ SHA256 = "sha256"
|
||||
# meow events
|
||||
EVENT_TYPE = "event_type"
|
||||
EVENT_PATH = "event_path"
|
||||
EVENT_RULE = "rule"
|
||||
|
||||
# watchdog events
|
||||
EVENT_TYPE_WATCHDOG = "watchdog"
|
||||
WATCHDOG_BASE = "monitor_base"
|
||||
WATCHDOG_HASH = "file_hash"
|
||||
EVENT_RULE = "event_rule"
|
||||
EVENT_TIME = "event_time"
|
||||
|
||||
# inotify events
|
||||
FILE_CREATE_EVENT = "file_created"
|
||||
|
Reference in New Issue
Block a user