Skip to content

Commit

Permalink
Merge pull request #447 from PokeyzRule/master
Browse files Browse the repository at this point in the history
added openfolder support for macOS and Windows
  • Loading branch information
z411 authored Jul 11, 2019
2 parents f92dd17 + dba15ba commit 44d40a9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
11 changes: 9 additions & 2 deletions trackma/ui/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,15 @@ def do_openfolder(self, args):
show = self._get_show(args[0])
filename = self.engine.get_episode_path(show, 1)
with open(os.devnull, 'wb') as DEVNULL:
subprocess.Popen(["/usr/bin/xdg-open",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
if sys.platform == 'darwin':
subprocess.Popen(["open",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
elif sys.platform == 'win32':
subprocess.Popen(["explorer",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
else:
subprocess.Popen(["/usr/bin/xdg-open",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
except OSError:
# xdg-open failed.
self.display_error("Could not open folder.")
Expand Down
11 changes: 9 additions & 2 deletions trackma/ui/curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,15 @@ def do_openfolder(self):
show = self.engine.get_show_info(item.showid)
filename = self.engine.get_episode_path(show, 1)
with open(os.devnull, 'wb') as DEVNULL:
subprocess.Popen(["/usr/bin/xdg-open",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
if sys.platform == 'darwin':
subprocess.Popen(["open",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
elif sys.platform == 'win32':
subprocess.Popen(["explorer",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
else:
subprocess.Popen(["/usr/bin/xdg-open",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
except OSError:
# xdg-open failed.
raise utils.EngineError("Could not open folder.")
Expand Down
16 changes: 13 additions & 3 deletions trackma/ui/gtk/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import sys
import os
import subprocess
import threading
Expand Down Expand Up @@ -562,9 +563,18 @@ def _open_folder(self, show_id):
try:
filename = self._engine.get_episode_path(show, 1)
with open(os.devnull, 'wb') as DEVNULL:
subprocess.Popen(["/usr/bin/xdg-open", os.path.dirname(filename)],
stdout=DEVNULL,
stderr=DEVNULL)
if sys.platform == 'darwin':
subprocess.Popen(["open", os.path.dirname(filename)],
stdout=DEVNULL,
stderr=DEVNULL)
elif sys.platform == 'win32':
subprocess.Popen(["explorer", os.path.dirname(filename)],
stdout=DEVNULL,
stderr=DEVNULL)
else:
subprocess.Popen(["/usr/bin/xdg-open", os.path.dirname(filename)],
stdout=DEVNULL,
stderr=DEVNULL)
except OSError:
# xdg-open failed.
raise utils.EngineError("Could not open folder.")
Expand Down
12 changes: 10 additions & 2 deletions trackma/ui/qt/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

pyqt_version = 5

import sys
import os
import datetime
import subprocess
Expand Down Expand Up @@ -1142,8 +1143,15 @@ def s_open_folder(self):
try:
filename = self.worker.engine.get_episode_path(show, 1)
with open(os.devnull, 'wb') as DEVNULL:
subprocess.Popen(["/usr/bin/xdg-open",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
if sys.platform == 'darwin':
subprocess.Popen(["open",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
elif sys.platform == 'win32':
subprocess.Popen(["explorer",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
else:
subprocess.Popen(["/usr/bin/xdg-open",
os.path.dirname(filename)], stdout=DEVNULL, stderr=DEVNULL)
except OSError:
# xdg-open failed.
raise utils.EngineError("Could not open folder.")
Expand Down

0 comments on commit 44d40a9

Please sign in to comment.