You've already forked Mailu
mirror of
https://github.com/Mailu/Mailu.git
synced 2025-11-25 22:12:28 +02:00
Replaces os.popen with subprocess.check_output
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
import docker
|
import docker
|
||||||
from colorama import Fore, Style
|
from colorama import Fore, Style
|
||||||
|
import subprocess
|
||||||
|
|
||||||
# Declare variables for service name and sleep time
|
# Declare variables for service name and sleep time
|
||||||
test_name=sys.argv[1]
|
test_name=sys.argv[1]
|
||||||
@@ -17,7 +18,7 @@ containers = []
|
|||||||
# Stop containers
|
# Stop containers
|
||||||
def stop(exit_code):
|
def stop(exit_code):
|
||||||
print_logs()
|
print_logs()
|
||||||
print(os.popen("docker-compose -f " + compose_file + " down").read())
|
print(subprocess.check_output("docker-compose -f " + compose_file + " down", shell=True))
|
||||||
sys.exit(exit_code)
|
sys.exit(exit_code)
|
||||||
|
|
||||||
# Sleep for a defined amount of time
|
# Sleep for a defined amount of time
|
||||||
@@ -64,25 +65,25 @@ def print_logs():
|
|||||||
#Iterating through docker container inspect list and print logs
|
#Iterating through docker container inspect list and print logs
|
||||||
for container in containers:
|
for container in containers:
|
||||||
print(Fore.LIGHTMAGENTA_EX + "Printing logs for: " + Fore.GREEN + container['Name'] + Style.RESET_ALL)
|
print(Fore.LIGHTMAGENTA_EX + "Printing logs for: " + Fore.GREEN + container['Name'] + Style.RESET_ALL)
|
||||||
print(os.popen('docker container logs ' + container['Name']).read())
|
print(subprocess.check_output('docker container logs ' + container['Name'], shell=True))
|
||||||
|
|
||||||
#Iterating over hooks in test folder and running them
|
#Iterating over hooks in test folder and running them
|
||||||
def hooks():
|
def hooks():
|
||||||
print("Running hooks")
|
print("Running hooks")
|
||||||
for test_file in sorted(os.listdir(test_path)):
|
for test_file in sorted(os.listdir(test_path)):
|
||||||
if test_file.endswith(".py"):
|
if test_file.endswith(".py"):
|
||||||
print(os.popen("python3 " + test_path + test_file).read())
|
print(subprocess.check_output("python3 " + test_path + test_file, shell=True))
|
||||||
elif test_file.endswith(".sh"):
|
elif test_file.endswith(".sh"):
|
||||||
print(os.popen("./" + test_path + test_file).read())
|
print(subprocess.check_output("./" + test_path + test_file, shell=True))
|
||||||
|
|
||||||
print(os.popen("python3 tests/compose/email_test.py").read())
|
print(subprocess.check_output("python3 tests/email_test.py", shell=True))
|
||||||
|
|
||||||
# Start up containers
|
# Start up containers
|
||||||
print(os.popen("docker-compose -f " + compose_file + " up -d ").read())
|
print(subprocess.check_output("docker-compose -f " + compose_file + " up -d", shell=True))
|
||||||
print()
|
print()
|
||||||
sleep()
|
sleep()
|
||||||
print()
|
print()
|
||||||
print(os.popen("docker ps -a").read())
|
print(subprocess.check_output("docker ps -a", shell=True))
|
||||||
print()
|
print()
|
||||||
health_checks()
|
health_checks()
|
||||||
print()
|
print()
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import random
|
|||||||
import smtplib
|
import smtplib
|
||||||
import imaplib
|
import imaplib
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
def secret(length=16):
|
def secret(length=16):
|
||||||
charset = string.ascii_uppercase + string.digits
|
charset = string.ascii_uppercase + string.digits
|
||||||
@@ -44,7 +45,8 @@ def read_email():
|
|||||||
if secret_message in str(data[0][1]):
|
if secret_message in str(data[0][1]):
|
||||||
print("Success!")
|
print("Success!")
|
||||||
else:
|
else:
|
||||||
print("Failed! Something went wrong")
|
print("Failed! Something went wrong")
|
||||||
|
sys.exit(1)
|
||||||
server.close()
|
server.close()
|
||||||
server.logout()
|
server.logout()
|
||||||
|
|
||||||
Reference in New Issue
Block a user