Add logic that detects test scans and real scans
I just don't do anything with them yet.
This commit is contained in:
parent
7fadb30e84
commit
dd93754295
|
@ -1,2 +1,31 @@
|
|||
import argparse
|
||||
import inotify.adapters
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
def main():
|
||||
print("hey there")
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--verbose", "-v", action="store_true", help="Enable verbose logging.")
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO)
|
||||
try:
|
||||
run(Path("/mnt/shares/scans"))
|
||||
except KeyboardInterrupt:
|
||||
LOGGER.info("Quitting")
|
||||
|
||||
def run(path: Path) -> None:
|
||||
i = inotify.adapters.Inotify()
|
||||
i.add_watch(str(path))
|
||||
for event in i.event_gen(yield_nones=False):
|
||||
(_, type_names, path, filename) = event
|
||||
if "IN_CLOSE_WRITE" in type_names:
|
||||
_handle_write_complete(Path(filename))
|
||||
|
||||
def _handle_write_complete(path: Path) -> None:
|
||||
if path.suffix == ".test":
|
||||
LOGGER.info("Ignoring scanner test write '%s'", path)
|
||||
return
|
||||
LOGGER.info("Pretend I uploaded %s", path)
|
||||
|
|
Loading…
Reference in New Issue