From 3797e9e2039bbc0109222cd94e32557938ca8dad Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sat, 24 Feb 2018 18:38:40 -0800 Subject: [PATCH] When using , put the src in quotes. Otherwise the filename is likely to have spaces in it, and the src will break. Also, in Windows use backslashes for local resources instead of forward slashes --- onionshare/common.py | 6 +++++- onionshare_gui/onionshare_gui.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/onionshare/common.py b/onionshare/common.py index 79d62ca9..9703e0f5 100644 --- a/onionshare/common.py +++ b/onionshare/common.py @@ -57,7 +57,7 @@ def get_platform(): """ Returns the platform OnionShare is running on. """ - plat = platform.system() + plat = platform.system() if re.match('^.*BSD$', plat): plat = 'BSD' return plat @@ -69,6 +69,10 @@ def get_resource_path(filename): """ p = get_platform() + # On Windows, and in Windows dev mode, switch slashes in incoming filename to backslackes + if p == 'Windows': + filename = filename.replace('/', '\\') + if getattr(sys, 'onionshare_dev_mode', False): # Look for resources directory relative to python file prefix = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), 'share') diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 56a1967b..5c05ae18 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -684,7 +684,7 @@ class OnionShareGui(QtWidgets.QMainWindow): self.info_completed_downloads_image = common.get_resource_path('images/download_completed_none.png') else: self.info_completed_downloads_image = common.get_resource_path('images/download_completed.png') - self.info_completed_downloads_count.setText(' {1:d}'.format(self.info_completed_downloads_image, count)) + self.info_completed_downloads_count.setText(' {1:d}'.format(self.info_completed_downloads_image, count)) self.info_completed_downloads_count.setToolTip(strings._('info_completed_downloads_tooltip', True).format(count)) def update_downloads_in_progress(self, count): @@ -695,7 +695,7 @@ class OnionShareGui(QtWidgets.QMainWindow): self.info_in_progress_downloads_image = common.get_resource_path('images/download_in_progress_none.png') else: self.info_in_progress_downloads_image = common.get_resource_path('images/download_in_progress.png') - self.info_in_progress_downloads_count.setText(' {1:d}'.format(self.info_in_progress_downloads_image, count)) + self.info_in_progress_downloads_count.setText(' {1:d}'.format(self.info_in_progress_downloads_image, count)) self.info_in_progress_downloads_count.setToolTip(strings._('info_in_progress_downloads_tooltip', True).format(count)) def closeEvent(self, e):