clean up curl usage, add consistent debug printing across ovpn_downloader
This commit is contained in:
@@ -22,7 +22,9 @@ if len(sys.argv) > 1 and sys.argv[1] == "-d":
|
||||
|
||||
def debug_print(message):
|
||||
if DEBUG_MODE:
|
||||
print(message)
|
||||
print(f"{datetime.datetime.now()} + [Debug Mode]:{message}")
|
||||
else:
|
||||
log_file.flush()
|
||||
|
||||
# Open the log file in append mode if not in debug mode
|
||||
log_file = None # Define log_file in the global scope
|
||||
@@ -62,7 +64,7 @@ conn, cursor = connect_to_database()
|
||||
|
||||
# Download and extract OVPN configurations, and get the list of files to check
|
||||
debug_print(f"{datetime.datetime.now()} [Main Script]: Downloading and extracting OVPN configurations...")
|
||||
ovpn_files_to_check = download_and_extract_ovpn_configs(cursor, conn)
|
||||
ovpn_files_to_check = download_and_extract_ovpn_configs(cursor, conn, debug_print=debug_print)
|
||||
|
||||
total_files = len(ovpn_files_to_check)
|
||||
|
||||
@@ -77,13 +79,13 @@ for OVPN_FILE in ovpn_files_to_check:
|
||||
debug_print(f"{datetime.datetime.now()} [{FILE_NUM}/{total_files}] [{OVPN_FILENAME}]: Processing OVPN file...")
|
||||
|
||||
# Check if the OVPN file exists, download if needed
|
||||
file_exists = download_ovpn_if_needed(OVPN_FILENAME, cursor, conn)
|
||||
file_exists = download_ovpn_if_needed(OVPN_FILENAME, cursor, conn, debug_print=debug_print)
|
||||
|
||||
if not file_exists:
|
||||
print(f"{datetime.datetime.now()} [{FILE_NUM}/{total_files}] [{OVPN_FILENAME}]: Skipping, file not found and removed from database.")
|
||||
FILE_NUM += 1
|
||||
continue
|
||||
|
||||
continue
|
||||
|
||||
# Read credentials
|
||||
with open(CREDENTIAL_FILE, 'r') as f:
|
||||
username = f.readline().strip()
|
||||
|
||||
Reference in New Issue
Block a user