mirror of
				https://github.com/onionshare/onionshare.git
				synced 2025-10-30 22:09:08 -04:00 
			
		
		
		
	Fix CLI to work with mode settings
This commit is contained in:
		
							parent
							
								
									12a1d73f91
								
							
						
					
					
						commit
						b8f1299496
					
				
					 4 changed files with 24 additions and 15 deletions
				
			
		|  | @ -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("") | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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: | ||||
|  |  | |||
|  | @ -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", | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Micah Lee
						Micah Lee