diff --git a/onionshare/__init__.py b/onionshare/__init__.py index a2d6d4a1..a85de871 100644 --- a/onionshare/__init__.py +++ b/onionshare/__init__.py @@ -26,6 +26,7 @@ from .common import Common from .web import Web from .onion import * from .onionshare import OnionShare +from .mode_settings import ModeSettings def build_url(common, app, web): @@ -177,14 +178,20 @@ def main(cwd=None): # Verbose mode? common.verbose = verbose + # Mode settings + mode_settings = ModeSettings(common) + # Create the Web object - web = Web(common, False, mode) + web = Web(common, False, mode_settings, mode) # Start the Onion object onion = Onion(common) try: onion.connect( - custom_settings=False, config=config, connect_timeout=connect_timeout + custom_settings=False, + config=config, + connect_timeout=connect_timeout, + local_only=local_only, ) except KeyboardInterrupt: print("") diff --git a/onionshare/onion.py b/onionshare/onion.py index 95a31244..15709bd6 100644 --- a/onionshare/onion.py +++ b/onionshare/onion.py @@ -191,7 +191,14 @@ class Onion(object): config=False, tor_status_update_func=None, connect_timeout=120, + local_only=False, ): + if local_only: + self.common.log( + "Onion", "connect", "--local-only, so skip trying to connect" + ) + return + self.common.log("Onion", "connect") # Either use settings that are passed in, or use them from common @@ -205,6 +212,7 @@ class Onion(object): self.settings = self.common.settings strings.load_strings(self.common) + # The Tor controller self.c = None diff --git a/onionshare/web/receive_mode.py b/onionshare/web/receive_mode.py index 55f0df8c..17613fdd 100644 --- a/onionshare/web/receive_mode.py +++ b/onionshare/web/receive_mode.py @@ -292,7 +292,7 @@ class ReceiveModeRequest(Request): date_dir = now.strftime("%Y-%m-%d") time_dir = now.strftime("%H.%M.%S") self.receive_mode_dir = os.path.join( - self.web.settings.get("website", "data_dir"), date_dir, time_dir + self.web.settings.get("receive", "data_dir"), date_dir, time_dir ) # Create that directory, which shouldn't exist yet @@ -358,14 +358,9 @@ class ReceiveModeRequest(Request): except: self.content_length = 0 - print( - "{}: {}".format( - datetime.now().strftime("%b %d, %I:%M%p"), - strings._("receive_mode_upload_starting").format( - self.web.common.human_readable_filesize(self.content_length) - ), - ) - ) + date_str = datetime.now().strftime("%b %d, %I:%M%p") + size_str = self.web.common.human_readable_filesize(self.content_length) + print(f"{date_str}: Upload of total size {size_str} is starting") # Don't tell the GUI that a request has started until we start receiving files self.told_gui_about_request = False @@ -453,10 +448,10 @@ class ReceiveModeRequest(Request): if self.previous_file != filename: self.previous_file = filename - print( - f"\r=> {self.web.common.human_readable_filesize(self.progress[filename]['uploaded_bytes'])} {filename}", - end="", + size_str = self.web.common.human_readable_filesize( + self.progress[filename]["uploaded_bytes"] ) + print(f"\r=> {size_str} {filename} ", end="") # Update the GUI on the upload progress if self.told_gui_about_request: diff --git a/share/locale/en.json b/share/locale/en.json index 14695658..5425a336 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -170,7 +170,6 @@ "gui_website_mode_no_files": "No Website Shared Yet", "gui_receive_mode_no_files": "No Files Received Yet", "gui_receive_mode_autostop_timer_waiting": "Waiting to finish receiving", - "receive_mode_upload_starting": "Upload of total size {} is starting", "days_first_letter": "d", "hours_first_letter": "h", "minutes_first_letter": "m",