324 if current_OS ==
'Windows':
326 editor_note = subprocess.check_output(
'wmic process where "name=' +
"'notepad++.exe'" +
'" get ExecutablePath')
327 editor_sublime = subprocess.check_output(
'wmic process where "name=' +
"'sublime_text.exe'" +
'" get ExecutablePath')
328 editor_atom = subprocess.check_output(
'wmic process where "name=' +
"'atom.exe'" +
'" get ExecutablePath')
330 if 0 <= editor_note.find(
'notepad++.exe'):
331 start = editor_note.find(
'\n') + 1
332 end = editor_note.find(
'\n',start + 5) -4
333 editor_note = editor_note[ start : end]
334 command = file_path ,
' -n' + str(line_num) ,
' -c' + str(column_num)
335 subprocess.Popen([editor_note, command])
337 elif 0 <= editor_sublime.find(
'sublime_text.exe'):
338 start = editor_sublime.find(
'\n') + 1
339 end = editor_sublime.find(
'\n',start + 5) -4
340 editor_sublime = editor_sublime[ start : end]
341 command = file_path +
':' + line_num +
':' + column_num
342 subprocess.Popen([editor_sublime, command])
344 elif 0 <= editor_atom.find(
'atom.exe'):
345 start = editor_atom.find(
'\n') + 1
346 end = editor_atom.find(
'\n',start + 5) -4
347 editor_atom = editor_atom[ start : end]
348 command = file_path +
':' + str(line_num) +
':' + str(column_num)
349 subprocess.Popen([editor_atom, command])
354 elif current_OS ==
'Linux':
356 command = file_path +
':' + str(line_num) +
':' + str(column_num)
357 index_end = command.find(
',')
359 command = command[ : index_end]
360 running_apps = subprocess.Popen(
'ps ax -o cmd', stdout=subprocess.PIPE, shell=
True)
361 (output, err) = running_apps.communicate()
362 temp = output.split(
'\n')
364 def find_editor_linux(name, search_obj):
365 for line
in search_obj:
366 if 0 <= line.find(name):
371 (success_sublime, editor_path_sublime) = find_editor_linux(
'sublime_text',temp)
372 (success_atom, editor_path_atom) = find_editor_linux(
'atom',temp)
375 subprocess.Popen([editor_path_sublime, command])
378 subprocess.Popen([editor_path_atom, command])
381 os.system(
'xdg-open ' + file_path )
383 elif current_OS ==
'Darwin':
385 command = file_path +
':' + str(line_num) +
':' + str(column_num)
386 index_end = command.find(
',')
388 command = command[ : index_end]
389 running_apps = subprocess.Popen(
'ps axwww -o command', stdout=subprocess.PIPE, shell=
True)
390 (output, err) = running_apps.communicate()
391 temp = output.split(
'\n')
393 def find_editor_mac(name, search_obj):
394 for line
in search_obj:
395 if 0 <= line.find(name):
397 if 0 <= path.find(
'-psn'):
398 path = path[ : path.find(
'-psn') - 1 ]
402 (success_sublime, editor_path_sublime) = find_editor_mac(
'Sublime',temp)
403 (success_atom, editor_path_atom) = find_editor_mac(
'Atom',temp)
406 subprocess.Popen([editor_path_sublime, command])
409 subprocess.Popen([editor_path_atom, command])
412 os.system(
'open ' + file_path )