mirror of
				https://github.com/onionshare/onionshare.git
				synced 2025-10-31 06:19:16 -04:00 
			
		
		
		
	Make helpers.get_pyinstaller_resource_path work when package is not frozen, and make tests report real platform to get accurate paths
This commit is contained in:
		
							parent
							
								
									ef5665b050
								
							
						
					
					
						commit
						e8ce6b1c54
					
				
					 2 changed files with 11 additions and 6 deletions
				
			
		|  | @ -36,13 +36,16 @@ def get_pyinstaller_resource_path(filename): | |||
|     """ | ||||
|     Returns the path a resource file in a frozen PyInstall app | ||||
|     """ | ||||
|     # Resource path from frozen PyInstaller app | ||||
|     # Check if app is "frozen" with pyinstaller | ||||
|     # https://pythonhosted.org/PyInstaller/#run-time-information | ||||
|     p = get_platform() | ||||
|     if p == 'Darwin': | ||||
|         return os.path.join(os.path.join(os.path.dirname(sys._MEIPASS), 'Resources'), filename) | ||||
|     elif p == 'Windows': | ||||
|         return os.path.join(sys._MEIPASS, filename) | ||||
|     if getattr(sys, 'frozen', False): | ||||
|         p = get_platform() | ||||
|         if p == 'Darwin': | ||||
|             return os.path.join(os.path.join(os.path.dirname(sys._MEIPASS), 'Resources'), filename) | ||||
|         elif p == 'Windows': | ||||
|             return os.path.join(sys._MEIPASS, filename) | ||||
|     else: | ||||
|         return os.path.join(os.path.dirname(os.path.dirname(__file__)), filename) | ||||
| 
 | ||||
| def get_html_path(filename): | ||||
|     """ | ||||
|  |  | |||
|  | @ -23,5 +23,7 @@ import test_helpers | |||
| 
 | ||||
| def test_get_platform_returns_platform_system(): | ||||
|     """get_platform() returns platform.system() when ONIONSHARE_PLATFORM is not defined""" | ||||
|     p = helpers.platform.system | ||||
|     helpers.platform.system = lambda: 'Sega Saturn' | ||||
|     assert helpers.get_platform() == 'Sega Saturn' | ||||
|     helpers.platform.system = p | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Micah Lee
						Micah Lee