update

update

global num_servers
set num_servers to 7

on open_window_tabs()
	tell application "Terminal"
		activate
		-- Open a new window
		--   http://superuser.com/questions/195633/applescript-to-open-a-new-terminal-window-in-current-space
		do script "clear"
		-- set currentWindow to front window

		-- Open new tabs
		repeat (num_servers * 2 - 1) times
			tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
		end repeat
	end tell
end open_window_tabs

on ssh()
	tell application "Terminal"
		set currentWindow to front window

		-- Without the delay, some connections are not made.
		set delay_after_ssh to 0.5

		set tab_id to 0
		set s_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "sshs" & s_id
			do script (cmd) in tab tab_id of currentWindow
			delay delay_after_ssh

			set tab_id to tab_id + 1
			set cmd to "sshc" & s_id
			do script (cmd) in tab tab_id of currentWindow
			delay delay_after_ssh

			set s_id to s_id + 1
		end repeat
	end tell
end ssh

on screen()
	tell application "Terminal"
		set currentWindow to front window

		set tab_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "screen"
			do script (cmd) in tab tab_id of currentWindow
			set cmd to " "
			do script (cmd) in tab tab_id of currentWindow
		end repeat
	end tell
end screen

on install_pkgs_0()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "sudo add-apt-repository -y ppa:webupd8team/java && sudo apt-get update && sudo apt-get install oracle-java8-installer git ctags ant htop tree maven gnuplot-nox ntp ioping realpath make gcc cmake g++ libboost-dev libboost-system-dev libboost-timer-dev collectl -y && sudo apt-get autoremove -y vim-tiny && mkdir -p ~/work && cd ~/work && git clone https://github.com/hoytech/vmtouch.git && cd vmtouch && make -j && sudo make install && sudo service ntp stop && sudo ntpdate -bv 0.ubuntu.pool.ntp.org && sudo service ntp start && cd ~/work && git clone git@github.com:hobinyoon/linux-home.git && cd linux-home && ./setup-linux.sh"
			do script (cmd) in tab tab_id of currentWindow
		end repeat
	end tell
end install_pkgs_0

on install_pkgs_1()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is (num_servers * 2)
		set tab_id to tab_id + 1
		tell application "System Events" to key code 36 -- enter
		delay 0.2
		tell application "System Events" to key code 123 -- left
		tell application "System Events" to key code 36 -- enter
		tell application "System Events" to key code 124 using {shift down, command down} -- move to the next tab
		delay 0.1
	end repeat
end install_pkgs_1

-- Sometimes the previous step takes forever. Need to make sure.
on install_pkgs_2()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "yes"
			do script (cmd) in tab tab_id of currentWindow
			delay 0.1
		end repeat
	end tell
end install_pkgs_2

on killall_screen()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "killall screen"
			do script (cmd) in tab tab_id of currentWindow
		end repeat
	end tell
end killall_screen

on exit_screen()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "d" using {control down}
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "X"

		tell application "System Events" to keystroke "d" using {control down}
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "X"

		tell application "System Events" to keystroke "d" using {control down}
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "X"

		tell application "System Events" to keystroke "d" using {control down}
		tell application "System Events" to keystroke "d" using {control down}
		delay 0.1

		-- Move to the right
		tell application "System Events" to key code 124 using {shift down, command down}

		tell application "System Events" to keystroke "d" using {control down}
		tell application "System Events" to keystroke "d" using {control down}
		delay 0.1

		-- Move to the right
		tell application "System Events" to key code 124 using {shift down, command down}
	end repeat
end exit_screen

on server_screen_split_htop()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "S"
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "c"
		tell application "System Events" to keystroke "htop"
		tell application "System Events" to key code 36

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "S"
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "c"
		tell application "System Events" to keystroke "watch -n 0.5 \"free -mt\""
		tell application "System Events" to key code 36

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "S"
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "c"

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		-- Move 2 to the right, since S and C take turns.
		--   124: right arrow
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end server_screen_split_htop

on client_screen_split_htop()
	tell application "Terminal" to activate
	set tab_id to 0
	-- Start from the 2nd tab, which is the first client tab
	tell application "System Events" to key code 124 using {shift down, command down}
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "S"
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "c"
		tell application "System Events" to keystroke "htop"
		tell application "System Events" to key code 36

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		-- Move 2 to the right, since S and C take turns.
		--   124: right arrow
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat

	-- Set the current tab to the 1st one
	tell application "System Events" to key code 123 using {shift down, command down}

end client_screen_split_htop

on build_cass_pressuremem_loadgen()
	tell application "Terminal"
		set currentWindow to front window

		-- Without the delay, some connections are not made.
		set delay_after_ssh to 0.2

		set tab_id to 0
		set s_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "cd ~/work && git clone git@github.com:hobinyoon/apache-cassandra-2.2.3-src.git && ln -s ~/work/apache-cassandra-2.2.3-src ~/work/cassandra && cd ~/work/cassandra/mtdb/tools/pressure-memory && mkdir -p .build && cd .build && cmake .. && make -j && cdcass && time ant"
			do script (cmd) in tab tab_id of currentWindow
			delay delay_after_ssh

			set tab_id to tab_id + 1
			set cmd to "cd ~/work && git clone git@github.com:hobinyoon/apache-cassandra-2.2.3-src.git && ln -s ~/work/apache-cassandra-2.2.3-src ~/work/cassandra && cd ~/work/cassandra/mtdb/loadgen && ./loadgen"
			do script (cmd) in tab tab_id of currentWindow
			delay delay_after_ssh

			set s_id to s_id + 1
		end repeat
	end tell
end build_cass_pressuremem_loadgen

on git_pull()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is (num_servers * 2)
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "c" using {control down}

		-- Move to the next tab
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat

	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "cdcass && git pull"
			do script (cmd) in tab tab_id of currentWindow
		end repeat
	end tell
end git_pull

on server_format_ebs_mag_mount_prepare_dirs()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "sudo mkfs.ext4 -m 0 /dev/xvdd && sudo cp ~/work/cassandra/mtdb/ec2-tools/etc-fstab /etc/fstab && sudo umount /mnt && sudo mkdir -p /mnt/local-ssd && sudo mount /mnt/local-ssd && sudo chown -R ubuntu /mnt/local-ssd && mkdir /mnt/local-ssd/cass-data && mkdir ~/cass-data-vol && sudo ln -s ~/cass-data-vol /mnt/ebs-ssd-gp2 && mkdir /mnt/ebs-ssd-gp2/cass-data && sudo mkdir -p /mnt/ebs-mag && sudo mount /mnt/ebs-mag && sudo mkdir /mnt/ebs-mag/cass-data && sudo chown -R ubuntu /mnt/ebs-mag && sudo chown -R ubuntu /mnt/ebs-mag/cass-data && sudo mkdir -p /mnt/ebs-ssd-gp2/mtdb-cold && (sudo mkdir -p /mnt/ebs-mag/mtdb-cold || true) && sudo ln -s /mnt/ebs-mag /mnt/cold-storage && sudo chown -R ubuntu /mnt/ebs-ssd-gp2 && sudo chown -R ubuntu /mnt/cold-storage && sudo chown -R ubuntu /mnt/cold-storage/mtdb-cold && mkdir -p ~/work/cassandra/mtdb/logs/collectl && ln -s /mnt/local-ssd/cass-data ~/work/cassandra/data"
			do script (cmd) in tab tab_id of currentWindow

			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end server_format_ebs_mag_mount_prepare_dirs

