#!/usr/bin/osascript

on run argv
   tell application "Finder"
      set base_path to container of (container of (path to me)) as alias
   end tell
   set env_activate to "source " & quoted form of ((POSIX path of base_path) & "env/bin/activate") & ";"
   set run_server_and_terminate to ( " python" & " -m" & " bumps.webview.server --use_persistent_path;" & " exit;")
   if application "Terminal" is not running then
      tell application "Terminal"
         activate
         set currentTab to do script (env_activate & run_server_and_terminate) in window 1
      end tell
   else
      tell application "Terminal"
         set currentTab to do script (env_activate & run_server_and_terminate)
      end tell
   end if
end run
