mirror of
https://github.com/scito/extract_otp_secret_keys.git
synced 2025-12-10 00:35:02 +01:00
build: add generate result files option
This commit is contained in:
parent
1c106150b0
commit
722009b172
4 changed files with 23 additions and 5 deletions
14
build.sh
14
build.sh
|
|
@ -83,6 +83,7 @@ ignore_version_check=true
|
|||
clean=false
|
||||
build_docker=true
|
||||
run_gui=true
|
||||
generate_result_files=false
|
||||
|
||||
while test $# -gt 0; do
|
||||
case $1 in
|
||||
|
|
@ -97,6 +98,7 @@ while test $# -gt 0; do
|
|||
echo "-D No docker build"
|
||||
echo "-G No not run gui"
|
||||
echo "-c Clean"
|
||||
echo "-r Generate result files"
|
||||
echo "-h, --help Help"
|
||||
quit
|
||||
;;
|
||||
|
|
@ -116,6 +118,10 @@ while test $# -gt 0; do
|
|||
run_gui=false
|
||||
shift
|
||||
;;
|
||||
-r)
|
||||
generate_result_files=true
|
||||
shift
|
||||
;;
|
||||
-c)
|
||||
clean=true
|
||||
shift
|
||||
|
|
@ -286,6 +292,14 @@ cmd="extract_otp_secrets - < example_export.txt"
|
|||
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
|
||||
eval "$cmd"
|
||||
|
||||
# Generate results files
|
||||
|
||||
if $generate_result_files; then
|
||||
cmd="for color in '' '-n'; do for level in '' '-v' '-vv' '-vvv'; do $PYTHON src/extract_otp_secrets.py example_export.txt $color $level > tests/data/print_verbose_output$color$level.txt; done; done"
|
||||
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
|
||||
eval "$cmd"
|
||||
fi
|
||||
|
||||
# Test
|
||||
|
||||
cmd="$PYTHON src/extract_otp_secrets.py example_export.txt"
|
||||
|
|
|
|||
|
|
@ -242,7 +242,9 @@ def cv2_draw_box(img: Any, raw_pts: Any, color: ColorBGR) -> Any:
|
|||
def cv2_print_text(img: Any, text: str, line_number: int, position: TextPosition, color: ColorBGR, opposite_len: Optional[int] = None) -> None:
|
||||
text_dim, _ = cv2.getTextSize(text, FONT, FONT_SCALE, FONT_THICKNESS)
|
||||
window_dim = cv2.getWindowImageRect(WINDOW_NAME)
|
||||
out_text = text if not opposite_len or (actual_width := text_dim[TEXT_WIDTH] + opposite_len * CHAR_DX + 4 * BORDER) <= window_dim[WINDOW_WIDTH] else text[:(window_dim[WINDOW_WIDTH] - actual_width) // CHAR_DX] + '.'
|
||||
out_text = text \
|
||||
if not opposite_len or (actual_width := text_dim[TEXT_WIDTH] + opposite_len * CHAR_DX + 4 * BORDER) <= window_dim[WINDOW_WIDTH] \
|
||||
else text[:(window_dim[WINDOW_WIDTH] - actual_width) // CHAR_DX] + '.'
|
||||
text_dim, _ = cv2.getTextSize(out_text, FONT, FONT_SCALE, FONT_THICKNESS)
|
||||
if position == TextPosition.LEFT:
|
||||
pos = BORDER, START_Y + line_number * FONT_DY
|
||||
|
|
|
|||
|
|
@ -393,6 +393,7 @@ def test_extract_verbose(verbose_level: str, color: str, capsys: pytest.CaptureF
|
|||
assert actual_stdout == expected_stdout
|
||||
assert captured.err == ''
|
||||
|
||||
|
||||
def normalize_verbose_text(text: str) -> str:
|
||||
return re.sub('^.+ version: .+$', '', text, flags=re.MULTILINE | re.IGNORECASE)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,21 +19,22 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import annotations # workaround for PYTHON <= 3.10
|
||||
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from contextlib import redirect_stdout
|
||||
|
||||
import extract_otp_secrets
|
||||
from utils import (Capturing, read_csv, read_file_to_str, read_json,
|
||||
remove_dir_with_files, remove_file, count_files_in_dir)
|
||||
from utils import (Capturing, count_files_in_dir, read_csv, read_file_to_str,
|
||||
read_json, remove_dir_with_files, remove_file)
|
||||
|
||||
import extract_otp_secrets
|
||||
|
||||
# Conditional skip example
|
||||
# if sys.implementation.name == 'pypy' or sys.platform.startswith("win") or sys.version_info < (3, 10):
|
||||
# self.skipTest("Avoid encoding problems")
|
||||
|
||||
|
||||
class TestExtract(unittest.TestCase):
|
||||
|
||||
def test_extract_csv(self) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue