mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-11 20:29:15 -05:00
Fix CLI to work with mode settings
This commit is contained in:
parent
30df0c4bd8
commit
f6f4665e30
@ -26,6 +26,7 @@ from .common import Common
|
|||||||
from .web import Web
|
from .web import Web
|
||||||
from .onion import *
|
from .onion import *
|
||||||
from .onionshare import OnionShare
|
from .onionshare import OnionShare
|
||||||
|
from .mode_settings import ModeSettings
|
||||||
|
|
||||||
|
|
||||||
def build_url(common, app, web):
|
def build_url(common, app, web):
|
||||||
@ -177,14 +178,20 @@ def main(cwd=None):
|
|||||||
# Verbose mode?
|
# Verbose mode?
|
||||||
common.verbose = verbose
|
common.verbose = verbose
|
||||||
|
|
||||||
|
# Mode settings
|
||||||
|
mode_settings = ModeSettings(common)
|
||||||
|
|
||||||
# Create the Web object
|
# Create the Web object
|
||||||
web = Web(common, False, mode)
|
web = Web(common, False, mode_settings, mode)
|
||||||
|
|
||||||
# Start the Onion object
|
# Start the Onion object
|
||||||
onion = Onion(common)
|
onion = Onion(common)
|
||||||
try:
|
try:
|
||||||
onion.connect(
|
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:
|
except KeyboardInterrupt:
|
||||||
print("")
|
print("")
|
||||||
|
@ -191,7 +191,14 @@ class Onion(object):
|
|||||||
config=False,
|
config=False,
|
||||||
tor_status_update_func=None,
|
tor_status_update_func=None,
|
||||||
connect_timeout=120,
|
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")
|
self.common.log("Onion", "connect")
|
||||||
|
|
||||||
# Either use settings that are passed in, or use them from common
|
# Either use settings that are passed in, or use them from common
|
||||||
@ -205,6 +212,7 @@ class Onion(object):
|
|||||||
self.settings = self.common.settings
|
self.settings = self.common.settings
|
||||||
|
|
||||||
strings.load_strings(self.common)
|
strings.load_strings(self.common)
|
||||||
|
|
||||||
# The Tor controller
|
# The Tor controller
|
||||||
self.c = None
|
self.c = None
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ class ReceiveModeRequest(Request):
|
|||||||
date_dir = now.strftime("%Y-%m-%d")
|
date_dir = now.strftime("%Y-%m-%d")
|
||||||
time_dir = now.strftime("%H.%M.%S")
|
time_dir = now.strftime("%H.%M.%S")
|
||||||
self.receive_mode_dir = os.path.join(
|
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
|
# Create that directory, which shouldn't exist yet
|
||||||
@ -358,14 +358,9 @@ class ReceiveModeRequest(Request):
|
|||||||
except:
|
except:
|
||||||
self.content_length = 0
|
self.content_length = 0
|
||||||
|
|
||||||
print(
|
date_str = datetime.now().strftime("%b %d, %I:%M%p")
|
||||||
"{}: {}".format(
|
size_str = self.web.common.human_readable_filesize(self.content_length)
|
||||||
datetime.now().strftime("%b %d, %I:%M%p"),
|
print(f"{date_str}: Upload of total size {size_str} is starting")
|
||||||
strings._("receive_mode_upload_starting").format(
|
|
||||||
self.web.common.human_readable_filesize(self.content_length)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Don't tell the GUI that a request has started until we start receiving files
|
# Don't tell the GUI that a request has started until we start receiving files
|
||||||
self.told_gui_about_request = False
|
self.told_gui_about_request = False
|
||||||
@ -453,10 +448,10 @@ class ReceiveModeRequest(Request):
|
|||||||
if self.previous_file != filename:
|
if self.previous_file != filename:
|
||||||
self.previous_file = filename
|
self.previous_file = filename
|
||||||
|
|
||||||
print(
|
size_str = self.web.common.human_readable_filesize(
|
||||||
f"\r=> {self.web.common.human_readable_filesize(self.progress[filename]['uploaded_bytes'])} {filename}",
|
self.progress[filename]["uploaded_bytes"]
|
||||||
end="",
|
|
||||||
)
|
)
|
||||||
|
print(f"\r=> {size_str} {filename} ", end="")
|
||||||
|
|
||||||
# Update the GUI on the upload progress
|
# Update the GUI on the upload progress
|
||||||
if self.told_gui_about_request:
|
if self.told_gui_about_request:
|
||||||
|
@ -170,7 +170,6 @@
|
|||||||
"gui_website_mode_no_files": "No Website Shared Yet",
|
"gui_website_mode_no_files": "No Website Shared Yet",
|
||||||
"gui_receive_mode_no_files": "No Files Received Yet",
|
"gui_receive_mode_no_files": "No Files Received Yet",
|
||||||
"gui_receive_mode_autostop_timer_waiting": "Waiting to finish receiving",
|
"gui_receive_mode_autostop_timer_waiting": "Waiting to finish receiving",
|
||||||
"receive_mode_upload_starting": "Upload of total size {} is starting",
|
|
||||||
"days_first_letter": "d",
|
"days_first_letter": "d",
|
||||||
"hours_first_letter": "h",
|
"hours_first_letter": "h",
|
||||||
"minutes_first_letter": "m",
|
"minutes_first_letter": "m",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user