mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
*: Use action_utils.run instead of subprocess.check_output
- This is to capture stdout and stderr and transmit that from privileged daemon back to the service to be displayed in HTML. Tests: - Unit tests and code checks pass. - Some of the modified actions work as expected. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
1 parent
bf9005ac48
commit
b253166f6d
17 files changed
+101
-72
No files matched your search
@@ -8,7 +8,6 @@ import os
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
@@ -28,8 +27,9 @@ WEB_ROOT_PATH = '/var/www/html'
|
||||
def _get_certificate_expiry(domain: str) -> str:
|
||||
"""Return the expiry date of a certificate."""
|
||||
certificate_file = os.path.join(le.LIVE_DIRECTORY, domain, 'cert.pem')
|
||||
output = subprocess.check_output(
|
||||
['openssl', 'x509', '-enddate', '-noout', '-in', certificate_file])
|
||||
output = action_utils.run(
|
||||
['openssl', 'x509', '-enddate', '-noout', '-in', certificate_file],
|
||||
check=True).stdout
|
||||
return output.decode().strip().split('=')[1]
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ def _get_modified_time(domain: str) -> int:
|
||||
|
||||
def _get_validity_status(domain: str) -> str:
|
||||
"""Return validity status of a certificate; valid, revoked, expired."""
|
||||
output = subprocess.check_output(['certbot', 'certificates', '-d', domain])
|
||||
output = action_utils.run(['certbot', 'certificates', '-d', domain],
|
||||
check=True).stdout
|
||||
line = output.decode(sys.stdout.encoding)
|
||||
|
||||
match = re.search(r'INVALID: (.*)\)', line)
|
||||
|
||||
Reference in new issue
Block a user