From fde645fd60f4ec636752632985cd85257d6f794e Mon Sep 17 00:00:00 2001 From: doctor_dev Date: Fri, 6 Jun 2025 21:00:10 +0000 Subject: [PATCH] minor bug fix, both issue 80 and 20 are done --- scripts/lantern.py | 5 ++--- scripts/logic/options.py | 27 ++++++++++++++++++++++++--- scripts/utils.py | 8 ++++++-- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/scripts/lantern.py b/scripts/lantern.py index 374292d..746702e 100644 --- a/scripts/lantern.py +++ b/scripts/lantern.py @@ -1,7 +1,7 @@ from utils import * import logic.lantern_logic as lantern from dotenv import load_dotenv -import options +import logic.options as options import os, pwd @@ -533,7 +533,7 @@ Maintenance: ##################################################### case 4: - + options.run_option_4() break @@ -679,7 +679,6 @@ Maintenance: case 6: - options.run_option_6() break diff --git a/scripts/logic/options.py b/scripts/logic/options.py index a4c02c5..0376a23 100644 --- a/scripts/logic/options.py +++ b/scripts/logic/options.py @@ -1,8 +1,15 @@ +import shutil +import os + import utils import conf -import lantern_logic as lantern +import logic.lantern_logic as lantern def run_option_4(): + """ + Running option 4: syncing all links from official and registered webrings + + """ try: utils.print_colors("4) Synchronize new links from new or existing webring participants, into your local csv files") @@ -70,6 +77,10 @@ def run_option_4(): utils.print_colors("[-] Option 4 failed suddently, please try again", is_error=True) def run_option_6(): + """ + Running option 6: Trusting/Untrusting/Blacklisting a webring participant + + """ while True: utils.print_colors("[+] Trust/UnTrust/Blacklist a webring participant (Potentially dangerous)") @@ -164,6 +175,10 @@ def run_option_6(): utils.print_colors("[-] Option 6 failed suddently, please try again", is_error=True) def run_option_9(): + """ + Running option 9: cleans duplications in local instance verified and unverified csv files + + """ utils.print_colors("[+] 9) Cleaning up all duplicates in your own unverified + verified.csv (based on the url)") try: @@ -181,6 +196,10 @@ def run_option_9(): utils.print_colors("[-] Option 9 failed suddenly, please try again", is_error=True) def run_option_10(): + """ + Running option 10: go over all verified and unverified participants csv files + + """ utils.print_colors("[+] 10) perform sanity checks on all csv files (to mark them as sensitive / or remove the ones that are blacklisted)") try: @@ -191,6 +210,9 @@ def run_option_10(): for participant in os.listdir(conf.PARTICIPANT_DIR): participant_local_dir = conf.PARTICIPANT_DIR + participant + '/' + if not os.path.exists(f'{participant_local_dir}verified.csv'): + continue + utils.print_colors('[+] Reading webrring participant\'s verified and unverified') participant_verified_df, participant_unverified_df = utils.get_participant_local_verified_and_unverified(participant_local_dir) @@ -206,8 +228,7 @@ def run_option_10(): utils.save_local_participant_verified_and_unverified(participant_verified_df, participant_unverified_df, participant_local_dir) except Exception as err: - utils.print_colors("[-] Option 10 failed suddently, please try again", is_error=True) - + utils.print_colors("[-] Option 10 failed suddenly, please try again", is_error=True) diff --git a/scripts/utils.py b/scripts/utils.py index 2b9e264..790be16 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -28,8 +28,12 @@ def get_current_instance(): #expanduser gives the current user directory instance_file = os.path.expanduser("~") + '/.darknet_participant_url' - with open(instance_file) as f: - return f.read().rstrip() + if os.path.exists(instance_file): + with open(instance_file) as f: + return f.read().rstrip() + + else: + return "" #Set the local dir on script run conf.LOCAL_DIR = conf.PARTICIPANT_DIR + get_current_instance() + '/'