open folder and select file on osx

This commit is contained in:
j 2015-11-30 18:07:07 +01:00
parent 2ea25949ed
commit 1e17e4a9d1
2 changed files with 16 additions and 6 deletions

View file

@ -339,6 +339,6 @@ def openFolder(data):
if item:
path = item.get_path()
if path:
utils.open_folder(os.path.dirname(path))
utils.open_folder(path=path)
return response
actions.register(openFolder, cache=False)

View file

@ -331,8 +331,18 @@ def makefolder(path):
os.makedirs(dirname)
def open_folder(folder):
cmd = 'open'
if sys.platform.startswith('linux'):
cmd = 'xdg-open'
subprocess.Popen([cmd, folder], close_fds=True)
def open_folder(folder=None, path=None):
cmd = []
if path and not folder:
folder = os.path.dirname(path)
if folder and not path:
path = folder
if sys.platform == 'darwin':
if folder and not path:
path = folder
cmd += ['open', '-R', path]
elif sys.platform.startswith('linux'):
cmd += ['xdg-open', folder]
else:
logger.debug('unsupported platform %s', sys.platform)
subprocess.Popen(cmd, close_fds=True)