refactor away from a log file, stout only.
This commit is contained in:
@@ -16,7 +16,7 @@ def establish_vpn_connection(ovpn_file, credential_file, log_file, debug_print=N
|
||||
password = f.readline().strip()
|
||||
|
||||
# Establish VPN connection (capture stdout and stderr)
|
||||
openvpn_command = ["openvpn", "--config", ovpn_file,
|
||||
openvpn_command = ["/usr/sbin/openvpn", "--config", ovpn_file,
|
||||
"--auth-user-pass", credential_file,
|
||||
"--verb", "1"]
|
||||
|
||||
@@ -41,8 +41,11 @@ def establish_vpn_connection(ovpn_file, credential_file, log_file, debug_print=N
|
||||
debug_print(f"OpenVPN exited with a non-zero return code: {process.returncode}")
|
||||
return False, process.stderr.read().decode()
|
||||
|
||||
# Read a line from stdout (non-blocking)
|
||||
line = process.stdout.readline().decode()
|
||||
try:
|
||||
line = process.stdout.readline().decode()
|
||||
except UnicodeDecodeError:
|
||||
print(f"Decoding error: {line.strip()}") # Log the problematic line
|
||||
continue # Skip to the next line
|
||||
if line:
|
||||
if debug_print:
|
||||
debug_print(f"OpenVPN output: {line.strip()}")
|
||||
|
||||
Reference in New Issue
Block a user