on watch_free_mem()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		tell application "System Events" to keystroke "watch -n 0.5 \"free -mt\""
		tell application "System Events" to key code 36
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end watch_free_mem

on server_edit_cassandra_yaml()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			--			set cmd to "sed -i -r 's/^    migrate_to_cold_storage:.+/    migrate_to_cold_storage: true/' ~/work/cassandra/conf/cassandra.yaml"
			set cmd to "sed -i -r 's/^    migrate_to_cold_storage:.+/    migrate_to_cold_storage: false/' ~/work/cassandra/conf/cassandra.yaml"
			do script (cmd) in tab tab_id of currentWindow
			set cmd to "sed -i -r 's/^    tablet_coldness_threshold:.+/    tablet_coldness_threshold: 75/' ~/work/cassandra/conf/cassandra.yaml"
			do script (cmd) in tab tab_id of currentWindow

			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end server_edit_cassandra_yaml

on client_edit_cassandra_yaml()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 2
		repeat until tab_id > (num_servers * 2)
			set cmd to "sed -i -r 's/^        num_writes_per_simulation_time_mins:.+/        num_writes_per_simulation_time_mins: " & (tab_id * 5000) & "/' ~/work/cassandra/conf/cassandra.yaml"
			do script (cmd) in tab tab_id of currentWindow
			set cmd to "grep num_writes_per_simulation_time_mins: ~/work/cassandra/conf/cassandra.yaml"
			do script (cmd) in tab tab_id of currentWindow

			-- Go to the next client tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end client_edit_cassandra_yaml

on save_screen_layout()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is (num_servers * 2)
		set tab_id to tab_id + 1

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke ":layout save default"
		tell application "System Events" to key code 36

		-- Move to the next tab
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end save_screen_layout

-- One-time fix. Won't need again
on mkdir_collectl()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "mkdir ~/work/cassandra/mtdb/logs/collectl"
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end mkdir_collectl

on run_server()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "sudo -- sh -c 'echo 1 > /proc/sys/vm/drop_caches' && cdcass && time ant && rm -rf ~/work/cassandra/data/* && rm -rf /mnt/cold-storage/mtdb-cold/* && (killall mon-num-cass-threads.sh >/dev/null 2>&1 || true) && (~/work/cassandra/mtdb/tools/mon-num-cass-threads.sh &) && (killall collectl >/dev/null 2>&1 || true) && ((collectl -i 1 -sCDN -oTm > ~/work/cassandra/mtdb/logs/collectl/collectl-`date +'%y%m%d-%H%M%S'` 2>/dev/null) &) && bin/cassandra -f | grep --color -E '^|MTDB:'"
			do script (cmd) in tab tab_id of currentWindow
			-- Give enough delay to make sure the logs have different datetimes.
			delay 3

			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end run_server

on server_pressure_memory()
	tell application "Terminal" to activate

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat

	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "cd ~/work/cassandra/mtdb/tools/pressure-memory/.build"
			set cmd to cmd & " && (./pressure-memory &)"
			set cmd to cmd & " && watchsstables"
			do script (cmd) in tab tab_id of currentWindow

			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end server_pressure_memory

on client_run_loadgen()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 2
		repeat until tab_id > (num_servers * 2)
			set cmd to "cd ~/work/cassandra/mtdb/loadgen && ./create-db.sh && ./loadgen"
			do script (cmd) in tab tab_id of currentWindow
			-- Make sure we get different exp datetime
			delay 2
			-- Go to the next client tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end client_run_loadgen

on screen_detach()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is (num_servers * 2)
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "d"
		delay 0.1
		-- Move to the next tab
		tell application "System Events" to key code 124 using {shift down, command down}
	end repeat
end screen_detach

on screen_reattach()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "screen -r"
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next tab
			set tab_id to tab_id + 1
		end repeat
	end tell
end screen_reattach

on server_get_client_logs_and_process()
	tell application "Terminal" to activate

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "c" using {control down}

		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat

	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "(killall pressure-memory > /dev/null 2>&1 || true) && (sudo killall collectl > /dev/null 2>&1 || true) && (sudo killall mon-num-cass-threads.sh > /dev/null 2>&1 || true) && rsync -ave \"ssh -o StrictHostKeyChecking=no\" $CASSANDRA_CLIENT_ADDR:work/cassandra/mtdb/logs/loadgen ~/work/cassandra/mtdb/logs && cd ~/work/cassandra/mtdb/process-log/calc-cost-latency-plot-tablet-timeline && (\\rm *.pdf || true) && ./plot-cost-latency-tablet-timelines.py && du -hs ~/work/cassandra/data/"
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end server_get_client_logs_and_process

-- One-time fix. Won't need again
on server_rename_client_log()
	tell application "Terminal" to activate

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat

	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			-- I don't like the float division. oh well.
			set cmd to "mv ~/work/cassandra/mtdb/logs/loadgen/160302-023811 ~/work/cassandra/mtdb/logs/loadgen/160302-023811-" & ((tab_id - 1) / 2) & " && mv ~/work/cassandra/mtdb/logs/cassandra/160302-023811 ~/work/cassandra/mtdb/logs/cassandra/160302-023811-" & ((tab_id - 1) / 2)
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end server_rename_client_log

-- One-time use.
on server_kill_monitor_processes()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "(killall pressure-memory > /dev/null 2>&1 || true) && (sudo killall collectl > /dev/null 2>&1 || true) && (sudo killall mon-num-cass-threads.sh > /dev/null 2>&1 || true)"
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end server_kill_monitor_processes

on server_switch_data_dir_to_ebs_mag()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "cdcass"
			set cmd to cmd & " && \\rm data"
			set cmd to cmd & " && ln -s /mnt/ebs-mag/cass-data data"
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end server_switch_data_dir_to_ebs_mag

on open_window_tabs_ssh_screen()
	my open_window_tabs()
	my ssh()
	my screen()
end open_window_tabs_ssh_screen

on run_all()
	my open_window_tabs_ssh_screen()

	my install_pkgs_0()
	my install_pkgs_1()
	my install_pkgs_2()

	-- Not a normal process. In case something goes wrong.
	-- my exit_screen()

	-- Need to logout and login again to make the new .bashrc in effect

	-- These can be grouped
	my server_screen_split_htop()
	my client_screen_split_htop()
	my build_cass_pressuremem_loadgen()

	-- These can be grouped
	my server_format_ebs_mag_mount_prepare_dirs()
	my watch_free_mem()

	-- Switch data directory to ebs mag
	-- my server_switch_data_dir_to_ebs_mag()

	-- Make sure which experiment you want, by editing migrate_to_cold_storage
	my server_edit_cassandra_yaml()
	my client_edit_cassandra_yaml()
	my save_screen_layout()

	-- This takes some time to make sure each server has different exp datetime. Wait till all servers are ready before moving on to the next step
	my run_server()

	my server_pressure_memory()

	-- This takes some time too.
	my client_run_loadgen()

	my screen_detach()
	my screen_reattach()

	my server_get_client_logs_and_process()

	-- Switch data directory to ebs mag
	-- my server_switch_data_dir_to_ebs_mag()
