]> git.mxchange.org Git - fba.git/blobdiff - fba/boot.py
WIP:
[fba.git] / fba / boot.py
index e66690bd6fabbd0bfe942f0488c9ec600326c0de..91c2880d59f595f96c9696c13fdee36cc391ee01 100644 (file)
@@ -19,6 +19,7 @@ import os
 import sys
 import tempfile
 import zc.lockfile
+
 from fba import commands
 from fba import fba
 
@@ -30,19 +31,19 @@ _PARSER = None
 def acquire_lock():
     global LOCK
     try:
-        print(f"DEBUG: Acquiring lock: '{lockfile}'")
+        # DEBUG: print(f"DEBUG: Acquiring lock: '{lockfile}'")
         LOCK = zc.lockfile.LockFile(lockfile)
-        print("DEBUG: Lock obtained.")
+        # DEBUG: print("DEBUG: Lock obtained.")
 
     except zc.lockfile.LockError:
         print(f"ERROR: Cannot aquire lock: '{lockfile}'")
         sys.exit(100)
 
 def init_parser():
-    # DEBUG: print("DEBUG: init_parser(): CALLED!")
+    # DEBUG: # DEBUG: print("DEBUG: init_parser(): CALLED!")
     global _PARSER
 
-    # DEBUG: print("DEBUG: Initializing parser ...")
+    # DEBUG: # DEBUG: print("DEBUG: Initializing parser ...")
     _PARSER = argparse.ArgumentParser(
         description="Fetches block reasons from the fediverse",
         epilog="Please note that some commands have optional arguments, you may want to try fba.py <command> --help to find them out.",
@@ -115,24 +116,24 @@ def init_parser():
     parser.add_argument("--single", action="store_true", help="Only fetch given instance.")
     parser.set_defaults(command=commands.fetch_instances)
 
-    # DEBUG: print("DEBUG: init_parser(): EXIT!")
+    # DEBUG: # DEBUG: print("DEBUG: init_parser(): EXIT!")
 
 def run_command():
-    # DEBUG: print("DEBUG: run_command(): CALLED!")
+    # DEBUG: # DEBUG: print("DEBUG: run_command(): CALLED!")
     args = _PARSER.parse_args()
-    # DEBUG: print(f"DEBUG: args[{type(args)}]={args}")
+    # DEBUG: # DEBUG: print(f"DEBUG: args[{type(args)}]={args}")
     status = args.command(args)
-    # DEBUG: print("DEBUG: status={status} - EXIT!")
-    return status if type(status) == int else 0
+    # DEBUG: # DEBUG: print("DEBUG: status={status} - EXIT!")
+    return status if isinstance(status, int) else 0
 
 def shutdown():
-    print("DEBUG: Closing database connection ...")
+    # DEBUG: print("DEBUG: Closing database connection ...")
     fba.connection.close()
 
-    if LOCK != None:
-        print("DEBUG: Releasing lock ...")
+    if LOCK is not None:
+        # DEBUG: print("DEBUG: Releasing lock ...")
         LOCK.close()
-        print(f"DEBUG: Deleting lockfile='{lockfile}' ...")
+        # DEBUG: print(f"DEBUG: Deleting lockfile='{lockfile}' ...")
         os.remove(lockfile)
 
-    print("DEBUG: Shutdown completed.")
+    # DEBUG: print("DEBUG: Shutdown completed.")