win32 select folder/file

This commit is contained in:
j 2019-01-20 18:40:04 +05:30
parent ff671141f5
commit c602aab915

View file

@ -2,9 +2,11 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
import subprocess from os.path import normpath, dirname, abspath, join
import json import json
import os import os
import subprocess
import sys
import ox import ox
from oxtornado import actions from oxtornado import actions
@ -16,6 +18,14 @@ import update
import logging import logging
logger = logging.getLogger(__name__) 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): def selectFolder(data):
''' '''
returns { returns {
@ -23,6 +33,8 @@ def selectFolder(data):
} }
''' '''
cmd = ['./ctl', 'ui', 'folder'] cmd = ['./ctl', 'ui', 'folder']
if sys.platform == 'win32':
cmd = win32_ui('folder')
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
path = stdout.decode('utf-8').strip() path = stdout.decode('utf-8').strip()
@ -39,6 +51,8 @@ def selectFile(data):
} }
''' '''
cmd = ['./ctl', 'ui', 'file'] cmd = ['./ctl', 'ui', 'file']
if sys.platform == 'win32':
cmd = win32_ui('file')
p = subprocess.Popen(cmd, stdout=subprocess.PIPE) p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
path = stdout.decode('utf-8').strip() path = stdout.decode('utf-8').strip()