From 0a7ad79bc603105e917763f2fc42e0dd6a21d4b6 Mon Sep 17 00:00:00 2001 From: Gaetan Jonathan BAKARY Date: Fri, 26 Feb 2021 14:44:56 +0300 Subject: [PATCH 1/8] Add time_shutdown parameter --- eel/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/eel/__init__.py b/eel/__init__.py index f3df71bb..0ecb9d4e 100644 --- a/eel/__init__.py +++ b/eel/__init__.py @@ -51,8 +51,17 @@ 'disable_cache': True, # Sets the no-store response header when serving assets 'default_path': 'index.html', # The default file to retrieve for the root URL 'app': btl.default_app(), # Allows passing in a custom Bottle instance, e.g. with middleware + 'time_shutdown' : 1.0 # timer verification if browser closed } +# verify time_shutdown is correct value +try: + _start_args['time_shutdown'] = float(_start_args['time_shutdown']) +except: + print(_start_args['time_shutdown'], 'is not a correct number, value is changed 1.0') + _start_args['time_shutdown'] = 1.0 + + # == Temporary (suppressable) error message to inform users of breaking API change for v1.0.0 === _start_args['suppress_error'] = False api_error_message = ''' @@ -379,8 +388,8 @@ def _websocket_close(page): else: if _shutdown: _shutdown.kill() - - _shutdown = gvt.spawn_later(1.0, _detect_shutdown) + + _shutdown = gvt.spawn_later(_start_args['time_shutdown'], _detect_shutdown) def _set_response_headers(response): From e992dcfae8dd152df66768a4c74e22ef4427f938 Mon Sep 17 00:00:00 2001 From: Gaetan Jonathan Date: Fri, 26 Feb 2021 12:00:20 +0300 Subject: [PATCH 2/8] Add warning show for incorrect value - Change default if time_shutdown is not correct int or float - Accept string if is a digit --- eel/__init__.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/eel/__init__.py b/eel/__init__.py index 0ecb9d4e..37368b60 100644 --- a/eel/__init__.py +++ b/eel/__init__.py @@ -54,14 +54,6 @@ 'time_shutdown' : 1.0 # timer verification if browser closed } -# verify time_shutdown is correct value -try: - _start_args['time_shutdown'] = float(_start_args['time_shutdown']) -except: - print(_start_args['time_shutdown'], 'is not a correct number, value is changed 1.0') - _start_args['time_shutdown'] = 1.0 - - # == Temporary (suppressable) error message to inform users of breaking API change for v1.0.0 === _start_args['suppress_error'] = False api_error_message = ''' @@ -162,6 +154,13 @@ def start(*start_urls, **kwargs): _start_args['jinja_env'] = Environment(loader=FileSystemLoader(templates_path), autoescape=select_autoescape(['html', 'xml'])) + # verify time_shutdown is correct value + try: + _start_args['time_shutdown'] = float(_start_args['time_shutdown']) + except: + print(_start_args['time_shutdown'], \ + 'is not a correct number for time_shutdown \nValue is changed by default 1.0') + _start_args['time_shutdown'] = 1.0 # Launch the browser to the starting URLs show(*start_urls) From 8e6bf20a1258c1df17e5cc2f3298c5f0d2f12b50 Mon Sep 17 00:00:00 2001 From: Gaetan Jonathan Date: Fri, 26 Feb 2021 12:12:52 +0300 Subject: [PATCH 3/8] Add time_shutdown on README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a445cc84..edc1099d 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ As of Eel v0.12.0, the following options are available to `start()`: - **close_callback**, a lambda or function that is called when a websocket to a window closes (i.e. when the user closes the window). It should take two arguments; a string which is the relative path of the page that just closed, and a list of other websockets that are still open. *Default: `None`* - **app**, an instance of Bottle which will be used rather than creating a fresh one. This can be used to install middleware on the instance before starting eel, e.g. for session management, authentication, etc. + - **time_shutdown**, timer configurable for Eel's shutdown detection mechanism, whereby when any websocket closes, it waits time_shutdown seconds (default 1 second), and then checks if there are now any websocket connections. If not, then Eel closes. In case the user has closed the browser and wants to exit the program. From c1583fd73a2e8a961a60f9563940035df39dde91 Mon Sep 17 00:00:00 2001 From: Gaetan Jonathan BAKARY Date: Fri, 26 Feb 2021 15:52:41 +0300 Subject: [PATCH 4/8] fix typo on README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index edc1099d..84f79475 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ As of Eel v0.12.0, the following options are available to `start()`: - **close_callback**, a lambda or function that is called when a websocket to a window closes (i.e. when the user closes the window). It should take two arguments; a string which is the relative path of the page that just closed, and a list of other websockets that are still open. *Default: `None`* - **app**, an instance of Bottle which will be used rather than creating a fresh one. This can be used to install middleware on the instance before starting eel, e.g. for session management, authentication, etc. - - **time_shutdown**, timer configurable for Eel's shutdown detection mechanism, whereby when any websocket closes, it waits time_shutdown seconds (default 1 second), and then checks if there are now any websocket connections. If not, then Eel closes. In case the user has closed the browser and wants to exit the program. + - **time_shutdown**, timer configurable for Eel's shutdown detection mechanism, whereby when any websocket closes, it waits `time_shutdown seconds`, and then checks if there are now any websocket connections. If not, then Eel closes. In case the user has closed the browser and wants to exit the program. Default: `1.0` From 56345bd70dc3bc86b20b3cf4eef27482723ec496 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 26 Feb 2021 13:41:35 +0000 Subject: [PATCH 5/8] rename variable, stricter error checking --- README.md | 2 +- eel/__init__.py | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 84f79475..0cf08d25 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ As of Eel v0.12.0, the following options are available to `start()`: - **close_callback**, a lambda or function that is called when a websocket to a window closes (i.e. when the user closes the window). It should take two arguments; a string which is the relative path of the page that just closed, and a list of other websockets that are still open. *Default: `None`* - **app**, an instance of Bottle which will be used rather than creating a fresh one. This can be used to install middleware on the instance before starting eel, e.g. for session management, authentication, etc. - - **time_shutdown**, timer configurable for Eel's shutdown detection mechanism, whereby when any websocket closes, it waits `time_shutdown seconds`, and then checks if there are now any websocket connections. If not, then Eel closes. In case the user has closed the browser and wants to exit the program. Default: `1.0` + - **shutdown_delay**, timer configurable for Eel's shutdown detection mechanism, whereby when any websocket closes, it waits `shutdown_delay` seconds, and then checks if there are now any websocket connections. If not, then Eel closes. In case the user has closed the browser and wants to exit the program. Default: `1.0` diff --git a/eel/__init__.py b/eel/__init__.py index 37368b60..21497fc5 100644 --- a/eel/__init__.py +++ b/eel/__init__.py @@ -51,7 +51,7 @@ 'disable_cache': True, # Sets the no-store response header when serving assets 'default_path': 'index.html', # The default file to retrieve for the root URL 'app': btl.default_app(), # Allows passing in a custom Bottle instance, e.g. with middleware - 'time_shutdown' : 1.0 # timer verification if browser closed + 'shutdown_delay' : 1.0 # how long to wait after a websocket closes before detecting complete shutdown } # == Temporary (suppressable) error message to inform users of breaking API change for v1.0.0 === @@ -154,13 +154,9 @@ def start(*start_urls, **kwargs): _start_args['jinja_env'] = Environment(loader=FileSystemLoader(templates_path), autoescape=select_autoescape(['html', 'xml'])) - # verify time_shutdown is correct value - try: - _start_args['time_shutdown'] = float(_start_args['time_shutdown']) - except: - print(_start_args['time_shutdown'], \ - 'is not a correct number for time_shutdown \nValue is changed by default 1.0') - _start_args['time_shutdown'] = 1.0 + # verify shutdown_delay is correct value + if not isinstance(_start_args['shutdown_delay'], (int, float)): + raise ValueError(f"`shutdown_delay` must be a number, got a {type(_start_args['shutdown_delay'])}") # Launch the browser to the starting URLs show(*start_urls) @@ -387,8 +383,8 @@ def _websocket_close(page): else: if _shutdown: _shutdown.kill() - - _shutdown = gvt.spawn_later(_start_args['time_shutdown'], _detect_shutdown) + + _shutdown = gvt.spawn_later(_start_args['shutdown_delay'], _detect_shutdown) def _set_response_headers(response): From 00f1c4f8904103c381da5948c1650cfb19c7a8ab Mon Sep 17 00:00:00 2001 From: Gaetan Jonathan BAKARY Date: Sat, 3 Jul 2021 02:08:00 +0300 Subject: [PATCH 6/8] Update __init__.py fix flake8 warning remplace shortcut `f` not stable on python3.6 by format --- eel/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eel/__init__.py b/eel/__init__.py index 21497fc5..effe4228 100644 --- a/eel/__init__.py +++ b/eel/__init__.py @@ -51,7 +51,7 @@ 'disable_cache': True, # Sets the no-store response header when serving assets 'default_path': 'index.html', # The default file to retrieve for the root URL 'app': btl.default_app(), # Allows passing in a custom Bottle instance, e.g. with middleware - 'shutdown_delay' : 1.0 # how long to wait after a websocket closes before detecting complete shutdown + 'shutdown_delay': 1.0 # how long to wait after a websocket closes before detecting complete shutdown } # == Temporary (suppressable) error message to inform users of breaking API change for v1.0.0 === @@ -156,7 +156,8 @@ def start(*start_urls, **kwargs): # verify shutdown_delay is correct value if not isinstance(_start_args['shutdown_delay'], (int, float)): - raise ValueError(f"`shutdown_delay` must be a number, got a {type(_start_args['shutdown_delay'])}") + raise ValueError("`shutdown_delay` must be a number, \ + got a {}".format(type(_start_args['shutdown_delay'])) # Launch the browser to the starting URLs show(*start_urls) From fd746d4715d284f4a66ba528bf812e6901661ab9 Mon Sep 17 00:00:00 2001 From: Gaetan Jonathan BAKARY Date: Wed, 6 Oct 2021 23:54:40 +0300 Subject: [PATCH 7/8] Update README.md fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c13963a4..b93e5534 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ As of Eel v0.12.0, the following options are available to `start()`: - **close_callback**, a lambda or function that is called when a websocket to a window closes (i.e. when the user closes the window). It should take two arguments; a string which is the relative path of the page that just closed, and a list of other websockets that are still open. *Default: `None`* - **app**, an instance of Bottle which will be used rather than creating a fresh one. This can be used to install middleware on the instance before starting eel, e.g. for session management, authentication, etc. - - **shutdown_delay**, timer configurable for Eel's shutdown detection mechanism, whereby when any websocket closes, it waits `shutdown_delay` seconds, and then checks if there are now any websocket connections. If not, then Eel closes. In case the user has closed the browser and wants to exit the program. Default: `1.0` + - **shutdown_delay**, timer configurable for Eel's shutdown detection mechanism, whereby when any websocket closes, it waits `shutdown_delay` seconds, and then checks if there are now any websocket connections. If not, then Eel closes. In case the user has closed the browser and wants to exit the program. By default, the value of **shutdown_delay** is `1.0` second From 5c875b081b3526898bfbd42163a57eee53de3908 Mon Sep 17 00:00:00 2001 From: Chris Knott Date: Tue, 19 Oct 2021 21:13:32 +0100 Subject: [PATCH 8/8] Update __init__.py I think the syntax of this multi-line string was not correct --- eel/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eel/__init__.py b/eel/__init__.py index effe4228..a630e1e1 100644 --- a/eel/__init__.py +++ b/eel/__init__.py @@ -156,8 +156,8 @@ def start(*start_urls, **kwargs): # verify shutdown_delay is correct value if not isinstance(_start_args['shutdown_delay'], (int, float)): - raise ValueError("`shutdown_delay` must be a number, \ - got a {}".format(type(_start_args['shutdown_delay'])) + raise ValueError("`shutdown_delay` must be a number, "\ + "got a {}".format(type(_start_args['shutdown_delay']))) # Launch the browser to the starting URLs show(*start_urls)