Skip to content

Commit

Permalink
improve Windows UX
Browse files Browse the repository at this point in the history
  • Loading branch information
mechatroner committed Mar 21, 2018
1 parent cb93dfc commit 3361947
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,24 +286,24 @@ def on_query_done(input_line):
file_path = active_view.file_name()
if not file_path:
# TODO create a temp file from unnamed buffer
sublime.error_message('Error. Unable to run query for this buffer')
sublime.error_message('RBQL Error. Unable to run query for this buffer')
return
input_delim = active_view.settings().get('rainbow_delim')
input_policy = active_view.settings().get('rainbow_policy')
meta_language = active_view.settings().get('rbql_meta_language', 'python')
output_format = active_view.settings().get('rbql_output_format', 'input')
format_map = {'input': (input_delim, input_policy), 'csv': (',', 'quoted'), 'tsv': ('\t', 'simple')}
if output_format not in format_map:
sublime.error_message('Error. "rbql_output_format" must be in [{}]'.format(', '.join(format_map.keys())))
sublime.error_message('RBQL Error. "rbql_output_format" must be in [{}]'.format(', '.join(format_map.keys())))
return
output_delim, output_policy = format_map[output_format]
query_result = sublime_rbql.converged_execute(meta_language, file_path, input_line, input_delim, input_policy, output_delim, output_policy)
error_type, error_details, warnings, dst_table_path = query_result
if error_type is not None:
sublime.error_message('{}. {}'.format(error_type, error_details))
sublime.error_message('Unable to execute RBQL query :(\nEdit your query and try again!\n\n\n\n\n=============================\nDetails:\n{}\n{}'.format(error_type, error_details))
return
if not dst_table_path or not os.path.exists(dst_table_path):
sublime.error_message('Unknown Error: Unable to find destination file')
sublime.error_message('Unknown RBQL Error: Unable to find destination file')
return
if warnings is not None and len(warnings):
warning_report = 'Warning!\n' + '\n'.join(warnings)
Expand Down
8 changes: 7 additions & 1 deletion sublime_rbql.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ def execute_js(src_table_path, rainbow_query, input_delim, input_policy, out_del
except rbql.RBParsingError as e:
return ('Parsing Error', str(e), warnings)
cmd = ['node', meta_script_path]
pobj = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if os.name == 'nt': # Windows
# Without startupinfo magic Windows will show console window for a longer period.
si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
pobj = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=si)
else:
pobj = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out_data, err_data = pobj.communicate()
error_code = pobj.returncode

Expand Down

0 comments on commit 3361947

Please sign in to comment.