Loading build-and-test.sh +16 −9 Original line number Diff line number Diff line #!/bin/bash if [ -z $1 ]; then if [ -z $1 ]; then echo "Enter dockerfile name" else { # try docker build -f $1 -t pyinstaller_test . && \ docker run -v "$(pwd)/test:/src/" pyinstaller_test "pyinstaller main.py --onefile" } || { # catch podman build -f $1 -t pyinstaller_test . && \ podman run -v "$(pwd)/test:/src/" pyinstaller_test "pyinstaller main.py --onefile" exit 1 fi build_and_run() { local build_cmd=$1 local run_cmd=$2 local dockerfile=$3 $build_cmd -f $dockerfile -t pyinstaller_test . && \ $run_cmd -v "$(pwd)/test:/src/" pyinstaller_test "pyinstaller main.py --onefile" } # Try with Docker if ! build_and_run "docker build" "docker run" $1; then # If Docker fails, try with Podman build_and_run "podman build" "podman run" $1 fi test/main.py +37 −2 Original line number Diff line number Diff line import logging import random import time from datetime import datetime import requests get = requests.get("https://api.github.com") print(get) def check_requests(): try: response = requests.get("https://api.github.com") response.raise_for_status() # Проверка на успешный статус print(f"Response Status Code: {response.status_code}") print(f"Response Content: {response.json()}") except requests.exceptions.HTTPError as http_err: print(f"HTTP error occurred: {http_err}") except Exception as err: print(f"Other error occurred: {err}") def log_request(): logging.basicConfig(level=logging.INFO) logging.info(f"Request made at {datetime.now()}") def simulate_delay(): delay = random.uniform(1, 3) print(f"Simulating delay of {delay:.2f} seconds") time.sleep(delay) def main(): log_request() simulate_delay() check_requests() if __name__ == "__main__": main() Loading
build-and-test.sh +16 −9 Original line number Diff line number Diff line #!/bin/bash if [ -z $1 ]; then if [ -z $1 ]; then echo "Enter dockerfile name" else { # try docker build -f $1 -t pyinstaller_test . && \ docker run -v "$(pwd)/test:/src/" pyinstaller_test "pyinstaller main.py --onefile" } || { # catch podman build -f $1 -t pyinstaller_test . && \ podman run -v "$(pwd)/test:/src/" pyinstaller_test "pyinstaller main.py --onefile" exit 1 fi build_and_run() { local build_cmd=$1 local run_cmd=$2 local dockerfile=$3 $build_cmd -f $dockerfile -t pyinstaller_test . && \ $run_cmd -v "$(pwd)/test:/src/" pyinstaller_test "pyinstaller main.py --onefile" } # Try with Docker if ! build_and_run "docker build" "docker run" $1; then # If Docker fails, try with Podman build_and_run "podman build" "podman run" $1 fi
test/main.py +37 −2 Original line number Diff line number Diff line import logging import random import time from datetime import datetime import requests get = requests.get("https://api.github.com") print(get) def check_requests(): try: response = requests.get("https://api.github.com") response.raise_for_status() # Проверка на успешный статус print(f"Response Status Code: {response.status_code}") print(f"Response Content: {response.json()}") except requests.exceptions.HTTPError as http_err: print(f"HTTP error occurred: {http_err}") except Exception as err: print(f"Other error occurred: {err}") def log_request(): logging.basicConfig(level=logging.INFO) logging.info(f"Request made at {datetime.now()}") def simulate_delay(): delay = random.uniform(1, 3) print(f"Simulating delay of {delay:.2f} seconds") time.sleep(delay) def main(): log_request() simulate_delay() check_requests() if __name__ == "__main__": main()