From 91b968b62316c579a3f887e8b01bc15515b47afb Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Mon, 23 Sep 2024 00:35:51 +0330 Subject: [PATCH 1/7] fix : EOFError handler added --- nafas/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nafas/__main__.py b/nafas/__main__.py index 86843bc..c328199 100644 --- a/nafas/__main__.py +++ b/nafas/__main__.py @@ -46,5 +46,5 @@ def main(): if __name__ == "__main__": try: main() - except KeyboardInterrupt: + except (KeyboardInterrupt, EOFError): print("\n" + EXIT_MESSAGE) From c9f6f592c76afd71414c4bced9691a8cb4466c50 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Mon, 23 Sep 2024 00:38:50 +0330 Subject: [PATCH 2/7] fix : get_input_standard function updated --- nafas/functions.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nafas/functions.py b/nafas/functions.py index 18fb22e..687b9a7 100644 --- a/nafas/functions.py +++ b/nafas/functions.py @@ -221,6 +221,8 @@ def get_input_standard(input_func=input): try: input_data[item] = int(input_func("")) exit_flag = True + except KeyboardInterrupt: + sys.exit() except Exception: print("[Error] Bad Input!") return input_data From ec98957cbf997231d43b9dcd6a029eca0c53ef47 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Mon, 23 Sep 2024 00:39:50 +0330 Subject: [PATCH 3/7] doc : CHANGELOG.md updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d2be4d..4949304 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `clear_screen` function ### Changed - Restart mode updated +- Exit bug fixed ## [0.7] - 2024-08-27 ### Added - `feature_request.yml` template From 5ee07d748864fd60aa68c6d514183b6f0478392d Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 24 Sep 2024 01:19:31 +0330 Subject: [PATCH 4/7] fix : minor bug in get_input_standard function fixed --- nafas/functions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nafas/functions.py b/nafas/functions.py index 687b9a7..93559a8 100644 --- a/nafas/functions.py +++ b/nafas/functions.py @@ -222,6 +222,7 @@ def get_input_standard(input_func=input): input_data[item] = int(input_func("")) exit_flag = True except KeyboardInterrupt: + print("\n" + EXIT_MESSAGE) sys.exit() except Exception: print("[Error] Bad Input!") From 2fed0412da950f0a46523a8ad82275fdee123c6d Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 24 Sep 2024 01:22:12 +0330 Subject: [PATCH 5/7] fix : import EXIT_MESSAGE --- nafas/functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nafas/functions.py b/nafas/functions.py index 93559a8..4aa416c 100644 --- a/nafas/functions.py +++ b/nafas/functions.py @@ -4,7 +4,7 @@ import time from nafas.params import NAFAS_DESCRIPTION, NAFAS_NOTICE, STANDARD_MENU, STANDARD_MENU_ORDER, STEP_MAP from nafas.params import PROGRAMS, PROGRAM_DESCRIPTION, SOUND_MAP, STEP_TEMPLATE, CYCLE_TEMPLATE -from nafas.params import SOUND_WARNING_MESSAGE +from nafas.params import SOUND_WARNING_MESSAGE, EXIT_MESSAGE import nava import os from warnings import warn From 308236fded006265018873d0cab25e976886c46f Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 24 Sep 2024 01:56:16 +0330 Subject: [PATCH 6/7] fix : tests updated --- test/test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test.py b/test/test.py index c6cae68..a8316e2 100644 --- a/test/test.py +++ b/test/test.py @@ -50,6 +50,8 @@ True >>> input_data["level"] == 1 True +>>> def test_keyboard_interrupt(i): +... raise KeyboardInterrupt >>> input_data = get_input_standard(lambda x: "1") - Please choose a program : @@ -70,6 +72,23 @@ 1- Beginner 2- Medium 3- Advanced +>>> get_input_standard(test_keyboard_interrupt) +- Please choose a program : + +1- Clear Mind (~ 7 minutes) +2- Relax1 (~ 7 minutes) +3- Relax2 (~ 3 minutes) +4- Relax3 (~ 6 minutes) +5- Calming1 (~ 9 minutes) +6- Calming2 (~ 2 minutes) +7- Power (~ 7 minutes) +8- Harmony (~ 7 minutes) +9- Anti-Stress (~ 4 minutes) +10- Anti-Appetite (~ 10 minutes) +11- Cigarette Replace (~ 5 minutes) +12- Decision-Making (~ 2 minutes) + +See you. Bye! >>> input_data["program"] == 1 True >>> input_data["level"] == 1 From 2d381718e334eeba6e09c2de8c6502b877df4a81 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 24 Sep 2024 02:14:08 +0330 Subject: [PATCH 7/7] fix : tests updated --- test/test.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/test/test.py b/test/test.py index a8316e2..b71da61 100644 --- a/test/test.py +++ b/test/test.py @@ -73,22 +73,9 @@ 2- Medium 3- Advanced >>> get_input_standard(test_keyboard_interrupt) -- Please choose a program : - -1- Clear Mind (~ 7 minutes) -2- Relax1 (~ 7 minutes) -3- Relax2 (~ 3 minutes) -4- Relax3 (~ 6 minutes) -5- Calming1 (~ 9 minutes) -6- Calming2 (~ 2 minutes) -7- Power (~ 7 minutes) -8- Harmony (~ 7 minutes) -9- Anti-Stress (~ 4 minutes) -10- Anti-Appetite (~ 10 minutes) -11- Cigarette Replace (~ 5 minutes) -12- Decision-Making (~ 2 minutes) - -See you. Bye! +Traceback (most recent call last): +... +SystemExit >>> input_data["program"] == 1 True >>> input_data["level"] == 1