# Demo osh script for hello_trace.py

# Allow execution etc.
set safe_mode false

# msg display + user input alias
!import sys
alias msg exec sys.stdout.write('"\*"'); sys.stdin.readline() and '""'

# sleep alias
!from time import sleep
alias slp exec sleep(5)

# encrypt_password alias (Note pythonization of shell arguments using \\**)
alias encpass pr otrace.encrypt_password(\\**)

noecho "Demo script is ready"
noecho msg Press ENTER key to proceed:

##############################################
noecho "*****help, cd, ls, and view commands*****"

help
help pwd

ls
ls -c

cd GetHandler
ls -f
ls -f -..

cd ..
cd Receive
ls
view -i respond

##############################################
noecho msg Press ENTER key to proceed:
noecho "*****pr and exec commands*****"

cd ~~g
pwd
pr Request_stats

Request_stats["count"]
set safe_mode False
abs(Request_stats["count"] - 1)

!Request_stats["count"] = 2

##############################################
noecho msg Press ENTER key to proceed:
noecho "*****trace command*****"

cd ~~g
cd Receive
trace respond
trace

submit(3)
submit(0)

ls ~~
cd ~~
ls
ls -l
cd __trc
ls
ls -l where

##############################################
noecho msg Press ENTER key to proceed:
noecho "*****edit and traceassert*****"
cd ~~g
set trace_active True

edit Receive.respond < ~~w/demo/Receive.respond.patch

submit(2)
submit(0.0005)

ls ~~
cd ~~
ls
self.value
request.headers

##############################################
noecho msg Press ENTER key to proceed:
noecho "*****unpatch and untrace*****"

cd /osh/patches
ls
unpatch Receive.respond
cd ~~g
trace
untrace Receive.respond

##############################################
noecho msg Press ENTER key to proceed:
noecho "*****Object tag tracing*****"
cd ~~g
trace -a tag -c self.value==1 Receive.__init__
trace -c taggedself Receive.respond
submit(2)
submit(1)
cd ~~
pwd
ls

trace
untrace all

noecho "Demo over."
##############################################