end run_all

global num_servers
set num_servers to 12

on open_window_tabs()
	tell application "Terminal"
		activate
		-- Open a new window
		--   http://superuser.com/questions/195633/applescript-to-open-a-new-terminal-window-in-current-space
		do script "clear"
		-- set currentWindow to front window

		-- Open new tabs
		repeat (num_servers * 2 - 1) times
			tell application "System Events" to tell process "Terminal" to keystroke "t" using command down
		end repeat
	end tell
end open_window_tabs

on ssh()
	tell application "Terminal"
		set currentWindow to front window

		-- Without the delay, some connections are not made.
		set delay_after_ssh to 0.5

		set tab_id to 0
		set s_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "sshs" & s_id
			do script (cmd) in tab tab_id of currentWindow
			delay delay_after_ssh

			set tab_id to tab_id + 1
			set cmd to "sshc" & s_id
			do script (cmd) in tab tab_id of currentWindow
			delay delay_after_ssh

			set s_id to s_id + 1
		end repeat
	end tell
end ssh

on screen()
	tell application "Terminal"
		set currentWindow to front window

		set tab_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "screen"
			do script (cmd) in tab tab_id of currentWindow
			set cmd to " "
			do script (cmd) in tab tab_id of currentWindow
		end repeat
	end tell
end screen

on install_pkgs_0()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "sudo add-apt-repository -y ppa:webupd8team/java && sudo apt-get update && sudo apt-get install oracle-java8-installer git ctags ant htop tree maven gnuplot-nox ntp ioping realpath make gcc cmake g++ libboost-dev libboost-system-dev libboost-timer-dev collectl -y && sudo apt-get autoremove -y vim-tiny && mkdir -p ~/work && cd ~/work && git clone https://github.com/hoytech/vmtouch.git && cd vmtouch && make -j && sudo make install && sudo service ntp stop && sudo ntpdate -bv 0.ubuntu.pool.ntp.org && sudo service ntp start && cd ~/work && git clone git@github.com:hobinyoon/linux-home.git && cd linux-home && ./setup-linux.sh"
			do script (cmd) in tab tab_id of currentWindow
		end repeat
	end tell
end install_pkgs_0

on install_pkgs_1()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is (num_servers * 2)
		set tab_id to tab_id + 1
		tell application "System Events" to key code 36 -- enter
		delay 0.2
		tell application "System Events" to key code 123 -- left
		tell application "System Events" to key code 36 -- enter
		tell application "System Events" to key code 124 using {shift down, command down} -- move to the next tab
		delay 0.1
	end repeat
end install_pkgs_1

-- Sometimes the previous step takes forever. Need to make sure.
on install_pkgs_2()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "yes"
			do script (cmd) in tab tab_id of currentWindow
			delay 0.1
		end repeat
	end tell
end install_pkgs_2

on exit_screen()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "d" using {control down}
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "X"

		tell application "System Events" to keystroke "d" using {control down}
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "X"

		tell application "System Events" to keystroke "d" using {control down}
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "X"

		tell application "System Events" to keystroke "d" using {control down}
		tell application "System Events" to keystroke "d" using {control down}
		delay 0.1

		-- Move to the right
		tell application "System Events" to key code 124 using {shift down, command down}

		tell application "System Events" to keystroke "d" using {control down}
		tell application "System Events" to keystroke "d" using {control down}
		delay 0.1

		-- Move to the right
		tell application "System Events" to key code 124 using {shift down, command down}
	end repeat
end exit_screen

on server_screen_split_htop()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "S"
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "c"
		tell application "System Events" to keystroke "htop"
		tell application "System Events" to key code 36

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "S"
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "c"
		tell application "System Events" to keystroke "watch -n 0.5 \"free -mt\""
		tell application "System Events" to key code 36

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "S"
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "c"

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		-- Move 2 to the right, since S and C take turns.
		--   124: right arrow
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end server_screen_split_htop

on client_screen_split_htop()
	tell application "Terminal" to activate
	set tab_id to 0
	-- Start from the 2nd tab, which is the first client tab
	tell application "System Events" to key code 124 using {shift down, command down}
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "S"
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "c"
		tell application "System Events" to keystroke "htop"
		tell application "System Events" to key code 36

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		-- Move 2 to the right, since S and C take turns.
		--   124: right arrow
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat

	-- Set the current tab to the 1st one
	tell application "System Events" to key code 123 using {shift down, command down}

end client_screen_split_htop

on build_cass_pressuremem_loadgen()
	tell application "Terminal"
		set currentWindow to front window

		-- Without the delay, some connections are not made.
		set delay_after_ssh to 0.2

		set tab_id to 0
		set s_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "cd ~/work && git clone git@github.com:hobinyoon/apache-cassandra-2.2.3-src.git && ln -s ~/work/apache-cassandra-2.2.3-src ~/work/cassandra && cd ~/work/cassandra/mtdb/tools/pressure-memory && mkdir -p .build && cd .build && cmake .. && make -j && cdcass && time ant"
			do script (cmd) in tab tab_id of currentWindow
			delay delay_after_ssh

			set tab_id to tab_id + 1
			set cmd to "cd ~/work && git clone git@github.com:hobinyoon/apache-cassandra-2.2.3-src.git && ln -s ~/work/apache-cassandra-2.2.3-src ~/work/cassandra && cd ~/work/cassandra/mtdb/loadgen && ./loadgen"
			do script (cmd) in tab tab_id of currentWindow
			delay delay_after_ssh

			set s_id to s_id + 1
		end repeat
	end tell
end build_cass_pressuremem_loadgen

on git_pull()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is (num_servers * 2)
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "c" using {control down}

		-- Move to the next tab
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat

	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 0
		repeat until tab_id is (num_servers * 2)
			set tab_id to tab_id + 1
			set cmd to "cdcass && git pull"
			do script (cmd) in tab tab_id of currentWindow
		end repeat
	end tell
end git_pull

on server_format_ebs_mag_mount_prepare_dirs()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "sudo mkfs.ext4 -m 0 /dev/xvdd && sudo cp ~/work/cassandra/mtdb/ec2-tools/etc-fstab /etc/fstab && sudo umount /mnt && sudo mkdir -p /mnt/local-ssd && sudo mount /mnt/local-ssd && sudo chown -R ubuntu /mnt/local-ssd && mkdir /mnt/local-ssd/cass-data && mkdir ~/cass-data-vol && sudo ln -s ~/cass-data-vol /mnt/ebs-ssd-gp2 && mkdir /mnt/ebs-ssd-gp2/cass-data && sudo mkdir -p /mnt/ebs-mag && sudo mount /mnt/ebs-mag && sudo mkdir /mnt/ebs-mag/cass-data && sudo chown -R ubuntu /mnt/ebs-mag && sudo chown -R ubuntu /mnt/ebs-mag/cass-data && sudo mkdir -p /mnt/ebs-ssd-gp2/mtdb-cold && (sudo mkdir -p /mnt/ebs-mag/mtdb-cold || true) && sudo ln -s /mnt/ebs-mag /mnt/cold-storage && sudo chown -R ubuntu /mnt/ebs-ssd-gp2 && sudo chown -R ubuntu /mnt/cold-storage && sudo chown -R ubuntu /mnt/cold-storage/mtdb-cold && mkdir -p ~/work/cassandra/mtdb/logs/collectl && ln -s /mnt/local-ssd/cass-data ~/work/cassandra/data"
			do script (cmd) in tab tab_id of currentWindow

			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end server_format_ebs_mag_mount_prepare_dirs

