test auth
This commit is contained in:
1 parent
259f71bceb
commit
46fd321d06
1 file changed
+17
-6
+17
-6
@@ -13,14 +13,25 @@ def get_systemd_env_var(var_name):
|
|||||||
"""Get environment variable from systemd service"""
|
"""Get environment variable from systemd service"""
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
['systemctl', 'show', 'pdf-renamer', '-p', f'Environment'],
|
['systemctl', 'show', 'pdf-renamer', '-p', 'Environment'],
|
||||||
capture_output=True, text=True, check=True
|
capture_output=True, text=True, check=True
|
||||||
)
|
)
|
||||||
env_lines = result.stdout.strip().split('\n')
|
env_line = result.stdout.strip()
|
||||||
for line in env_lines:
|
if not env_line or '=' not in env_line:
|
||||||
if f'{var_name}=' in line:
|
return None
|
||||||
# Extract the value after the equals sign
|
|
||||||
return line.split('=', 1)[1].strip('"')
|
# The Environment line contains: Environment=VAR1=value1 VAR2=value2 ...
|
||||||
|
# Extract everything after the first '='
|
||||||
|
env_string = env_line.split('=', 1)[1]
|
||||||
|
|
||||||
|
# Split by spaces to get individual VAR=value pairs
|
||||||
|
env_pairs = env_string.split()
|
||||||
|
|
||||||
|
# Find the specific variable
|
||||||
|
for pair in env_pairs:
|
||||||
|
if pair.startswith(f'{var_name}='):
|
||||||
|
return pair.split('=', 1)[1]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in new issue
Block a user