Permalink
Browse files

create better ui by breaking vnclog out from vncdo

  • Loading branch information...
sibson committed Nov 13, 2012
1 parent 554d955 commit 15f65f12b85a1678243375055a2ff1555064c128
View
@@ -79,37 +79,38 @@ The file format is simply a collection of actions::
> echo "type hello" | vncdo -
- > cat some_file.vdo
+ > 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 some_file.vdo
+ > vncdo login.vdo
Creating long lists of commands can be time consuming so vncdotool provides
-a record mode that logs messages and screen captures.
+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.
+Others encoding may work but are not fully supported at this time.::
-As the log is a text file you can edit it to tweak the behaviour.::
+ > vnclog keylog.vdo
+ > vncviewer localhost:2 # do something and then exit viewer
+ > vncdo keylog.vdo
- > vncdo record 6000 vnc.vdo
- > vncviewer localhost:6000
- > sed -i s/click 1/click 2/ vnc.vdo
- > vncdo vnc.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.::
-It may be more convient to automatically launch a VNC client connected to vncdotool in record mode with::
+ > vnclog --viewer vncviewer keylog.vdo
- > vncdo viewer somefile.vdo
-
-By running in service mode vncdotool will create a new file for every client connection and record each clients activity.
+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.::
- > vncdo service 6000
- > vncviewer localhost:6000 # then exit and start new session
- > vncviewer localhost:6000
+ > vnclog --forever --listen 6000 /tmp
+ > vncviewer localhost::6000 # then exit and start new session
+ > vncviewer localhost::6000
+ > ls /tmp/*.vdo
Feedback
--------------------------------
File renamed without changes.
@@ -20,5 +20,5 @@ script
. $DEFAULTFILE
fi
- /usr/bin/vncdotool --logfile $LOGFILE -o $OUTPUT_DIR -s $SERVER $VNCDOTOOL_FLAGS service $PORT
+ /usr/bin/vnclog --forever --logfile $LOGFILE -s $SERVER $VNCDOTOOL_FLAGS --listen $PORT $OUTPUT
end script
View
@@ -23,8 +23,9 @@
entry_points={
"console_scripts": [
- 'vncdo=vncdotool.command:main',
- 'vncdotool=vncdotool.command:main',
+ 'vncdo=vncdotool.command:vncdo',
+ 'vncdotool=vncdotool.command:vncdo',
+ 'vnclog=vncdotool.command:vnclog',
],
},
packages=['vncdotool'],
@@ -1,6 +1,8 @@
-import pexpect
import unittest
import sys
+
+import pexpect
+
from vncdotool import rfb
@@ -10,18 +12,19 @@ def setUp(self):
self.server = pexpect.spawn(cmd, timeout=2)
self.server.logfile_read = sys.stdout
- cmd = 'vncdo -d 99 record 1842 -'
- self.logger = pexpect.spawn(cmd, timeout=2)
- self.logger.logfile_read = sys.stdout
+ cmd = 'vnclog --listen 1842 -s :99 -'
+ self.recorder = pexpect.spawn(cmd, timeout=2)
+ self.recorder.logfile_read = sys.stdout
def tearDown(self):
self.server.terminate(force=True)
- if self.logger:
- self.logger.terminate(force=True)
+ if self.recorder:
+ self.recorder.terminate(force=True)
def run_vncdo(self, commands):
- cmd = 'vncdo -s localhost:1842 ' + commands
- vnc = pexpect.spawn(cmd, logfile=sys.stdout, timeout=2)
+ cmd = 'vncdo -s localhost::1842 ' + commands
+ vnc = pexpect.spawn(cmd, timeout=2)
+ vnc.logfile_read = sys.stdout
retval = vnc.wait()
assert retval == 0, (retval, str(vnc))
@@ -43,8 +46,8 @@ def test_key_alpha(self):
self.assertKeyDown(ord('z'))
self.assertKeyUp(ord('z'))
- self.logger.expect('keydown z')
- self.logger.expect('keyup z')
+ self.recorder.expect('keydown z')
+ self.recorder.expect('keyup z')
def test_key_ctrl_a(self):
self.run_vncdo('key ctrl-a')
@@ -56,5 +59,5 @@ def test_key_ctrl_a(self):
def test_mouse(self):
self.run_vncdo('move 111 222 click 1')
self.assertMouse(111, 222, 1)
- self.logger.expect('move 111 222')
- self.logger.expect('click 1')
+ self.recorder.expect('move 111 222')
+ self.recorder.expect('click 1')
@@ -35,7 +35,7 @@ def run_server(self, server):
self.server.logfile_read = sys.stdout
def run_vncdo(self, commands, exitcode=0):
- cmd = 'vncdo -d 10 ' + commands
+ cmd = 'vncdo -s :10 ' + commands
vnc = pexpect.spawn(cmd, logfile=sys.stdout, timeout=5)
vnc.logfile_read = sys.stdout
vnc.expect(pexpect.EOF)
@@ -13,8 +13,7 @@ class TestSendEvents(object):
def setUp(self):
cmd = 'vncev -rfbport 5933 -rfbwait 1000'
- self.server = pexpect.spawn(cmd, timeout=2)
- self.server.logfile_read = sys.stdout
+ self.server = pexpect.spawn(cmd, logfile=sys.stdout, timeout=2)
def tearDown(self):
self.server.terminate(force=True)
@@ -36,7 +35,7 @@ def assertDisconnect(self):
self.server.expect(disco)
def run_vncdo(self, commands):
- cmd = 'vncdo -d 33 ' + commands
+ cmd = 'vncdo -v -s :33 ' + commands
vnc = pexpect.spawn(cmd, logfile=sys.stdout, timeout=5)
retval = vnc.wait()
assert retval == 0, retval
View
@@ -154,14 +154,12 @@ def test_insert_delay(self):
self.assertEqual(self.deferred.addCallback.call_args_list, expected)
-class TestMain(object):
+class TestParseHost(object):
def setUp(self):
- self.isolation = mock.isolate.object(command.main)
+ self.isolation = mock.isolate.object(command.parse_host)
self.isolation.start()
- self.factory = command.VNCDoToolFactory.return_value
self.options = mock.Mock()
- self.options.display = 0
self.options.server = '127.0.0.1'
parse_args = command.VNCDoToolOptionParser.return_value.parse_args
parse_args.return_value = (self.options, [])
@@ -171,32 +169,37 @@ def tearDown(self):
self.isolation.stop()
self.isolation = None
- def test_single_host_name(self):
- self.options.server = '10.11.12.13'
- command.main()
- assert self.options.server == '10.11.12.13'
+ def test_default(self):
+ command.parse_host(self.options)
+ assert self.options.host == '127.0.0.1'
assert self.options.port == 5900
+ def test_host_display(self):
+ self.options.server = '10.11.12.13:10'
+ command.parse_host(self.options)
+ assert self.options.host == '10.11.12.13'
+ assert self.options.port == 5910
+
def test_host_port(self):
- self.options.server = '10.11.12.13:4444'
- command.main()
+ self.options.server = '10.11.12.13::4444'
+ command.parse_host(self.options)
assert self.options.host == '10.11.12.13'
assert self.options.port == 4444
- def test_localhost_display(self):
- self.options.display = 10
- command.main()
- assert self.options.host == '127.0.0.1'
- assert self.options.port == 5910
-
- def test_host_display(self):
+ def test_just_host(self):
self.options.server = '10.11.12.13'
- self.options.display = 10
- command.main()
- assert self.options.host == '10.11.12.13'
+ command.parse_host(self.options)
+ assert self.options.server == '10.11.12.13'
+ assert self.options.port == 5900
+
+ def test_just_display(self):
+ self.options.server = ':10'
+ command.parse_host(self.options)
+ assert self.options.host == '127.0.0.1'
assert self.options.port == 5910
- def test_host_default(self):
- command.main()
+ def test_just_port(self):
+ self.options.server = '::1111'
+ command.parse_host(self.options)
assert self.options.host == '127.0.0.1'
- assert self.options.port == 5900
+ assert self.options.port == 1111
Oops, something went wrong.

0 comments on commit 15f65f1

Please sign in to comment.