Цель :
Я пытаюсь использовать AppleScript, чтобы определить, работает ли python
или ipython
в Терминале.
(Для простоты , Я предполагаю, что только один из python
или ipython
работает.)
Проблема :
Скрипт ниже неправильно устанавливает isIPythonRunning
в true когда:
ipython
был запущен, затем завершился, тогда python
был запущен
Вопрос :
Как изменить isIPythonRunning
на guish между python
и ipython
?
tell application "Terminal"
activate
set win to (get first window)
set currentTab to (selected tab of win)
set procs to processes of currentTab
set proc to (end of procs)
-- "isPythonRunning" is true regardless of whether python or ipython is running
set isPythonRunning to (proc is "python")
-- "isIPythonRunning" is true if ipython is now running, or has been run then quit
set windowName to name of win
set isIPythonRunning to (windowName contains "ipython")
if isIPythonRunning then
-- this is incorrect when:
-- IPython has been run, then quit, then python has been launched
display dialog "IPython is running!"
else
display dialog "Python is running!"
end if
end tell