Opens pydoc in your browser. If pydoc has not been started it starts it for you.
1
2
3
4 PYDOC=`which pydoc`
5 if [ ! -x ${PYDOC} ]
6 then
7 echo "could not find executable pydoc (tried: ${PYDOC})"
8 exit 1
9 fi
10
11
12 if [ $
13 then
14 ${PYDOC} $@
15 exit $?
16 fi
17
18
19
20
21 PYDOC_PORT=9000
22 PYDOC_SERVER=http://localhost:${PYDOC_PORT}/
23 running=0
24 pydoc_pses=0
25
26 function browse_docs()
27 {
28 open ${PYDOC_SERVER}
29 }
30
31 for ps in `ps ax | grep "${PYDOC}" | awk '{ print $1 }'`
32 do
33 let pydoc_pses++
34 done
35
36 if [ $pydoc_pses -ge 2 ]
37 then
38 browse_docs
39 else
40 ${PYDOC} -p ${PYDOC_PORT} &
41 until `curl -o /dev/null ${PYDOC_SERVER} &>/dev/null`
42 do
43 echo "waiting for pydoc server ..."
44 sleep 2
45 done
46 browse_docs
47 fi
48 exit 0