From 41b4cea673d5b1ea43e2d7eda6caecd9a77bde3c Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 19 Sep 2018 11:24:19 +1000 Subject: Open folder containing uploads with the file selected, in macOS and Windows --- onionshare_gui/receive_mode/uploads.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/onionshare_gui/receive_mode/uploads.py b/onionshare_gui/receive_mode/uploads.py index 1aebe902..4a383421 100644 --- a/onionshare_gui/receive_mode/uploads.py +++ b/onionshare_gui/receive_mode/uploads.py @@ -92,15 +92,11 @@ class File(QtWidgets.QWidget): # macOS elif self.common.platform == 'Darwin': - # TODO: Implement opening folder with file selected in macOS - # This seems helpful: https://stackoverflow.com/questions/3520493/python-show-in-finder - self.common.log('File', 'open_folder', 'not implemented for Darwin yet') + subprocess.call(['open', '-R', abs_filename]) # Windows elif self.common.platform == 'Windows': - # TODO: Implement opening folder with file selected in Windows - # This seems helpful: https://stackoverflow.com/questions/6631299/python-opening-a-folder-in-explorer-nautilus-mac-thingie - self.common.log('File', 'open_folder', 'not implemented for Windows yet') + webbrowser.Popen(['explorer', '/select', abs_filename]) class Upload(QtWidgets.QWidget): -- cgit v1.2.3-54-g00ecf From 388f96855663d4f69bf0ed88b8feab68cd7e5877 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 19 Sep 2018 11:27:36 +1000 Subject: fix function name for windows --- onionshare_gui/receive_mode/uploads.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onionshare_gui/receive_mode/uploads.py b/onionshare_gui/receive_mode/uploads.py index 4a383421..bf502f99 100644 --- a/onionshare_gui/receive_mode/uploads.py +++ b/onionshare_gui/receive_mode/uploads.py @@ -96,7 +96,7 @@ class File(QtWidgets.QWidget): # Windows elif self.common.platform == 'Windows': - webbrowser.Popen(['explorer', '/select', abs_filename]) + subprocess.Popen(['explorer', '/select', abs_filename]) class Upload(QtWidgets.QWidget): -- cgit v1.2.3-54-g00ecf From f45eae5768f75d2843f835a135708f1b521f0068 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 19 Sep 2018 12:12:18 +1000 Subject: Fix syntax for opening explorer and selecting the filename. Fix a bug in the downloads_dir for Windows (need to use a backslash) --- onionshare/settings.py | 10 +++++++--- onionshare_gui/receive_mode/uploads.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/onionshare/settings.py b/onionshare/settings.py index adcfc7a3..073798e5 100644 --- a/onionshare/settings.py +++ b/onionshare/settings.py @@ -105,9 +105,13 @@ class Settings(object): """ Returns the path of the default Downloads directory for receive mode. """ - # TODO: Test in Windows, though it looks like it should work - # https://docs.python.org/3/library/os.path.html#os.path.expanduser - return os.path.expanduser('~/OnionShare') + # On Windows, os.path.expanduser() needs to use backslash, or else it + # retains the forward slash, which breaks opening the folder in explorer. + p = platform.system() + if p == 'Windows': + return os.path.expanduser('~\OnionShare') + else: + return os.path.expanduser('~/OnionShare') def load(self): """ diff --git a/onionshare_gui/receive_mode/uploads.py b/onionshare_gui/receive_mode/uploads.py index bf502f99..8d95d984 100644 --- a/onionshare_gui/receive_mode/uploads.py +++ b/onionshare_gui/receive_mode/uploads.py @@ -96,7 +96,7 @@ class File(QtWidgets.QWidget): # Windows elif self.common.platform == 'Windows': - subprocess.Popen(['explorer', '/select', abs_filename]) + subprocess.Popen(['explorer', '/select,{}'.format(abs_filename)]) class Upload(QtWidgets.QWidget): -- cgit v1.2.3-54-g00ecf