Ver Fonte

Added extra debug statements

david há 4 anos atrás
pai
commit
ff8b02dc9b
2 ficheiros alterados com 6 adições e 1 exclusões
  1. 2 0
      config.py
  2. 4 1
      failUser.py

+ 2 - 0
config.py

@@ -62,6 +62,7 @@ def add_block(ip, time):
         blocks = {}
         pass
     # add ip and time
+    log.debug("Added {0} in blocks.json".format(ip))
     blocks[ip] = time
     # update blocks
     with open("blocks.json", "w") as f:
@@ -76,6 +77,7 @@ def rm_block(ip):
         return
     try:
         if blocks[ip]:
+            log.debug("Removed {0} in blocks.json".format(ip))
             del blocks[ip]
         # update blocks
         with open("blocks.json", "w") as f:

+ 4 - 1
failUser.py

@@ -9,7 +9,7 @@ from pyinotify import IN_MODIFY, IN_DELETE, IN_MOVE_SELF, IN_CREATE
 import sys
 
 # Branch off the logging into a seperate file
-from config import log, load_config, add_block, rm_block, check_blocks
+from config import log, load_config, save_config, add_block, rm_block, check_blocks
 
 myConfig = load_config()
 
@@ -52,6 +52,8 @@ def checkup():
             log.info("Unblock {0}".format(ip))
             unblocker(ip)
             rm_block(ip)
+    else:
+        log.debug("No blocks found to unblock.")
 
 class EventHandler(ProcessEvent):
     def process_IN_MODIFY(self, event):
@@ -93,6 +95,7 @@ while True:
         last = pendulum.parse(myConfig["last_unblock"])
         if now.diff(last).in_hours():
             myConfig["last_unblock"] = now.to_datetime_string()
+            save_config(myConfig)
             checkup()
         notifier.process_events()
         if notifier.check_events():