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"""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['systemctl', 'show', 'pdf-renamer', '-p', f'Environment'],
|
||||
['systemctl', 'show', 'pdf-renamer', '-p', 'Environment'],
|
||||
capture_output=True, text=True, check=True
|
||||
)
|
||||
env_lines = result.stdout.strip().split('\n')
|
||||
for line in env_lines:
|
||||
if f'{var_name}=' in line:
|
||||
# Extract the value after the equals sign
|
||||
return line.split('=', 1)[1].strip('"')
|
||||
env_line = result.stdout.strip()
|
||||
if not env_line or '=' not in env_line:
|
||||
return None
|
||||
|
||||
# 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
|
||||
except subprocess.CalledProcessError:
|
||||
return None
|
||||
|
||||
Reference in new issue
Block a user