on watch_free_mem()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		tell application "System Events" to keystroke "watch -n 0.5 \"free -mt\""
		tell application "System Events" to key code 36
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab

		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end watch_free_mem

on server_edit_cassandra_yaml()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			--			set cmd to "sed -i -r 's/^    migrate_to_cold_storage:.+/    migrate_to_cold_storage: true/' ~/work/cassandra/conf/cassandra.yaml"
			set cmd to "sed -i -r 's/^    migrate_to_cold_storage:.+/    migrate_to_cold_storage: false/' ~/work/cassandra/conf/cassandra.yaml"
			do script (cmd) in tab tab_id of currentWindow
			set cmd to "sed -i -r 's/^    tablet_coldness_threshold:.+/    tablet_coldness_threshold: 75/' ~/work/cassandra/conf/cassandra.yaml"
			do script (cmd) in tab tab_id of currentWindow

			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end server_edit_cassandra_yaml

on client_edit_cassandra_yaml()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 2
		repeat until tab_id > (num_servers * 2)
			set cmd to "sed -i -r 's/^        num_writes_per_simulation_time_mins:.+/        num_writes_per_simulation_time_mins: " & (tab_id * 5000) & "/' ~/work/cassandra/conf/cassandra.yaml"
			do script (cmd) in tab tab_id of currentWindow
			set cmd to "grep num_writes_per_simulation_time_mins: ~/work/cassandra/conf/cassandra.yaml"
			do script (cmd) in tab tab_id of currentWindow

			-- Go to the next client tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end client_edit_cassandra_yaml

on save_screen_layout()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is (num_servers * 2)
		set tab_id to tab_id + 1

		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke ":layout save default"
		tell application "System Events" to key code 36

		-- Move to the next tab
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end save_screen_layout

-- One-time fix. Won't need again
on mkdir_collectl()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "mkdir ~/work/cassandra/mtdb/logs/collectl"
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end mkdir_collectl

on run_server()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "sudo -- sh -c 'echo 1 > /proc/sys/vm/drop_caches' && cdcass && time ant && rm -rf ~/work/cassandra/data/* && rm -rf /mnt/cold-storage/mtdb-cold/* && (killall mon-num-cass-threads.sh >/dev/null 2>&1 || true) && (~/work/cassandra/mtdb/tools/mon-num-cass-threads.sh &) && (killall collectl >/dev/null 2>&1 || true) && ((collectl -i 1 -sCDN -oTm > ~/work/cassandra/mtdb/logs/collectl/collectl-`date +'%y%m%d-%H%M%S'` 2>/dev/null) &) && bin/cassandra -f | grep --color -E '^|MTDB:'"
			do script (cmd) in tab tab_id of currentWindow
			-- Give enough delay to make sure the logs have different datetimes.
			delay 3

			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end run_server

on server_pressure_memory()
	tell application "Terminal" to activate

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat

	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "cd ~/work/cassandra/mtdb/tools/pressure-memory/.build"
			set cmd to cmd & " && (./pressure-memory &)"
			set cmd to cmd & " && watchsstables"
			do script (cmd) in tab tab_id of currentWindow

			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end server_pressure_memory

on client_run_loadgen()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 2
		repeat until tab_id > (num_servers * 2)
			set cmd to "cd ~/work/cassandra/mtdb/loadgen && ./create-db.sh && ./loadgen"
			do script (cmd) in tab tab_id of currentWindow
			-- Make sure we get different exp datetime
			delay 2
			-- Go to the next client tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end client_run_loadgen

on screen_detach()
	tell application "Terminal" to activate
	set tab_id to 0
	repeat until tab_id is (num_servers * 2)
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke "d"
		delay 0.1
		-- Move to the next tab
		tell application "System Events" to key code 124 using {shift down, command down}
	end repeat
end screen_detach

on screen_reattach()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "screen -r"
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next tab
			set tab_id to tab_id + 1
		end repeat
	end tell
end screen_reattach

on server_get_client_logs_and_process()
	tell application "Terminal" to activate

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "c" using {control down}

		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat

	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "(killall pressure-memory > /dev/null 2>&1 || true) && (sudo killall collectl > /dev/null 2>&1 || true) && (sudo killall mon-num-cass-threads.sh > /dev/null 2>&1 || true) && rsync -ave \"ssh -o StrictHostKeyChecking=no\" $CASSANDRA_CLIENT_ADDR:work/cassandra/mtdb/logs/loadgen ~/work/cassandra/mtdb/logs && cd ~/work/cassandra/mtdb/process-log/calc-cost-latency-plot-tablet-timeline && (\\rm *.pdf || true) && ./plot-cost-latency-tablet-timelines.py && du -hs ~/work/cassandra/data/"
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end server_get_client_logs_and_process

-- One-time fix. Won't need again
on server_rename_client_log()
	tell application "Terminal" to activate

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat

	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			-- I don't like the float division. oh well.
			set cmd to "mv ~/work/cassandra/mtdb/logs/loadgen/160302-023811 ~/work/cassandra/mtdb/logs/loadgen/160302-023811-" & ((tab_id - 1) / 2) & " && mv ~/work/cassandra/mtdb/logs/cassandra/160302-023811 ~/work/cassandra/mtdb/logs/cassandra/160302-023811-" & ((tab_id - 1) / 2)
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell

	set tab_id to 0
	repeat until tab_id is num_servers
		set tab_id to tab_id + 1
		tell application "System Events" to keystroke "a" using {control down}
		tell application "System Events" to keystroke tab
		-- Move to the next server tab
		tell application "System Events" to key code 124 using {shift down, command down}
		tell application "System Events" to key code 124 using {shift down, command down}
		delay 0.1
	end repeat
end server_rename_client_log

-- One-time use.
on server_kill_monitor_processes()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "(killall pressure-memory > /dev/null 2>&1 || true) && (sudo killall collectl > /dev/null 2>&1 || true) && (sudo killall mon-num-cass-threads.sh > /dev/null 2>&1 || true)"
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end server_kill_monitor_processes

-- One-time use.
on server_data_dir_to_ebs_mag()
	tell application "Terminal"
		set currentWindow to front window
		set tab_id to 1
		repeat until tab_id > (num_servers * 2)
			set cmd to "cdcass"
			set cmd to cmd & " && \\rm data"
			set cmd to cmd & " && ln -s /mnt/ebs-mag/cass-data data"
			do script (cmd) in tab tab_id of currentWindow
			-- Go to the next server tab
			set tab_id to tab_id + 2
		end repeat
	end tell
end server_data_dir_to_ebs_mag

on open_window_tabs_ssh_screen()
	my open_window_tabs()
	my ssh()
	my screen()
end open_window_tabs_ssh_screen

