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: if item:
path = item.get_path() path = item.get_path()
if path: if path:
utils.open_folder(os.path.dirname(path)) utils.open_folder(path=path)
return response return response
actions.register(openFolder, cache=False) actions.register(openFolder, cache=False)

View file

@ -331,8 +331,18 @@ def makefolder(path):
os.makedirs(dirname) os.makedirs(dirname)
def open_folder(folder): def open_folder(folder=None, path=None):
cmd = 'open' cmd = []
if sys.platform.startswith('linux'): if path and not folder:
cmd = 'xdg-open' folder = os.path.dirname(path)
subprocess.Popen([cmd, folder], close_fds=True) 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)