diff --git a/oml/api.py b/oml/api.py index f2f5448..3253645 100644 --- a/oml/api.py +++ b/oml/api.py @@ -2,9 +2,11 @@ # vi:si:et:sw=4:sts=4:ts=4 -import subprocess +from os.path import normpath, dirname, abspath, join import json import os +import subprocess +import sys import ox from oxtornado import actions @@ -16,6 +18,14 @@ import update import logging logger = logging.getLogger(__name__) +def win32_ui(type): + base = normpath(dirname(dirname(dirname(abspath(__file__))))) + cmd = [ + join(base, 'platform_win32', 'python.exe'), + join(base, 'openmediablirary', 'oml', 'ui.py'), type + ] + return cmd + def selectFolder(data): ''' returns { @@ -23,6 +33,8 @@ def selectFolder(data): } ''' cmd = ['./ctl', 'ui', 'folder'] + if sys.platform == 'win32': + cmd = win32_ui('folder') p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True) stdout, stderr = p.communicate() path = stdout.decode('utf-8').strip() @@ -39,6 +51,8 @@ def selectFile(data): } ''' cmd = ['./ctl', 'ui', 'file'] + if sys.platform == 'win32': + cmd = win32_ui('file') p = subprocess.Popen(cmd, stdout=subprocess.PIPE) stdout, stderr = p.communicate() path = stdout.decode('utf-8').strip()