on run_all()
	my open_window_tabs_ssh_screen()

	my install_pkgs_0()
	my install_pkgs_1()
	my install_pkgs_2()

	-- Not a normal process. In case something goes wrong.
	-- my exit_screen()

	-- These can be grouped
	my server_screen_split_htop()
	my client_screen_split_htop()
	my build_cass_pressuremem_loadgen()

	-- In case needed
	-- my git_pull()

	-- These can be grouped
	my server_format_ebs_mag_mount_prepare_dirs()
	my watch_free_mem()
	-- Make sure which experiment you want, by editing migrate_to_cold_storage
	my server_edit_cassandra_yaml()
	my client_edit_cassandra_yaml()
	my save_screen_layout()

	-- This takes like 40 secs. Do not move focus to anywhere else, or it will fail.
	my run_server()

	my server_pressure_memory()

	my client_run_loadgen()

	my screen_detach()
	my screen_reattach()

	my server_get_client_logs_and_process()

	-- Switch data directory
	-- my server_data_dir_to_ebs_mag()
end run_all

my screen_detach()


Fixed one problem with the dmg script: The Growl package is now named Growl.pkg, not Growl.mpkg as the script was expecting. This is what was causing the icon positions to not get set.

on run -- for testing in script editor
	process_disk_image("Growl", "/Users/evands/growl/Release/Artwork")
end run

on process_disk_image(volumeName, artPath)
	tell application "Finder"
		tell disk volumeName
			open
			tell container window
				set current view to icon view
				set toolbar visible to false
				set statusbar visible to false
				--set the bounds to {30, 50, 579, 600}
			end tell
			close
			set opts to the icon view options of container window
			tell opts
				set icon size to 64
				set arrangement to not arranged
			end tell
			set background picture of opts to file ".background:growlDMGBackground.png"
			set position of item "Growl.pkg" to {147, 75}
			set position of item "Extras" to {100, 320}
			--set position of item "Scripts" to {36, 153}
			set position of item "Growl Documentation.webloc" to {100, 218}
			set position of item "Growl version history.webloc" to {275, 218}
			set position of item "Get more styles.webloc" to {415, 218}
			set position of item "Uninstall Growl.app" to {415, 320}

			-- Custom icons
			my copyIconOfTo(artPath & "/GrowlIcon", "/Volumes/" & volumeName & "/Growl.mpkg")

			update without registering applications
			tell container window
				open
				set the_window_id to id
			end tell
			update without registering applications
		end tell
		set bounds of window id the_window_id to {30, 50, 575, 450}
		--give the finder some time to write the .DS_Store file
		delay 5
	end tell
end process_disk_image

on copyIconOfTo(aFileOrFolderWithIcon, aFileOrFolder)
	tell application "Finder" to set f to POSIX file aFileOrFolderWithIcon as alias
	-- grab the file's icon
	my CopyOrPaste(f, "c")
	-- now the icon is in the clipboard
	tell application "Finder" to set c to POSIX file aFileOrFolder as alias
	my CopyOrPaste(result, "v")
end copyIconOfTo

on CopyOrPaste(i, cv)
	tell application "Finder"
		activate
		open information window of i
	end tell
	tell application "System Events" to tell process "Finder" to tell window 1
		keystroke tab -- select icon button
		keystroke (cv & "w") using command down (* (copy or paste) + close window *)
	end tell -- window 1 then process Finder then System Events
end CopyOrPaste

on run -- for testing in script editor
	process_disk_image("Growl", "/Users/evands/growl/Release/Artwork")
end run

on process_disk_image(volumeName, artPath)
	tell application "Finder"
		tell disk volumeName
			open
			tell container window
				set current view to icon view
				set toolbar visible to false
				set statusbar visible to false
				--set the bounds to {30, 50, 579, 600}
			end tell
			close
			set opts to the icon view options of container window
			tell opts
				set icon size to 64
				set arrangement to not arranged
			end tell
			set background picture of opts to file ".background:growlDMGBackground.png"
			set position of item "Growl.mpkg" to {147, 75}
			set position of item "Extras" to {100, 320}
			--set position of item "Scripts" to {36, 153}
			set position of item "Growl Documentation.webloc" to {100, 218}
			set position of item "Growl version history.webloc" to {275, 218}
			set position of item "Get more styles.webloc" to {415, 218}
			set position of item "Uninstall Growl.app" to {415, 320}

			-- Custom icons
			my copyIconOfTo(artPath & "/GrowlIcon", "/Volumes/" & volumeName & "/Growl.mpkg")

			update without registering applications
			tell container window
				open
				set the_window_id to id
			end tell
			update without registering applications
		end tell
		set bounds of window id the_window_id to {30, 50, 575, 450}
		--give the finder some time to write the .DS_Store file
		delay 5
	end tell
end process_disk_image

on copyIconOfTo(aFileOrFolderWithIcon, aFileOrFolder)
	tell application "Finder" to set f to POSIX file aFileOrFolderWithIcon as alias
	-- grab the file's icon
	my CopyOrPaste(f, "c")
	-- now the icon is in the clipboard
	tell application "Finder" to set c to POSIX file aFileOrFolder as alias
	my CopyOrPaste(result, "v")
end copyIconOfTo

on CopyOrPaste(i, cv)
	tell application "Finder"
		activate
		open information window of i
	end tell
	tell application "System Events" to tell process "Finder" to tell window 1
		keystroke tab -- select icon button
		keystroke (cv & "w") using command down (* (copy or paste) + close window *)
	end tell -- window 1 then process Finder then System Events
end CopyOrPaste


Wil who likes men said to do this

Wil who likes men said to do this

on http_post(the_data, the_url)
	set the_command to "curl -d " & quoted form of the_data & " " & the_url
	return do shell script (the_command as Unicode text)
end http_post

on open_location(x)
	open location x
end open_location


Updated rate_current_track.

Updated rate_current_track.

FasdUAS 1.101.10
k
i
I
.aevtoappnull****
	o0argv
O

Z

=
1

pPlS
m
ePlSkPSP

k
r
l
1

pTrk
o0thetracktheTrack
r
l
n
4

cobj
m
o0argv
l
n
1

pRte
o0thetracktheTrack
m  hookalisLMacintosh HDīH+ݕ
iTunes.appTĚq	 ApplicationsĬb\Ěݕ$Macintosh HD:Applications:iTunes.app
iTunes.appMacintosh HDApplications/iTunes.app/!
!l"#$"
.aevtoappnull****0thetracktheTrack#%&
.aevtoappnull****0argv%0argv&

pPlS
ePlSkPSP

pTrk0thetracktheTrack

cobj

pRte *,*,EOk/,FYhU$''(())

