forked from cdrx/docker-pyinstaller
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update test * Enhancing Tests --------- Co-authored-by: Fedor Batonogov <f.batonogov@yandex.ru>
- Loading branch information
1 parent
9795809
commit fb13834
Showing
2 changed files
with
53 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,39 @@ | ||
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() |