Skip to content

Commit

Permalink
convert to sphinx for documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sibson committed Jul 26, 2013
1 parent 6459e30 commit d5b97c7
Show file tree
Hide file tree
Showing 11 changed files with 607 additions and 115 deletions.
6 changes: 3 additions & 3 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
- --warp to replay script faster than real-time
- --delay, insert a delay between sending commands

vncdotool - 0.2.0 (2012-08-07)
0.2.0 (2012-08-07)
--------------------------------
- add pause, mouseup, mousedown, drag commands
- only require TWisted 11.1.0, so we can have py2.4 support
- bugfixes, thanks Christopher Holm for reporting
- vncdotool type -something now works
- no longer silently fail for unsupported image formats

vncdotool - 0.1.1 (2011-05-18)
0.1.1 (2011-05-18)
--------------------------------
- add PIL to requires
- fix bug where incorrect mouse button is sent

vncdotool - 0.1.0 (2011-03-03)
0.1.0 (2011-03-03)
--------------------------------
- first release
- commands: press, type, move, click, capture, expect
132 changes: 21 additions & 111 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,138 +1,48 @@
vncdotool
=================
vncdotool is a command line VNC client.
------------

It comes in handy when automating interactions with virtual machines or
some hardware devices that are otherwise difficult to control.
vncdotool is a command line VNC client.
It can be useful to automating interactions with virtual machines or
hardware devices that are otherwise difficult to control.

Currently under development, so use at your own peril but what is the
worst that could happen?
It's under active development and seems to be working, but please report any problems you have.

Quick Start
--------------------------------
To see vncdotool in action you can run it against an existing VNC server
or start one locally with x11vnc. Then you can run::

pip install twisted # if you don't already have it
python vncdotool/command.py -s hostaddr type "hello world"

If you have PIL_ installed then you can do a screen captures with::

python vncdotool/command.py -s hostaddr capture screen.png

Installation
--------------------------------
vncdotool depends on Twisted_. Additionally, for capture and expect commands
to work you will need the Python Image Library. You can use your
favourite package manager to grab them. Once you have the dependencies
installed you install from the unpacked source tree.

python setup.py install

Usage
--------------------------------
Once installed you can use the vncdotool command to send key-presses.
Alphanumerics are straightforward just specify the character. For other
keys longer names are used::

> vncdo key a
> vncdo key 5
> vncdo key .
> vncdo key enter
> vncdo key shift-a
> vncdo key ctrl-C
> vncdo key ctrl-alt-del

To type longer strings when entering data or commands you can use the type c
command, which does not support special characters::

> vncdo type "hello world"

You can control the mouse pointer with move and click commands.
NOTE, you should almost always issue a move before a click, as in::

> vncdo move 100 100 click 1

The following would seem to be equivalent but would actually click at (0, 0).
This occurs due to how click events are encoded by VNC, meaning you need to initialise the position of the mouse.::
To use vncdotool you will need a VNC server, most virtualization products
include one, you can use RealVNC, TightVNC or clone you Desktop using x11vnc.

> vncdo move 100 100
> vncdo click 1
Once you have a server running you can install vncdotool from pypi::

If you have the Python Imaging Library (PIL_) installed you can also
make screen captures of the session::
pip install vncdotool

> vncdo capture screenshot.png
and then send a message to the vncserver with::

With PIL_ installed, you can wait for the screen to match a known image.::
vncdo -s vncserveraddress type "hello world"

> vncdo expect somescreen.png 0
You can also take a screen capture with::

Putting it all together you can specify multiple actions on a single
command line. You could automate a login with the following::
vncdo -s vncservername capture screen.png

> vncdo type username key enter expect password_prompt.png
> vncdo type password move 100 150 click 1 expect welcome_screen.png

For more complex automation you can read commands from stdin or a file.
The file format is simply a collection of actions::

> echo "type hello" | vncdo -

> cat login.vdo
# select the name text box, enter your name and submit
move 100 100 click 1 type "my name" key tab key enter

# grab the result
capture screenshot.png

> vncdo login.vdo

Creating long lists of commands can be time consuming so vncdotool provides
a log mode that records a users interactions to a file, which you can then
playback with vncdo.
For best results set your client to use the RAW encoding.
Others encoding may work but are not fully supported at this time.::

> vnclog keylog.vdo
> vncviewer localhost:2 # do something and then exit viewer
> vncdo keylog.vdo

If its too hard to remember which port to use you can tell vncdotool to
launch a client that will be connected to the vnclog session.::

> vnclog --viewer vncviewer keylog.vdo

By running with --forever vncdotool will create a new file for every client
connection and record each clients activity.
This can be useful for quickly recording a number of testcases.::

> vnclog --forever --listen 6000 /tmp
> vncviewer localhost::6000 # then exit and start new session
> vncviewer localhost::6000
> ls /tmp/*.vdo

Sometimes you only care about a portion of the screen, in which case you can
use rcapture and rexpect.
For instance, if your login window appears at x=100, y=200) and is 400 pixels wide by 250 high you could do::

> vncdo rcapture region.png 100 200 400 250
> vncdo rexpect region.png 100 200 0

More documentation can be found at ReadtheDocs_.

Feedback
--------------------------------
Comments, suggestions and patches are welcome and appreciated.
They can be sent to sibson+vncdotool@gmail.com or via github_.
They can be sent to sibson+vncdotool@gmail.com or via GitHub_.
If you are reporting a bug or issue please include the version of both vncdotool
and the VNC server you are using it with.

Acknowledgements
--------------------------------
Thanks to Chris Liechti, techtonik and Todd Whiteman for developing the RFB
and DES implementations used by vncdotool.
Also, to the TigerVNC_ project for creating a community focus RFB specification document



.. _ReadTheDocs: http://vncdotool.readthedocs.org
.. _GitHub: http://github.com/sibson/vncdotool
.. _TigerVNC: http://sourceforge.net/apps/mediawiki/tigervnc/index.php?title=Main_Page
.. _python-vnc-viewer: http://code.google.com/p/python-vnc-viewer
.. _Twisted: http://twistedmatrix.com
.. _PIL: http://www.pythonware.com/products/pil
.. _github: http://github.com/sibson/vncdotool.
177 changes: 177 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build

# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"

clean:
rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/VNCDoTool.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/VNCDoTool.qhc"

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/VNCDoTool"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/VNCDoTool"
@echo "# devhelp"

epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."

info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."

gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."

pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
4 changes: 4 additions & 0 deletions docs/appendix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Appendix I
===============
This appendix contains the community RFB protocol document maintained by the TigerVNC_ project.

Loading

0 comments on commit d5b97c7

Please sign in to comment.