cSrc(
kfrmID

cUsPh
kfrmID

cFlTh
kfrmID  ascrޭ

FasdUAS 1.101.10
k
i
I
.aevtoappnull****
	o0argv
O

Z

=
1

pPlS
m
ePlSkPSP

k
r
l
1

pTrk
o0thetracktheTrack
r
l
n
4

cobj
m
o0argv
l
n
1

pRte
o0thetracktheTrack
m  hookalisLMacintosh HDīH+ݕ
iTunes.appTĚq	 ApplicationsĬb\Ěݕ$Macintosh HD:Applications:iTunes.app
iTunes.appMacintosh HDApplications/iTunes.app/!
!l"#$"
.aevtoappnull****0thetracktheTrack#%&
.aevtoappnull****0argv%0argv&

pPlS
ePlSkPSP

pTrk0thetracktheTrack

cobj

pRte *,*,EOk/,FYhU$''(())

cSrc*
kfrmID

cUsP1v
kfrmID

cFlTw
kfrmID  ascrޭ


Add openPresentation

Add openPresentation

on newPresentation(themeName)
	tell application "Keynote"
		activate
		-- FIXME: Make this selectable?
		set targetWidth to 1024 -- 1440 <-- higher resolution
		set targetHeight to 768 -- 1080 <-- higher resolution

		set props to {document theme:theme (themeName as string), width:targetWidth, height:targetHeight}

		set thisDocument to make new document with properties props
		return name of thisDocument
	end tell
end newPresentation

on openPresentation(posixPath)
	tell application "Keynote"
		open posixPath
	end tell
end openPresentation

on savePresentation(docname, posixPath)
	tell application "Keynote"
		save document named docname in POSIX file posixPath
	end tell
end savePresentation

on createSlide(docname, masterSlideName)
	try
		tell application "Keynote"
			tell document named docname
				set thisSlide to make new slide with properties {base slide:master slide masterSlideName}
			end tell
	  return thisSlide
		end tell
	on error
		return 0
	end try
end createSlide

on finalize(docname)
	tell application "Keynote"
		tell document named docname to delete slide 1
	end tell
end finalize

on themeMasters(docname)
	--	  tell application "Keynote" to get the name of every master slide of thisDocument
	tell application "Keynote"
		set names to the name of every master slide of document named docname
		return names
	end tell
end themeMasters

on addImage(docname, filepath)
  (*
	FIXME: Use slide ID to adress slide instead of "current slide"
  *)
  tell application "Keynote"
	tell document named docname
		tell the current slide

			-- TO REPLACE A PLACEHOLDER OR EXISTING IMAGE:
			set thisPlaceholderImageItem to image 1
			-- change the value of the “file name” property of the image to be an HFS file reference to the replacement image file
		set macPath to POSIX file filepath as Unicode text
			set file name of thisPlaceholderImageItem to ¬
				alias macPath

		end tell
	end tell
  end tell
end addImage

on addTitle(docname, thisSlideTitle)
  (*
	FIXME: Use slide ID to adress slide instead of "current slide"
  *)
	tell application "Keynote"
		tell document named docname
			tell the current slide
				if title showing is true then
					set the object text of the default title item to thisSlideTitle
				end if
			end tell
		end tell
	end tell
end addTitle

on addBody(docname, thisSlideBody)
  (*
	FIXME: Use slide ID to adress slide instead of "current slide"
  *)
	tell application "Keynote"
		tell document named docname
			tell the current slide
				if body showing is true then
					set the object text of the default body item to thisSlideBody
				end if
			end tell
		end tell
	end tell
end addTitle

on newPresentation(themeName)
	tell application "Keynote"
		activate
		-- FIXME: Make this selectable?
		set targetWidth to 1024 -- 1440 <-- higher resolution
		set targetHeight to 768 -- 1080 <-- higher resolution

		set props to {document theme:theme (themeName as string), width:targetWidth, height:targetHeight}

		set thisDocument to make new document with properties props
		return name of thisDocument
	end tell
end newPresentation

on savePresentation(docname, posixPath)
	tell application "Keynote"
		save document named docname in POSIX file posixPath
	end tell
end savePresentation

on createSlide(docname, masterSlideName)
	try
		tell application "Keynote"
			tell document named docname
				set thisSlide to make new slide with properties {base slide:master slide masterSlideName}
			end tell
	  return thisSlide
		end tell
	on error
		return 0
	end try
end createSlide

on finalize(docname)
	tell application "Keynote"
		tell document named docname to delete slide 1
	end tell
end finalize

on themeMasters(docname)
	--	  tell application "Keynote" to get the name of every master slide of thisDocument
	tell application "Keynote"
		set names to the name of every master slide of document named docname
		return names
	end tell
end themeMasters

on addImage(docname, filepath)
  (*
	FIXME: Use slide ID to adress slide instead of "current slide"
  *)
  tell application "Keynote"
	tell document named docname
		tell the current slide

			-- TO REPLACE A PLACEHOLDER OR EXISTING IMAGE:
			set thisPlaceholderImageItem to image 1
			-- change the value of the “file name” property of the image to be an HFS file reference to the replacement image file
		set macPath to POSIX file filepath as Unicode text
			set file name of thisPlaceholderImageItem to ¬
				alias macPath

		end tell
	end tell
  end tell
end addImage

on addTitle(docname, thisSlideTitle)
  (*
	FIXME: Use slide ID to adress slide instead of "current slide"
  *)
	tell application "Keynote"
		tell document named docname
			tell the current slide
				if title showing is true then
					set the object text of the default title item to thisSlideTitle
				end if
			end tell
		end tell
	end tell
end addTitle

on addBody(docname, thisSlideBody)
  (*
	FIXME: Use slide ID to adress slide instead of "current slide"
  *)
	tell application "Keynote"
		tell document named docname
			tell the current slide
				if body showing is true then
					set the object text of the default body item to thisSlideBody
				end if
			end tell
		end tell
	end tell
end addTitle


Saving

Saving

on newPresentation(themeName)
	tell application "Keynote"
		activate
		-- set the chosenTheme to themeName

		set targetWidth to 1024 -- 1440 <-- higher resolution
		set targetHeight to 768 -- 1080 <-- higher resolution

		set thisDocument to ¬
			make new document with properties ¬
				{document theme:theme (themeName as string)}
				--{document theme:theme (themeName as string), width:targetWidth, height:targetHeight}
		return name of thisDocument
	end tell
end newPresentation

on savePresentation(docname, posixPath)
	tell application "Keynote"
		save document named docname in POSIX file posixPath
	end tell
end savePresentation

on createSlide(docname, masterSlideName, thisSlideTitle, thisSlideBody)
	try
		tell application "Keynote"
			tell document named docname
				set thisSlide to make new slide with properties {base slide:master slide masterSlideName}
				tell thisSlide
					-- set the transition properties to {transition effect:dissolve, transition duration:defaultTransitionDuration, transition delay:defaultTransitionDelay, automatic transition:defaultAutomaticTransition}
					if title showing is true then
						set the object text of the default title item to thisSlideTitle
					end if
					if body showing is true then
						set the object text of the default body item to thisSlideBody
					end if
				end tell
			end tell
	  return thisSlide
		end tell
	on error
		return 0
	end try
end createSlide

on finalize(docname)
	tell application "Keynote"
		tell document named docname to delete slide 1
	end tell
end finalize

on themeMasters(docname)
	--	  tell application "Keynote" to get the name of every master slide of thisDocument
	tell application "Keynote"
		set names to the name of every master slide of document named docname
		return names
	end tell
end themeMasters

on addImage(docname, filepath)
  (*
	FIXME: Use slide ID to adress slide instead of "current slide"
  *)
  tell application "Keynote"
	tell document named docname
		tell the current slide

			-- TO REPLACE A PLACEHOLDER OR EXISTING IMAGE:
			set thisPlaceholderImageItem to image 1
			-- change the value of the “file name” property of the image to be an HFS file reference to the replacement image file
		set macPath to POSIX file filepath as Unicode text
			set file name of thisPlaceholderImageItem to ¬
				alias macPath

		end tell
	end tell
  end tell
end addImage

on newPresentation(themeName)
	tell application "Keynote"
		activate
		-- set the chosenTheme to themeName

		set targetWidth to 1024 -- 1440 <-- higher resolution
		set targetHeight to 768 -- 1080 <-- higher resolution

		set thisDocument to ¬
			make new document with properties ¬
				{document theme:theme (themeName as string)}
				--{document theme:theme (themeName as string), width:targetWidth, height:targetHeight}
		return name of thisDocument
	end tell
end newPresentation

on createSlide(docname, masterSlideName, thisSlideTitle, thisSlideBody)
	try
		tell application "Keynote"
			tell document named docname
				set thisSlide to make new slide with properties {base slide:master slide masterSlideName}
				tell thisSlide
					-- set the transition properties to {transition effect:dissolve, transition duration:defaultTransitionDuration, transition delay:defaultTransitionDelay, automatic transition:defaultAutomaticTransition}
					if title showing is true then
						set the object text of the default title item to thisSlideTitle
					end if
					if body showing is true then
						set the object text of the default body item to thisSlideBody
					end if
				end tell
			end tell
	  return thisSlide
		end tell
	on error
		return 0
	end try
end createSlide

on finalize(docname)
	tell application "Keynote"
		tell document named docname to delete slide 1
	end tell
end finalize

on themeMasters(docname)
	--	  tell application "Keynote" to get the name of every master slide of thisDocument
	tell application "Keynote"
		set names to the name of every master slide of document named docname
		return names
	end tell
end themeMasters

on addImage(docname, filepath)
  (*
	FIXME: Use slide ID to adress slide instead of "current slide"
  *)
  tell application "Keynote"
	tell document named docname
		tell the current slide

			-- TO REPLACE A PLACEHOLDER OR EXISTING IMAGE:
			set thisPlaceholderImageItem to image 1
			-- change the value of the “file name” property of the image to be an HFS file reference to the replacement image file
		set macPath to POSIX file filepath as Unicode text
			set file name of thisPlaceholderImageItem to ¬
				alias macPath

		end tell
	end tell
  end tell
end addImage


separate dialog for closing window on osx

git-svn-id: 1940fb81eac38ef6ef058c79705648ed98d10eaf@591 981887c0-d8ae-4743-aaa6-7abdade54d40

FasdUAS 1.101.10
k
l
i

	I
.aevtodocnullalis
o0df

k

r
m
o
0cmdarg
X*
k%
r
n
1

strq
l
n
1

psxp
 o	0aname
o0dfp!
!r%"#
"b#$%
$b&'
&o
0cmdarg
'm(())
%l"*
*c"+,
+o 0dfp
,m !

ctxt
#o
0cmdarg	0aname
o0df-.
-r+6/0
/n+412
1124

strq
2l+23
3n+245
4102

psxp
5l+06
6I+07
.earsffdralis afdr
7f+,
0o
0mypath.89
8r7@:;
:b7><=
<b7<>?
>b7:@A
@m78BBCC`dirname
Ao89
0mypath
?m:;DDEE*`/read_charts_osx.sh
=o<=
0cmdarg
;o0cmd9F
FOAGH
GkEIIJK
JIEJ
.miscactvnullnullKLM
LlKKMNO
NrKTPQ
PIKRR
.coredoscnullctxt
RbKNST
SoKL0cmd
TmLMUUVV
;exit
Qo0twOWX
WrUhYZ
YlUf[
[6Uf\]
\4UY^

cwin
^mWX
]=\e_`
_1]a

tcnt
`obd0tw
Zo	0mywinXab
arircd
cmil
dle
enfg
f1mq

ccol
golm	0mywinbhi
hrs|jk
jmsv(
kll
lnmn
m1w{

crow
novw	0mywiniop
or}qr
qm}ssttAvChartConvert
rnuv
u1

titl
vo	0mywinpwx
wIy
.sysodelanullnmbr
ymxz{
zV|}
|k~~
Z
E
l
n
1

pcnt
n
1

pcnt
o0tw
m8***chart generation finished
S
I
.sysodelanullnmbr
m
}m
boovtrue{
l
I
.sysodlogaskrTEXT
mZChart generation finished, OK to close window
I
.coreclosnullobj
o	0mywin

savo
m
savono
HmAB@alisd
AndreasMacH+@Terminal.appwc	 	UtilitieswG@?.AndreasMac:Applications:Utilities:Terminal.appTerminal.app
AndreasMac#Applications/Utilities/Terminal.app/
l
l
O
k
I
.miscactvnullnull
r

I

.appScalMnullobj
m
openPanel

of C
m
NSOpenPanel
o0	openpanel	openPanel
r
m
boovtrue
o0truebooltrueBool
I!
.appScalMnullobj
msetTitle:

psof
o0	openpanel	openPanel

witQ
mfSelect Files or Folders with charts to be converted
I"+
.appScalMnullobj
m"#"setFloatingPanel:

psof
o$%0	openpanel	openPanel

witQ
o&'0truebooltrueBool
I,5
.appScalMnullobj
m,-$setCanChooseFiles:

psof
o./0	openpanel	openPanel

witQ
o010truebooltrueBool
I6?
.appScalMnullobj
m670setCanChooseDirectories:

psof
o890	openpanel	openPanel

witQ
o:;0truebooltrueBool
I@K
.appScalMnullobj
m@C&setResolvesAliases:~
~
psof
oDE}}0	openpanel	openPanel|{
|
witQ
oFGzz0truebooltrueBool{
ILWy
y.appScalMnullobj
mLO6setAllowsMultipleSelection:x
x
psof
oPQww0	openpanel	openPanelvu
v
witQ
oRStt0truebooltrueBoolu
rXe
IXas
s.appScalMnullobj
mX[runModalrq
r
psof
o\]pp0	openpanel	openPanelq
ooo0	theresult	theResultn
Zfml
=fk
ofikk0	theresult	theResult
mijjj
ln{
rn{
Inwi
i.appScalMnullobj
mnqfilenameshg
h
psof
orsff0	openpanel	openPanelg
oee0chosenpathschosenPaths60 0 is returned when the cancel button is pressed` 0 is returned when the cancel button is pressedmln
m@alis
AndreasMacH+7Automator Runner.app(~`	 CoreServices}@7;AndreasMac:System:Library:CoreServices:Automator Runner.app*Automator Runner.app
AndreasMac0System/Library/CoreServices/Automator Runner.app/
ldc
Z	ba
=

o``0	theresult	theResult
m__
	O

I^]
^.aevtodocnullalis
l\[
oZZ0chosenpathschosenPaths\[]

fbadcY
lXWVXWVY
UTSRQUPONMLKJI
P.aevtodocnullalis
O.aevtoappnull****N0	openpanel	openPanelM0truebooltrueBoolL0	theresult	theResultK0chosenpathschosenPathsJIH
GFE
H.aevtodocnullalisG0dfFDCBA@?>=D0dfC
0cmdargB	0anameA0dfp@
0mypath?0cmd>0tw=	0mywin <;:98(76BD5U43210/.s-,+*)('
<
kocl
;
cobj
:.corecnte********
9
psxp
8
strq
7
ctxt
6.earsffdralis afdr
5.miscactvnullnull
4.coredoscnullctxt
3
cwin
2
tcnt1
0
ccol/(
.
crow
-
titl
,.sysodelanullnmbr
+
pcnt
*.sysodlogaskrTEXT
)
savo
(savono
'.coreclosnullobj EEO%[lkh,,EO%&%E[OYO)j,,EO%%%EO*jO%jEO*k/a[a,\Z81EOaa,FOaa,FOaa,FOljO%hea,a,aYhOkj[OYOajOaalU&%$#
&.aevtoappnull****
k""%$!
!.miscactvnullnull

of C
.appScalMnullobj 0	openpanel	openPanel0truebooltrueBool

psof

witQ0	theresult	theResult0chosenpathschosenPaths
.aevtodocnullalis#}*jOlEOeEOOOOOaOaOalE`O_kalE`YhUO_k)	_jUYh

opeP
TboovtrueS  !!r/Users/andreas/Karten/nv/satz4-2012-converted/HLS45_4.kapRQascrޭ

FasdUAS 1.101.10
k
l
i

	I
.aevtodocnullalis
o0df

k

r
m
o
0cmdarg
X*
k%
r
n
1

strq
l
n
1

psxp
 o	0aname
o0dfp!
!r%"#
"b#$%
$b&'
&o
0cmdarg
'm(())
%l"*
*c"+,
+o 0dfp
,m !

ctxt
#o
0cmdarg	0aname
o0df-.
-r+6/0
/n+412
1124

strq
2l+23
3n+245
4102

psxp
5l+06
6I+07
.earsffdralis afdr
7f+,
0o
0mypath.89
8r7@:;
:b7><=
<b7<>?
>b7:@A
@m78BBCC`dirname
Ao89
0mypath
?m:;DDEE*`/read_charts_osx.sh
=o<=
0cmdarg
;o0cmd9F
FOAGH
GkEIIJK
JIEJ
.miscactvnullnullKLM
LlKKNON*$set custom title to "AvChartConvert"OPPHset custom title to "AvChartConvert"MQR
QrKTST
SIKRU
.coredoscnullctxt
UbKNVW
VoKL0cmd
WmLMXXYY
;exit
To0twRZ[
ZrUh\]
\lUf^
^6Uf_`
_4UYa

cwin
amWX
`=\ebc
b1]a

tcnt
cobd0tw
]o	0mywin[de
drirfg
fmil
glh
hnij
i1mq

ccol
jolm	0mywinekl
krs|mn
mmsv(
nlo
onpq
p1w{

crow
qovw	0mywinlrs
rr}tu
tm}vvwwAvChartConvert
unxy
x1

titl
yo	0mywinsz{
zI|
.sysodelanullnmbr
|m{}~
}V
k
r
l
n
1

pcnt
n
1

pcnt
o0tw
o0c
l/)display dialog c buttons {"OK", "Cancel"}Rdisplay dialog c buttons {"OK", "Cancel"}
Z
E
o0c
m8***chart generation finished
S
I
.sysodelanullnmbr
m
m
boovtrue~
l
I
.sysodlogaskrTEXT
mZChart generation finished, OK to close window
I
.coreclosnullobj
o	0mywin

savo
m
savono
HmAB@alisd
AndreasMacH+@Terminal.appwc	 	UtilitieswG@?.AndreasMac:Applications:Utilities:Terminal.appTerminal.app
AndreasMac#Applications/Utilities/Terminal.app/
l
l
O
k
I
.miscactvnullnull
r

I

.appScalMnullobj
m
openPanel

of C
m
NSOpenPanel
o0	openpanel	openPanel
r
m
boovtrue
o0truebooltrueBool
I!
.appScalMnullobj
msetTitle:

psof
o0	openpanel	openPanel

witQ
mfSelect Files or Folders with charts to be converted
I"+
.appScalMnullobj
m"#"setFloatingPanel:

psof
o$%0	openpanel	openPanel

witQ
o&'0truebooltrueBool
I,5
.appScalMnullobj
m,-$setCanChooseFiles:

psof
o./0	openpanel	openPanel

witQ
o010truebooltrueBool
I6?
.appScalMnullobj
m670setCanChooseDirectories:

psof
o890	openpanel	openPanel

witQ
o:;0truebooltrueBool
I@K~
~.appScalMnullobj
m@C&setResolvesAliases:}
}
psof
oDE||0	openpanel	openPanel{z
{
witQ
oFGyy0truebooltrueBoolz
ILWx
x.appScalMnullobj
mLO6setAllowsMultipleSelection:w
w
psof
oPQvv0	openpanel	openPanelut
u
witQ
oRSss0truebooltrueBoolt
rXe
IXar
r.appScalMnullobj
mX[runModalqp
q
psof
o\]oo0	openpanel	openPanelp
onn0	theresult	theResultm
Zflk
=fk
ofijj0	theresult	theResult
mijii
ln{
rn{
Inwh

h.appScalMnullobj

mnq

filenamesgf
g
psof
orsee0	openpanel	openPanelf
	odd0chosenpathschosenPaths60 0 is returned when the cancel button is pressed` 0 is returned when the cancel button is pressedlkm
m@alis
AndreasMacH+7Automator Runner.app(~`	 CoreServices}@7;AndreasMac:System:Library:CoreServices:Automator Runner.app*Automator Runner.app
AndreasMac0System/Library/CoreServices/Automator Runner.app/
lcb
Za`
=
o__0	theresult	theResult
m^^
O
I]\
].aevtodocnullalis
l
oYY0chosenpathschosenPaths[Z\
fa`cbX
lWVUWVUX
T SR!QPTONMLKJIH
O.aevtodocnullalis
N.aevtoappnull****M0	openpanel	openPanelL0truebooltrueBoolK0	theresult	theResultJ0chosenpathschosenPathsIHG
FE"#D
G.aevtodocnullalisF0dfE"	CBA@?>=<;C0dfB
0cmdargA	0aname@0dfp?
0mypath>0cmd=0tw<	0mywin;0c# :9876(54BD3X21$0/.-,v+*)('&%
:
kocl
9
cobj
8.corecnte********
7
psxp
6
strq
5
ctxt
4.earsffdralis afdr
3.miscactvnullnull
2.coredoscnullctxt
1
cwin$
0
tcnt/
.
ccol-(
,
crow
+
titl
*.sysodelanullnmbr
)
pcnt
(.sysodlogaskrTEXT
'
savo
&savono
%.coreclosnullobj DEO%[lkh,,EO%&%E[OYO)j,,EO%%%EO*jO%jEO*k/a[a,\Z81EOaa,FOaa,FOaa,FOljO)hea,a,EOaYhOkj[OYOajOaalU$%#"&'!
$.aevtoappnull****
%k(())  #"&'
.miscactvnullnull

of C
.appScalMnullobj 0	openpanel	openPanel0truebooltrueBool

psof

witQ0	theresult	theResult0chosenpathschosenPaths
.aevtodocnullalis!}*jOlEOeEOOOOOaOaOalE`O_kalE`YhUO_k)	_jUYh **

opeP
SboovtrueR!++,,--r/Users/andreas/Karten/nv/satz4-2012-converted/HLS41_7.kapQPascr
ޭ