Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

kumar mcmillan http://farmdev.com/

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Browse pydoc locally ...

Opens pydoc in your browser. If pydoc has not been started it starts it for you.

   1  
   2  #!/bin/bash
   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  # passthru ...
  12  if [ $# -gt 0 ]
  13  then
  14      ${PYDOC} $@
  15      exit $?
  16  fi
  17  
  18  #--------------------------------------
  19  # or else... start it up automagically :
  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
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS