From e9ef087c8fcb3839eb77aa090de0a66f38e8e581 Mon Sep 17 00:00:00 2001 From: Max1Truc Date: Wed, 27 Oct 2021 11:47:17 +0200 Subject: [PATCH 1/3] Fix "KeyError: 'fr'" in desktop strings.py --- desktop/src/onionshare/strings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/desktop/src/onionshare/strings.py b/desktop/src/onionshare/strings.py index c4192a33..55f56788 100644 --- a/desktop/src/onionshare/strings.py +++ b/desktop/src/onionshare/strings.py @@ -43,7 +43,11 @@ def load_strings(common, locale_dir): current_locale = common.settings.get("locale") strings = {} for s in translations[default_locale]: - if s in translations[current_locale] and translations[current_locale][s] != "": + if ( + current_locale in translations + and s in translations[current_locale] + and translations[current_locale][s] != "" + ): strings[s] = translations[current_locale][s] else: strings[s] = translations[default_locale][s] From f5e4d70731274be3f4cc3c8ad4c9e1b65ffa0ccc Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Fri, 12 Nov 2021 11:43:09 +1100 Subject: [PATCH 2/3] Remove unnecessary censorship class invocation, which breaks CLI mode right now. Fix Website and Chat modes with auto-stop timer in CLI mode. Add 'poetry run onionshare-cli' tests to CircleCI to catch CLI runtime bugs. --- .circleci/config.yml | 4 ++++ cli/onionshare_cli/__init__.py | 28 +++++++++++----------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 175595f3..b9938c28 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,6 +30,10 @@ jobs: command: | cd ~/repo/cli poetry run pytest -v ./tests + poetry run onionshare-cli --local-only ./tests --auto-stop-timer 2 + poetry run onionshare-cli --local-only --receive --auto-stop-timer 2 + poetry run onionshare-cli --local-only --website ../docs --auto-stop-timer 2 + poetry run onionshare-cli --local-only --chat --auto-stop-timer 2 test-gui: docker: diff --git a/cli/onionshare_cli/__init__.py b/cli/onionshare_cli/__init__.py index 4e34a508..1c26b050 100644 --- a/cli/onionshare_cli/__init__.py +++ b/cli/onionshare_cli/__init__.py @@ -27,8 +27,6 @@ from datetime import datetime from datetime import timedelta from .common import Common, CannotFindTor -from .censorship import CensorshipCircumvention -from .meek import Meek, MeekNotRunning from .web import Web from .onion import TorErrorProtocolError, TorTooOldEphemeral, TorTooOldStealth, Onion from .onionshare import OnionShare @@ -285,20 +283,6 @@ def main(cwd=None): # Create the Web object web = Web(common, False, mode_settings, mode) - # Create the Meek object and start the meek client - # meek = Meek(common) - # meek.start() - - # Create the CensorshipCircumvention object to make - # API calls to Tor over Meek - censorship = CensorshipCircumvention(common, meek) - # Example: request recommended bridges, pretending to be from China, using - # domain fronting. - # censorship_recommended_settings = censorship.request_settings(country="cn") - # print(censorship_recommended_settings) - # Clean up the meek subprocess once we're done working with the censorship circumvention API - # meek.cleanup() - # Start the Onion object try: onion = Onion(common, use_tmp_dir=True) @@ -474,12 +458,18 @@ def main(cwd=None): if app.autostop_timer > 0: # if the auto-stop timer was set and has run out, stop the server if not app.autostop_timer_thread.is_alive(): - if mode == "share" or (mode == "website"): + if mode == "share": # If there were no attempts to download the share, or all downloads are done, we can stop if web.share_mode.cur_history_id == 0 or web.done: print("Stopped because auto-stop timer ran out") web.stop(app.port) break + if mode == "website": + # If there were no attempts to visit the website, or all downloads are done, we can stop + if web.website_mode.cur_history_id == 0 or web.done: + print("Stopped because auto-stop timer ran out") + web.stop(app.port) + break if mode == "receive": if ( web.receive_mode.cur_history_id == 0 @@ -489,6 +479,10 @@ def main(cwd=None): web.stop(app.port) break web.receive_mode.can_upload = False + if mode == "chat": + print("Stopped because auto-stop timer ran out") + web.stop(app.port) + break # Allow KeyboardInterrupt exception to be handled with threads # https://stackoverflow.com/questions/3788208/python-threading-ignores-keyboardinterrupt-exception time.sleep(0.2) From 80e73162498f06985f7892caca06888ec1849338 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Fri, 12 Nov 2021 11:58:48 +1100 Subject: [PATCH 3/3] Allow website mode to stop even if people have viewed it --- cli/onionshare_cli/__init__.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cli/onionshare_cli/__init__.py b/cli/onionshare_cli/__init__.py index 1c26b050..060c5628 100644 --- a/cli/onionshare_cli/__init__.py +++ b/cli/onionshare_cli/__init__.py @@ -464,13 +464,7 @@ def main(cwd=None): print("Stopped because auto-stop timer ran out") web.stop(app.port) break - if mode == "website": - # If there were no attempts to visit the website, or all downloads are done, we can stop - if web.website_mode.cur_history_id == 0 or web.done: - print("Stopped because auto-stop timer ran out") - web.stop(app.port) - break - if mode == "receive": + elif mode == "receive": if ( web.receive_mode.cur_history_id == 0 or not web.receive_mode.uploads_in_progress @@ -479,7 +473,8 @@ def main(cwd=None): web.stop(app.port) break web.receive_mode.can_upload = False - if mode == "chat": + else: + # website or chat mode print("Stopped because auto-stop timer ran out") web.stop(app.port) break