]> git.mxchange.org Git - fba.git/blobdiff - fba/boot.py
Continued:
[fba.git] / fba / boot.py
index d0bc4564e58bff11675ded616cc54d02fe7c5cd6..a602e3d41c3b048b2f453ecd439502dd3cbdabd9 100644 (file)
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 import argparse
-import os
-import sys
-import tempfile
-import zc.lockfile
 
 from fba import commands
 from fba import fba
+from fba import locking
 
-# Lock file
-lockfile = tempfile.gettempdir() + '/fba.lock'
-LOCK = None
 _PARSER = None
 
-def acquire_lock():
-    global LOCK
-    try:
-        print(f"DEBUG: Acquiring lock: '{lockfile}'")
-        LOCK = zc.lockfile.LockFile(lockfile)
-        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!")
     global _PARSER
@@ -100,12 +83,13 @@ def init_parser():
     )
     parser.set_defaults(command=commands.fetch_fbabot_atom)
 
-    ### Fetch blocks from federater ###
+    ### Fetch blocks from oliphant's GIT repository ###
     parser = subparser_command.add_parser(
-        "fetch_federater",
-        help="Fetches CSV file (block recommendations) for more possible instances to disover",
+        "fetch_oliphant",
+        help="Fetches CSV files (block recommendations) for more possible instances to disover",
     )
-    parser.set_defaults(command=commands.fetch_federater)
+    parser.add_argument("--domain", help="Instance name (aka. domain) to check")
+    parser.set_defaults(command=commands.fetch_oliphant)
 
     ### Fetch instances from given initial instance ###
     parser = subparser_command.add_parser(
@@ -116,6 +100,13 @@ def init_parser():
     parser.add_argument("--single", action="store_true", help="Only fetch given instance.")
     parser.set_defaults(command=commands.fetch_instances)
 
+    ### Fetch blocks from static text file(s) ###
+    parser = subparser_command.add_parser(
+        "fetch_txt",
+        help="Fetches text/plain files as simple domain lists",
+    )
+    parser.set_defaults(command=commands.fetch_txt)
+
     # DEBUG: print("DEBUG: init_parser(): EXIT!")
 
 def run_command():
@@ -127,13 +118,7 @@ def run_command():
     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 is not None:
-        print("DEBUG: Releasing lock ...")
-        LOCK.close()
-        print(f"DEBUG: Deleting lockfile='{lockfile}' ...")
-        os.remove(lockfile)
-
-    print("DEBUG: Shutdown completed.")
+    locking.release()
+    # DEBUG: print("DEBUG: Shutdown completed.")