diff options
author | Micah Lee <micah@micahflee.com> | 2019-11-02 14:56:40 -0700 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2019-11-02 14:56:40 -0700 |
commit | b8f12994962a402555fcd153f56e1c23d71c5d57 (patch) | |
tree | 65e6c141d758013d0404f0df8821d682f8161959 /onionshare | |
parent | 12a1d73f91586cab4fee019cc96af859d9fd2f19 (diff) | |
download | onionshare-b8f12994962a402555fcd153f56e1c23d71c5d57.tar.gz onionshare-b8f12994962a402555fcd153f56e1c23d71c5d57.zip |
Fix CLI to work with mode settings
Diffstat (limited to 'onionshare')
-rw-r--r-- | onionshare/__init__.py | 11 | ||||
-rw-r--r-- | onionshare/onion.py | 8 | ||||
-rw-r--r-- | onionshare/web/receive_mode.py | 19 |
3 files changed, 24 insertions, 14 deletions
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: |